DataMuseum.dk

Presents historical artifacts from the history of:

CP/M

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about CP/M

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download

⟦b581e81a9⟧ TextFile

    Length: 7936 (0x1f00)
    Types: TextFile
    Names: »MLLIST.PAS«

Derivation

└─⟦b8bf5a067⟧ Bits:30009529 PolyPascal version 3.10 DANSK
    └─⟦this⟧ »MLLIST.PAS« 

TextFile

PROGRAM list; æ$C-,K-,R-å

æ Modificeret til brug af Rc862-printeren 890212.               å

æ LIST is a very useful all-purpose list program. It can output å
æ listings of all sorts of text files, with headers, line num-  å
æ bers, and full control of page length, line length, left mar- å
æ gin and bottom margin. LIST obtains all its parameters from   å
æ the command line. The command line format is:                 å
æ                                                               å
æ    LIST <filename><options>,...,<filename><options>           å
æ                                                               å
æ where <filename> is a file name acceptable to the operating   å
æ system, and <options> are one or more options, selected from  å
æ the following list:                                           å
æ                                                               å
æ    Pnn     Set page length to nn.                             å
æ    Lnn     Set line length to nn.                             å
æ    Inn     Indent each line printed by nn blanks.             å
æ    Snn     Skip nn lines at the bottom of each page.          å
æ    H       Print file name and page number on top of          å
æ            each page.                                         å
æ    Hsssss  Print header string and page number on top         å
æ            of each page.                                      å
æ    N       Print line number before each line.                å
æ    F       Form-feed. Skip to top of next page.               å
æ                                                               å
æ Each option must be preceded by a forward slash. An example   å
æ of a LIST command line:                                       å
æ                                                               å
æ    LIST WORK.PAS/I8/N/HWorkfile Listing,CALC.PAS,/F           å
æ                                                               å
æ This line will cause WORK.PAS to be listed with an indenta-   å
æ tion (left margin) of 8, line numbers and a user specified    å
æ heading. Following this, CALC.PAS is listed using the default å
æ page format parameters, and finally a form-feed is output.    å

CONST
  dpagelen = 66;                æDefault page length  ML  å
  dlinelen = 80;                æDefault line length  ML  å
  dindent  = 0;                 æDefault indentationå
  dskip    = 3;                 æDefault bottom skip  ML  å
  cr       = @13;               æCarriage returnå
  lf       = @10;               æLinefeedå
  ht       = @9;                æHorizontal tabå
  ff       = @12;               æFormfeedå
  esc      = @27;               æEscapeå

VAR
  i,pos,pagelen,linelen,indent,skip,arg,
  pageno,lineno,lin,col,width: integer;
  ch,opt: char;
  printhdr,linenumbers: boolean;
  ns: STRINGÆ4Å;
  filename,header: STRINGÆ64Å;
  line: STRINGÆ127Å;
  infile: text;
  cmdlin: STRINGÆ127Å AT dseg:$80;

FUNCTION cap(ch: char): char;
BEGIN
  IF (ch>='a') AND (ch<='z') THEN
  cap:=chr(ord(ch)-32) ELSE cap:=ch;
END;

