-- ComString.Mesa Curry - September 26, 1980

DIRECTORY StreamDefs;

ComString: DEFINITIONS =
BEGIN OPEN StreamDefs;

Found:TYPE = {Yes, No, Multiple};
StrArrayDesc:TYPE =DESCRIPTOR FOR ARRAY OF STRING;

OpenCommandLine:PROCEDURE
RETURNS [ in:StreamDefs.DiskHandle ];

CloseCommandLine:PROCEDURE[in:StreamHandle];

StrToIndex : PROCEDURE [ str:STRING, sad:StrArrayDesc ]
RETURNS [ index:CARDINAL ]; --index = 0 => NOT found

StrFill: PROCEDURE[
unkstr:STRING,
sad:StrArrayDesc,
addstr:STRING ← NIL ]
RETURNS [ found:Found ];
--
Tries to find str using sad:StrArrayDesc
--
If not found then found ← No
--
If str is part of or equal to only one string then
--
found ← Yes
--
unkstr is filled out
--
if addstr present
--
then addstr gets remainder of string
--
else the remainder is output using IODefs.WriteStr
--
If str is part of more than one string then
--
found ← Multiple
--
unkstr is filled out to point of disaggreement
--
if addstr # NILL
--
then addstr gets additions to string
--
else the additions are output using WriteStr

GetKeyboardCommand:PROCEDURE[
queststr:STRING,
sad:StrArrayDesc]
RETURNS[index:CARDINAL];
-- User interaction to get a legal command
-- Only descriminating characters are required
-- ESC or TAB show current legal commands
-- CR, ?, or an illegal char show all legal commands
GetStreamCommand:PROCEDURE[
stream:StreamHandle,
sad:StrArrayDesc,
substr:STRING]
RETURNS[index:CARDINAL]; -- 0 if command not found

-- Strings rep: SingArgStr/SubStr or SingArgStr[SubStr]
GetStreamArg:PUBLIC PROCEDURE[
stream:StreamHandle,
argstr:STRING,
substr:STRING ]
RETURNS[argfound:BOOLEAN];

-- Strings rep: SingArgStr/SubStr or SingArgStr[SubStr]
GetStringArg:PROCEDURE[
sourcestr:STRING,
index:CARDINAL,
argstr:STRING,
substr:STRING]
RETURNS[CARDINAL]; -- = 0 if nothing found

END.