|
DataMuseum.dkPresents historical artifacts from the history of: CP/M |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about CP/M Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 3840 (0xf00) Types: TextFile Names: »TESTCMD.PAS«
└─⟦dd59903ef⟧ Bits:30005887 Klub diskette for udveksling af software └─ ⟦this⟧ »TESTCMD.PAS«
PROGRAM testcmd; æ +---------------------------------------------------------+ øThis is a program to test and demonstrate the procedure, ø øREADCMD, and to illustrate pertinent global declarations.ø øIt also illustrates the use of the accessory procedure, ø øGETNUMS, to convert numeric arguments from strings to an ø øarray of integers. ø +---------------------------------------------------------+ å æ$E+å CONST maxword = 14; æMAX NO. OF CHARACTERS AN ARGUMENT CAN HAVE å maxargs = 11; æMAX NO. OF ARGUMENTS ALLOWED IN COMMAND TAILå maxline = 80; margin = ' '; TYPE string0 = string 0; string255 = string 255; wrdtype = string maxword; wrdarray = ARRAYÆ1..maxargsÅ OF wrdtype; numarray = ARRAYÆ1..maxargsÅ OF INTEGER; byte = 0..255; VAR source : wrdtype; key : CHAR; name : wrdarray; æIDENTIFIERS FOR THE ARGUMENTS IN THE å i, æCOMMAND TAIL.å nargs, æACTUAL NUMBER OF ARGUMENTS IN COMMAND TAIL å numct : byte; æNUMBER OF NUMERIC ARGUMENTS å num : numarray; æIDENTIFIERS FOR NUMERIC ARGUMENTS å sum : INTEGER; FUNCTION length ( source: string255 ): INTEGER; external; æ$Igetnums.p å æ$Ireadcmd.p å PROCEDURE arguments; VAR i : byte; BEGIN æ-----------------------------arguments-----------------------------å WRITELN(' FOR i := 1 to nargs:'); FOR i := 1 TO nargs DO WRITELN(margin,'nameÆ',i:1,'Å = ',nameÆiÅ); WRITELN END; æ-----------------------------arguments-----------------------------å PROCEDURE maxarguments; VAR i : byte; BEGIN æ---------------------------maxarguments----------------------------å WRITELN(' FOR i := 1 to maxargs:'); FOR i := 1 TO maxargs DO WRITELN(margin,'nameÆ',i:1,'Å = ',nameÆiÅ); WRITELN; FOR i := 1 TO maxargs DO WRITELN(margin,'length(nameÆ',i:1,'Å) = ',length(nameÆiÅ):2); WRITELN; END; æ---------------------------maxarguments----------------------------å PROCEDURE numerics; VAR i : byte; BEGIN æ-----------------------------numerics------------------------------å getnums(name,nargs,num,numct); WRITELN(' FOR i := 1 to numct:'); FOR i := 1 TO numct DO WRITELN(margin,'numÆ',i:1,'Å =',numÆiÅ: 5); WRITELN; sum := 0; FOR i := 1 to numct DO sum := sum + numÆiÅ; WRITELN(margin,'Sum of numeric arguments = ',sum: 1); WRITELN END; æ-----------------------------numerics------------------------------å BEGIN æ-------------------------------testcmd-------------------------------å readcmd(name,nargs); IF (nameÆ1Å = 'Q') OR (nameÆ1Å = 'q') THEN WRITELN(margin,'Program aborted.') ELSE BEGIN source := nameÆ1Å; key := nameÆ2,1Å; WRITELN(margin,'The source filename is ',source,'.'); WRITELN(margin,'The key is ',key); WRITELN; IF (key = 'A') OR (key = 'a') OR (sourceÆ1Å = 'Ø') THEN arguments; IF (key = 'M') OR (key = 'm') OR (sourceÆ1Å = 'Ø') THEN maxarguments; IF (key = 'N') OR (key = 'n') OR (sourceÆ1Å = 'Ø') THEN numerics; WRITELN(margin,'The number of arguments, nargs =',nargs: 3) END END. æ-------------------------------testcmd-------------------------------å «eof»