MCrossUtilities.mesa
P.Rovner May 2, 1983 12:42 pm
DIRECTORY
Ascii,
MCrossUtilityDefs,
MessageWindow USING[Confirm],
Rope USING[ROPE, Size, Fetch, Compare];
----------------------------------------------------------------
MCrossUtilities: PROGRAM
IMPORTS --MessageWindow, --Rope
EXPORTS MCrossUtilityDefs
=
BEGIN
Confirm: PUBLIC PROCEDURE RETURNS[BOOLEAN] =
{RETURN[MessageWindow.Confirm["[Confirm] "]]};
IsNumber: PUBLIC PROCEDURE[s: Rope.ROPE] RETURNS[BOOLEAN] =
{ FOR i: INT IN [0..Rope.Size[s])
DO IF NOT Rope.Fetch[s, i] IN ['0..'9] THEN RETURN[FALSE] ENDLOOP;
RETURN[TRUE]};
IsTerminator: PUBLIC PROCEDURE[ch: CHARACTER] RETURNS [BOOLEAN] =
{ RETURN[SELECT ch FROM
IN ['0..'9], IN ['A..'Z], IN ['a..'z] => FALSE,
ENDCASE => TRUE]};
Returns TRUE if the string has only spaces, tabs and CRs
IsLineEmpty: PUBLIC PROCEDURE[line: Rope.ROPE] RETURNS[BOOLEAN] =
{ FOR i: INT IN [0..Rope.Size[line])
DO SELECT Rope.Fetch[line, i] FROM
Ascii.SP, Ascii.TAB, Ascii.CR => NULL;
ENDCASE => RETURN[FALSE] ENDLOOP;
RETURN[TRUE]};
Returns True if Str1 is Lexically less then Str2
StringLessThan: PUBLIC PROCEDURE[str1, str2: Rope.ROPE] RETURNS[BOOLEAN] =
{RETURN[Rope.Compare[str1, str2, FALSE] = less]};
Returns True if Str1 is equal to Str2
EqualString: PUBLIC PROCEDURE[str1, str2: Rope.ROPE] RETURNS[BOOLEAN] =
{RETURN[Rope.Compare[str1, str2] = equal]};
END.