BEGIN
  pagelen:=dpagelen; linelen:=dlinelen; indent:=dindent;
  skip:=dskip; header:=''; printhdr:=false; linenumbers:=false;
  filename:=''; line:=cmdlin+@0; pos:=1;
  REPEAT
    WHILE lineÆposÅ IN Æ' ',','Å DO pos:=succ(pos);
    WHILE NOT(lineÆposÅ IN Æ' ',',','/',@0Å) DO
    BEGIN
      filename:=filename+lineÆposÅ; pos:=succ(pos);
    END;
    WHILE lineÆposÅ=' ' DO pos:=succ(pos);
    WHILE lineÆposÅ='/' DO
    BEGIN
      pos:=succ(pos); opt:=cap(lineÆposÅ); pos:=succ(pos);
      CASE opt OF
        'P','L','I','S':
        BEGIN
          arg:=0;
          WHILE lineÆposÅ IN Æ'0'..'9'Å DO
          BEGIN
            arg:=arg*10+ord(lineÆposÅ)-ord('0');
            pos:=succ(pos);
          END;
          CASE opt OF
            'P': pagelen:=arg;
            'L': linelen:=arg;
            'I': indent:=arg;
            'S': skip:=arg;
          END;
        END;
        'H':
        BEGIN
          WHILE NOT(lineÆposÅ IN Æ',','/',@0Å) DO
          BEGIN
            header:=header+lineÆposÅ; pos:=succ(pos);
          END;
          printhdr:=true;
        END;
        'N': linenumbers:=true;
        'F': write(lst,ff);                                       æ ML å 
      OTHERWISE
        writeln('Unknown option identifier: "',opt,'"');
        halt;
      END;
      WHILE lineÆposÅ=' ' DO pos:=succ(pos);
    END;
    IF filename<>'' THEN
    BEGIN
      assign(infile,filename);
      æ$I-å reset(infile) æ$I+å;
      IF iores<>0 THEN
      BEGIN
        writeln('File not found: "',filename,'"');
        halt;
      END;
      IF header='' THEN header:='File '+filename;
      pageno:=1; lineno:=1; lin:=0; width:=linelen-indent;
      IF linenumbers THEN width:=width-6;
      WHILE NOT eof(infile) DO
      BEGIN
        IF keypress THEN
        BEGIN
          read(kbd,ch);
          IF ch=esc THEN
          BEGIN
            writeln('Interrupted');
            IF lin<>0 THEN
            FOR i:=lin TO pred(pagelen) DO write(lst,lf);
            halt;
          END;
        END;
        IF (lin=0) THEN
        BEGIN
          æ orienteringskopi til skaermen                              ML å
          write('':indent,header);                                   æ ML å 
          writeln('':linelen-indent-len(header)-8,'Page ',pageno);   æ ML å
          write(lf);                                                 æ ML å   
        END;
        IF printhdr AND (lin=0) THEN
        BEGIN
          write(lst,'':indent,header);
          writeln(lst,'':linelen-indent-len(header)-8,'Page ',pageno);
          write(lst,lf,lf);
          lin:=3;
        END;
        write(lst,'':indent);
        IF linenumbers THEN
        BEGIN
          str(lineno,ns); write(lst,copy('000',1,4-len(ns)),ns,'  ');
        END;
        col:=0;
        ch:=' ';                                                     æ ML å
        WHILE ((NOT eoln(infile)) AND (ch <> ff)) DO                 æ ML å
        BEGIN
          read(infile,ch);
          CASE ch OF
            @32..@126:
            BEGIN
              IF col<width THEN  write(lst,ch);
              col:=succ(col);
            END;
            ht:
            REPEAT
              IF col<width THEN write(lst,' ');
              col:=succ(col);
            UNTIL col MOD 8=0;
            ff:
            æ hvis programmet leverer header,
              negligeres filens egne ff-er                         ML å
            IF NOT printhdr THEN                                 æ ML å
            BEGIN
              write(lst,ff);                                     æ ML å
              pageno:=succ(pageno); lin:=0;
            END
            ELSE 
            BEGIN
              writeln(lst);                                      æ ML å
            END;                                                 æ ML å
          END;
        END;
        IF  (ch <> ff) THEN                                      æ ML å
        BEGIN                                                    æ ML å
          readln(infile);
          writeln(lst);
        END;                                                     æ ML å       
        lineno:=succ(lineno);
        IF NOT ((ch=ff) AND (lin=0)) THEN lin:=succ(lin);        æ ML å
        IF lin=pagelen-skip THEN
        BEGIN
          write(lst,ff);                                         æ ML å
          pageno:=succ(pageno);
          lin:=0;
        END;
      END;
      æ klar til en eventuel ny fil-udskrift                       ML å
      IF lin<>0 THEN write(lst,ff);                              æ ML å
      filename:='';
      header:='';
      printhdr:=false;
      linenumbers:=false;
    END;
  UNTIL lineÆposÅ=@0;
END.
«eof»