Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-04 - decus/20-0135/comp/videdp.sim
There are 2 other files named videdp.sim in the archive. Click here to see a list.
00040	COMMENT First release of VIDEDP by B`rje Ohlman, FOA. 78 07 19 ;
00080	
00120	COMMENT This is a program which makes it possible to output a text
00160	        containing indices and a straight right margin on a Diablo
00200	        1620 terminal.                                          ;
00240	
00280	COMMENT Those lines who are members of a section with indices and/or
00320	        underlinings will be put into a que while handeled before
00360	        output.                                                 ;
00400	
00440	COMMENT Corrections by Jacob Palme 1978-07-28:
00480	        1) Error message when outfile = infile
00520	        2) Error message when outfile will overwrite an
00560	           existing file
00600	        3) Normal prompter if rescan finds no "-" in
00640	           the command line;
00680	
00720	COMMENT Corrections by Jacob Palme 1978-12-15:
00760	        VIDEDP sets .TTY FORM and .TTY NO CRLF,
00800	        and .TTY TAB and .TTY GAG, because
00840	        otherwise strange things will happen!!!;
00880	
00920	BEGIN
00960	EXTERNAL TEXT PROCEDURE inline, scanto, conc, upcase, compress, rest;
01000	EXTERNAL CHARACTER PROCEDURE fetchar, findtrigger;
01040	EXTERNAL BOOLEAN PROCEDURE rescan, numbered;
01080	EXTERNAL INTEGER PROCEDURE scan, scanint, search, trmop;
01120	EXTERNAL PROCEDURE outstring, exit, outchr, forceout;
01160	EXTERNAL REF (infile) PROCEDURE findinfile;
01200	EXTERNAL REF (outfile) PROCEDURE findoutfile;
01240	INTEGER arrayindex;     ! This is the number of commands allowed;
01280	arrayindex:=10;         ! in the commandline (switchline)       ;
01320	simset BEGIN
01360	
01400	  COMMENT       This procedure takes care of the error handeling.
01440	   ;
01480	
01520	  PROCEDURE error(err);
01560	  INTEGER err;  ! err: The type of error that have occured.     ;
01600	  BEGIN
01640	
01680	  COMMENT       pag, pagnum, err0, err1, err2a, err2b, err3, err4,
01720	                err5: are dummyvariables as it's impossible to output
01760	                a text constant with outstring.                 ;
01800	
01840	    TEXT pag, pagenum, err0, err1, err2a, err2b, err3, err4, err5;
01880	    pag:-copy("Page");
01920	    pagenum:-copy(blanks(4));
01960	    err0:-copy("Please try again. ");
02000	    err1:-copy(" %VIDEDP - Illegal command after '.'.");
02040	    err2a:-copy("?VIDEDP - Command:");
02080	    err2b:-copy(" used more than once");
02120	    err3:-copy("?VIDEDP -Can't find infile.");
02160	    err4:-copy("?VIDEDP - Cant create outfile.");
02200	    err5:-copy(" %VIDEDP - .L command after .U command ?");
02240	    outchr(sysout,char(13),1);
02280	    outchr(sysout,char(10),1);
02320	    IF err=1 OR err=5 THEN BEGIN
02360	      outstring(sysout,pag);
02400	      pagenum.putint(page);
02440	      outstring(sysout,pagenum);
02480	    END;
02520	    IF err=1 THEN outstring(sysout,err1);
02560	    IF err=2 THEN BEGIN
02600	      outstring(sysout,err2a);
02640	      outstring(sysout,key[index]);
02680	      outstring(sysout,err2b);
02720	    END;
02760	    IF err=3 THEN outstring(sysout,err3);
02800	    IF err=4 THEN outstring(sysout,err4);
02840	    IF err=5 THEN outstring(sysout,err5);
02880	    outchr(sysout,char(13),1);
02920	    outchr(sysout,char(10),1);
02960	    IF err=2 OR err=3 OR err=4 THEN outstring(sysout,err0);
03000	    forceout(sysout);
03040	    IF err=1 THEN BEGIN
03080	      dot:=FALSE;
03120	      GOTO no_command;
03160	    END;
03200	    IF err=3 OR err=4 THEN GOTO new_file;
03240	  END error ;
03280	
03320	COMMENT This procedure does two things:
03360	
03400	        1) It counts the numbers of characters in checkline
03440	           and stores the result in the variable x, if it's
03480	           greater than x's current value.
03520	           When a group of quelines are ready for output x
03560	           will hold the maximum linelength for this group
03600	           of lines.
03640	
03680	        2) It will in the boolean array "blank" set every
03720	           element, corresponding to a characterposition
03760	           not containing a blank-character, to FALSE.
03800	           When a group of quelines are ready for output
03840	           the elements in "blank" which still are TRUE
03880	           will indicate that the corresponding character-
03920	           position is blank in all quelines.                   ;
03960	
04000	  PROCEDURE check (checkline);
04040	  TEXT checkline;       ! Line to be checked.                   ;
04080	  BEGIN
04120	    !   ***** 1 *****                                           ;
04160	    IF checkline.sub(2,1)="%" THEN
04200	    checkline:-checkline.sub(3,checkline.length-2);
04240	    IF checkline.strip.length>x THEN x:=checkline.strip.length;
04280	    !   ***** 2 *****                                           ;
04320	    WHILE checkline.more DO
04360	    IF checkline.getchar NE ' ' THEN blank[checkline.pos-1]:=FALSE;
04400	    checkline.setpos(1);
04440	  END check;
04480	
04520	  COMMENT       This procedure dose the following things:
04560	
04600	                1) Reads commands acoording to the making of
04640	                   straight right margin and sets the left
04680	                   margin.
04720	                   Rubs out the command characters or the
04760	                   entier line if marked with '&'.
04800	                   Exeption if command is '_', then the dot
04840	                   is replaced with an '_'.
04880	
04920	                2) Performes the number of halfstep linefeeds
04960	                   stored in the variable "linefeed".
05000	
05040	                3) If a group of lines contains a section of
05080	                   blanks all but the first one is treated as
05120	                   ordinary characters.
05160	                   If automatic is TRUE and characterposition
05200	                   rightmarg not contains a blank and the rest
05240	                   of the line is blank then auto will be set
05280	                   to TRUE.
05320	
05360	                4) For lines not belonging to a que and before
05400	                   the first queline is put out the length (in
05440	                   1/120 inch parts) of the spaces, requested to
05480	                   achive a straight right margin is calculated.
05520	                   Note that if the number of characters in a line
05560	                   is graeater than the number of characterpositions
05600	                   the length of the spaces will be decreased.
05640	                   If auto is TRUE then "autochar" will indicate
05680	                   wich positons not containing dummyblanks.
05720	
05760	                5) The characters is put out and if it's a blank
05800	                   the unnormal length of it is achived by sending
05840	                   ESC-sequences to the Diablo terminal (see the
05880	                   Diablo 1620 manual).                         ;
05920	
05960	  PROCEDURE output(linefeed,outputline);
06000	  TEXT outputline;
06040	  INTEGER linefeed;
06080	  BEGIN
06120	  COMMENT       slask4: Textdummy.
06160	                autochar: see comment 4 above.
06200	                skip:   Is set to TRUE if the command '&' is given.
06240	                slask1: Characterdummy.
06280	                command: To store commands in.
06320	                re:     Realdummy.
06360	                rubout: The number of commandcharacters to be rubed
06400	                        out in the begining of outputline.
06440	                marg:   Integerdummy.
06480	                bla:    Number of blanks in outputline.
06520	                spac:   Dummy for space.
06560	                extr:   Dummy for extra.
06600	                tab:    Number of blanks after each other in
06640	                        outputline.
06680	                tabmax: Maximum value of tab during this line.
06720	                tabnext: The second greatest value of tab during
06760	                        this line. Are used to detect if a line
06800	                        belongs to a table or simular when
06840	                        automatic is used.
06880	                i:      Loopinteger.
06920	                chrlength: The length of a normal character, usually
06960	                        10, but there are typewheels for the Diablo
07000	                        with only 10 characters/inch, which means
07040	                        that the character length is 12. Don't
07080	                        forget to turn the switch on the Diablo. ;
07120	
07160	    TEXT slask4;
07200	    BOOLEAN ARRAY autochar[1:140];
07240	    BOOLEAN skip;
07280	    CHARACTER slask1, command;
07320	    REAL re;
07360	    INTEGER rubout, marg, bla ,spac, extr, tab, tabnext, tabmax, i;
07400	    INTEGER chrlength;
07440	    slask4:-copy(blanks(140));
07480	    chrlength:=10;
07520	    IF fetchar(outputline,outputline.strip.length) EQ char(12) THEN
07560	
07600	    COMMENT     When a formfeed character apears in the variable
07640	                "page" is increased by one. And if the last
07680	                character before it was one of ".:;!?" then it's
07720	                also considered as endof this section of the text. ;
07760	
07800	    BEGIN
07840	      page:=page+1;
07880	      slask1:=fetchar(outputline,outputline.strip.length-1);
07920	      IF slask1 EQ '.' OR slask1 EQ ':' OR slask1 EQ ';'
07960	      OR slask1 EQ '!' OR slask1 EQ '?' THEN BEGIN
08000	        IF justify OR automatic THEN resetj:=TRUE;
08040	        j:=FALSE;
08080	      END;
08120	    END;
08160	    !           ***** 1 *****                                   ;
08200	    IF outputline.getchar EQ '.' THEN BEGIN
08240	      command:=outputline.getchar;
08280	      IF command EQ '%' THEN
08320	      outputline:-outputline.sub(3,outputline.length-2)
08360	      ELSE BEGIN
08400	        multicommand:
08440	        IF command EQ '&' THEN BEGIN
08480	          skip:=TRUE;
08520	          outputline.setpos(outputline.pos+2);
08560	          command:=outputline.getchar;
08600	        END;
08640	        IF command EQ 'J' OR command EQ 'j' THEN BEGIN
08680	          justify:=TRUE;
08720	          j:=TRUE;
08740	automatic:=false;
08760	        END;
08800	        IF command EQ 'F' OR command EQ 'f' THEN j:=TRUE;
08840	        IF command EQ 'A' OR command EQ 'a' THEN automatic:=TRUE;
08880	        IF command EQ 'N' OR command EQ 'n' THEN BEGIN
08920	          automatic:=FALSE;
08940	resetj:=false;
08960	          j:=FALSE;
09000	          justify:=FALSE;
09040	        END;
09080	        IF digit(command) THEN BEGIN
09120	          outputline.setpos(outputline.pos-1);
09160	          marg:=scanint(outputline);
09200	          slask1:=outputline.getchar;
09240	          IF slask1 EQ 'L' OR slask1 EQ 'l' THEN leftmarg:=marg
09280	          ELSE IF slask1 EQ 'R' OR slask1 EQ 'r' THEN rightmarg:=marg;
09320	        END;
09360	        IF skip THEN BEGIN
09400	          IF command EQ ' ' THEN GOTO out
09440	          ELSE BEGIN
09480	            outputline.setpos(outputline.pos+2);
09520	            command:=outputline.getchar;
09560	            GOTO multicommand;
09600	          END;
09640	        END
09680	        ELSE BEGIN
09720	          rubout:=outputline.pos-1;
09760	          outputline.setpos(1);
09800	        END;
09840	        IF command EQ '_' THEN outputline.putchar('_')
09880	        ELSE FOR i:=1 STEP 1 UNTIL rubout DO outputline.putchar(' ');
09920	      END;
09960	    END;
10000	    !           ***** 2 *****                                   ;
10040	    IF NOT other THEN BEGIN
10080	      FOR i:=1 STEP 1 UNTIL linefeed DO BEGIN
10120	        outchr(out_file,char(27),1);
10160	        outchr(out_file,'U',1);
10200	      END;
10240	    END ELSE IF linefeed>0 THEN outchr(out_file,char(10),1);
10280	    outputline.setpos(1);
10320	    !           ***** 3 *****                                   ;
10360	    IF automatic AND NOT quelines THEN BEGIN
10400	      auto:=FALSE;
10440	      j:=FALSE;
10480	      i:=rightmarg+1;
10520	      WHILE blank[i] AND i<140 DO i:=i+1;
10560	      IF i=140 AND NOT blank[rightmarg] AND blank[140] THEN BEGIN
10600	        auto:=TRUE;
10640	        j:=TRUE;
10680	      END;
10720	    END;
10760	    !           ***** 4 *****                                   ;
10800	    IF j AND NOT other THEN BEGIN
10840	      IF NOT quelines THEN BEGIN
10880	        IF auto THEN BEGIN
10920	          ai:=leftmarg;
10960	          FOR i:=1 STEP 1 UNTIL leftmarg DO autochar[i]:=TRUE;
11000	          FOR i:=leftmarg+1 STEP 1 UNTIL 140 DO autochar[i]:=FALSE;
11040	        END;
11080	        tab:=0;
11120	        tabnext:=0;
11160	        tabmax:=0;
11200	        FOR i:=leftmarg+1 STEP 1 UNTIL x DO BEGIN
11240	          IF blank[i] THEN tab:=tab+1 ELSE BEGIN
11280	            IF tab>tabmax THEN BEGIN
11320	              tabnext:=tabmax;
11360	              tabmax:=tab;
11400	            END
11440	            ELSE IF tab>tabnext THEN tabnext:=tab;
11480	            tab:=0;
11520	          END;
11560	          IF tab>1 THEN blank[i]:=FALSE ELSE
11600	          IF auto THEN BEGIN
11640	            autochar[i]:=TRUE;
11680	            ai:=ai+1;
11720	            blank[ai]:= IF tab=1 THEN TRUE ELSE FALSE;
11760	          END;
11800	        END;
11840	        IF auto THEN BEGIN IF tabmax-tabnext>2 THEN auto:=FALSE; END;
11880	        IF auto THEN BEGIN
11920	          FOR i:=ai+1 STEP 1 UNTIL x DO blank[i]:=TRUE;
11960	          x:=ai;
12000	        END;
12040	        FOR i:=leftmarg+1 STEP 1 UNTIL x DO IF blank[i] THEN
12080	        bla:=bla+1;
12120	        IF bla>0 THEN BEGIN
12160	          re:=(rightmarg-x)*chrlength/bla;
12200	          space:=chrlength+entier(re);
12240	          extra:=(re-entier(re))*bla;
12280	        END;
12320	      END;
12360	      IF auto THEN BEGIN
12400	        FOR i:=1 STEP 1 UNTIL rightmarg DO
12440	        IF autochar[i] THEN slask4.putchar(outputline.getchar)
12480	        ELSE outputline.getchar;
12520	        outputline:-slask4;
12560	        outputline.setpos(1);
12600	      END;
12640	      !         ***** 5 *****                                   ;
12680	      IF (space<126 OR (space<127 AND extra=0)) AND space>=0 THEN BEGIN
12720	        FOR i:=1 STEP 1 UNTIL leftmarg DO
12760	        outchr(out_file,outputline.getchar,1);
12800	        extr:=extra;
12840	        FOR i:=leftmarg+1 STEP 1 UNTIL x DO BEGIN
12880	          IF blank[i] THEN BEGIN
12920	            IF extr>0 THEN BEGIN
12960	              spac:=space+1;
13000	              extr:=extr-1;
13040	            END ELSE
13080	            spac:=space;
13120	            IF spac=34 OR spac=35 OR spac=63 OR spac=90 OR spac=91 OR
13160	            spac=92 OR spac=95 OR spac=123 OR spac=125 THEN BEGIN
13200	              outchr(out_file,char(32),1);
13240	              spac:=spac-chrlength;
13280	            END;
13320	            IF spac=8 THEN BEGIN
13360	              outchr(out_file,char(8),1);
13400	              spac:=18;
13440	            END;
13480	            outchr(out_file,char(27),1);
13520	            outchr(out_file,char(31),1);
13560	            outchr(out_file,char(spac+1),1);
13600	            outchr(out_file,outputline.getchar,1);
13640	            outchr(out_file,char(27),1);
13680	            outchr(out_file,char(31),1);
13720	            outchr(out_file,char(chrlength+1),1);
13760	          END blank ELSE
13800	          outchr(out_file,outputline.getchar,1);
13840	        END;
13880	      END ELSE outstring(out_file,outputline.strip);
13920	    END ELSE outstring(out_file,outputline.strip);
13960	    outchr(out_file,char(13),1);
14000	  out:END output;
14040	
14080	  REF (infile) in_file;
14120	  REF (outfile) out_file;
14160	  REF (head) lineque;
14200	  link CLASS line;
14240	
14280	COMMENT         The attributes of the "line" elements, which
14320	                can be put into the lineque are:
14360	
14400	                1) contents: A textvariable containing the
14440	                             current textline.
14480	
14520	                2) kog: The number of halfstep linefeeds to be
14560	                        performed before the line is put out.   ;
14600	
14640	  BEGIN
14680	    INTEGER kog;
14720	    TEXT contents;
14760	    contents:-blanks(140);
14800	  END;
14840	  COMMENT       line1:  Contains current textline (contents)
14880	                        and the linefeedvalue (kog).
14920	                queoutline: Dummyline.
14960	                arg, key: see external procedure scan.
15000	                line2:  Stores preceding line if not stored in que.
15040	                subcommands: Textconstant.
15080	                switchcommands: Textconstant.
15120	                switch: Contains commandstring.
15160	                triggs: Textconstant.
15200	                t:      Textdummy (Rescan).
15240	                slask2: Textdummy.
15280	                newfile, started, end_videdp: Textconstants.
15320	                overwriting, inoutequal, tocontinue: Textconstants.
15360	                command:Contains current command.
15400	                slask3: Characterdummy.
15440	                blank:  see comment 2, check.
15480	                ready:  Tells if there any lines in lineque.
15520	                oldl:   Tells if the number stored in "l" is from
15560	                        this time or the time before.
15600	                automatic: If it's TRUE the inputlines are
15640	                        supposed to have a straight right margin
15680	                        made by entier blanks.
15720	                auto:   If TRUE the inputline had straight right
15760	                        margin.
15800	                quelines: Tells if the lines to output comes from
15840	                        a que or not.
15880	                dot:    Tells i the first character in the current
15920	                        line is a '.'.
15960	                b:      Tells if there have been any dot-line without
16000	                        a command.
16040	                j:      Tells if the line should get a straight right
16080	                        margin.
16120	                firstline: Tells if the current line is the first
16160	                        from a new file.
16200	                sequence: TRUE if inputfile has linenumbers.
16240	                resetj: Set to true after blankline if automatic or
16280	                        justify is true.
16320	                justify: Are set TRUE when the j command is given.
16360	                other:  If TRUE text is to be put out on other term-
16400	                        inal than Diablo.
16440	                cog:    Line spacing.
16480	                r:      Number of normal lines in que.
16520	                u:      Number of u-lines in que.
16560	                l:      Number of l-lines in que.
16600	                x:      see comment 1, check.
16640	                i:      Loopinteger.
16680	                space:  length of the spaces (1/120 inch).
16720	                extra:  The extra first spaces should be one 1/120
16760	                        inch part longer than space tells.
16800	                leftmarg: Leftmargin.
16840	                rightmarg: Rightmargin.
16880	                index:  see external procedure scan.
16920	                page:   Number of pages.
16960	                ai:     Loopinteger.                            ;
17000	  REF (line) line1,queoutline;
17040	  TEXT ARRAY arg, key[1:arrayindex];
17080	  TEXT line2, subcommands, switchcommands, switc, triggs, t, slask2;
17120	  TEXT newfile, started, end_videdp, overwriting, inoutequal;
17160	  TEXT tocontinue;
17200	  CHARACTER command, slask3;
17240	  BOOLEAN ARRAY blank[1:140];
17280	  BOOLEAN ready, oldl, automatic, auto, quelines, dot, b, j;
17320	  BOOLEAN firstline, sequense, resetj, justify, other;
17360	  INTEGER cog,r,u,l,x,i,space,extra;
17400	  INTEGER leftmarg, rightmarg, index, page, ai;
17440	  key[1]:-copy("/DEFAULT:/D:/J/O/A/RL/COG:/L:/R:=");
17480	  key[2]:-key[1].sub(10,3);     ! /D    ;
17520	  key[3]:-key[1].sub(13,2);     ! /J    ;
17560	  key[4]:-key[1].sub(15,2);     ! /O    ;
17600	  key[5]:-key[1].sub(17,2);     ! /A    ;
17640	  key[6]:-key[1].sub(19,3);     ! /RL   ;
17680	  key[7]:-key[1].sub(22,5);     ! /COG: ;
17720	  key[8]:-key[1].sub(27,3);     ! /L:   ;
17760	  key[9]:-key[1].sub(30,3);     ! /R:   ;
17800	  key[10]:-key[1].sub(33,1);    ! =     ;
17840	  key[1]:-key[1].sub(1,9);      ! /DEAFAULT: ;
17880	  newfile:-copy("Input new files and commands.");
17920	  started:-copy("[VIDEDP started]");
17960	  end_videdp:-copy("[End of VIDEDP execution]");
18000	  overwriting:-copy("%VIDEDP - Overwriting existing file: ");
18040	  inoutequal:- copy("?VIDEDP - Input file = output file.");
18080	  tocontinue:- copy("To continue push RETURN.       ");
18120	  subcommands:-copy("UuLl+_  ");
18160	  switchcommands:-copy("AaFfJjNn0123456789 ");
18200	  triggs:-copy("AaFfJj ");
18240	  ! OBS blank no swcomm. ;
18280	  slask2:-blanks(140);
18320	
18360	  trmop(8R2006,sysout,1); ! .TTY FORM;
18400	  trmop(8R2010,sysout,1); ! .TTY NO CRLF;
18440	  trmop(8R2013,sysout,1); ! .TTY NO GAG;
18480	  trmop(8R2005,sysout,1); ! .TTY TAB;
18520	
18560	  outtext("[VIDEDP Version 1 is here.]"); outimage;
18600	
18640	COMMENT         Rescan is used to read command-string given
18680	                simultanious with the call of VIDEDP.           ;
18720	
18760	  IF rescan THEN BEGIN
18800	    inimage;
18840	    t:-sysin.image.strip;
18880	    IF t=/=NOTEXT THEN t:-copy(t);
18920	    scanto(t,'-');              ! t.pos=1 or after '-' in switchline ;
18960	    IF t.pos>1 THEN switc:-rest(t);
19000	    IF switc == NOTEXT THEN GOTO prompter;
19040	  END scanning switchline
19080	  ELSE BEGIN
19120	    prompter: IF FALSE THEN
19160	    new_file:
19200	    BEGIN
19240	      outstring(sysout,newfile);
19280	      outchr(sysout,char(13),1);
19320	      outchr(sysout,char(10),1);
19360	      forceout(sysout);
19400	    END;
19440	    switc:-NOTEXT;
19480	    switc:-inline("*",sysin);   ! To read new file and commandline.;
19520	    IF switc==NOTEXT THEN GOTO out;
19560	  END;
19600	  index:=scan(switc,arrayindex,arg,key,1);
19640	  WHILE index NE 0 DO BEGIN
19680	    error(2);
19720	    index:=scan(inline("*",sysin),arrayindex,arg,key,1);
19760	  END;
19800	  IF arg[arrayindex]==NOTEXT THEN BEGIN
19840	    arg[arrayindex]:-arg[1];    ! If no outfile is given the infile;
19880	    arg[1]:-copy("TTY:");       ! will be find in arg[1].       ;
19920	  END
19960	  ELSE BEGIN
20000	    outstring(sysout,started);
20040	    outchr(sysout,char(13),1); outchr(sysout,char(10),1);
20080	    forceout(sysout);
20120	  END;
20160	  IF arg[1] = arg[arrayindex] THEN
20200	  BEGIN outstring(sysout,inoutequal);
20240	    outchr(sysout,char(13),1); outchr(sysout,char(10),1);
20280	    GOTO new_file;
20320	  END;
20360	  in_file:-findinfile(arg[arrayindex]);
20400	  IF in_file==NONE THEN error(3);
20440	  in_file.open(blanks(140));
20480	  IF arg[1]="TTY:" THEN out_file:-sysout
20520	  ELSE BEGIN
20560	    IF findinfile(arg[1]) =/= NONE THEN
20600	    BEGIN outstring(sysout,overwriting); outstring(sysout,arg[1]);
20640	      outchr(sysout,char(13),1); outchr(sysout,char(10),1);
20680	      outstring(sysout,tocontinue);
20720	      forceout(sysout); sysin.inimage;
20760	    END;
20800	    out_file:-findoutfile(arg[1]);
20840	    IF out_file==NONE THEN error(4);
20880	    out_file.open(blanks(140));
20920	  END;
20960	  IF arg[3]=/=NOTEXT THEN BEGIN
21000	    justify:=TRUE;
21040	    j:=TRUE;
21080	  END ELSE justify:=FALSE;
21120	  IF arg[4]=/=NOTEXT THEN other:=TRUE ELSE other:=FALSE;
21160	  IF arg[5]=/=NOTEXT THEN automatic:=TRUE ELSE automatic:=FALSE;
21200	  cog:= IF arg[7]=/=NOTEXT THEN arg[7].getint ELSE 2;
21240	  leftmarg:= IF arg[8]=/=NOTEXT THEN arg[8].getint ELSE 5;
21280	  rightmarg:= IF arg[9]=/=NOTEXT THEN arg[9].getint ELSE 72;
21320	  lineque:- NEW head;
21360	  queoutline:- NEW line;
21400	  FOR i:=1 STEP 1 UNTIL 140 DO blank[i]:=TRUE;
21440	  ready:=TRUE;
21480	  oldl:=TRUE;
21520	  firstline:=TRUE;
21560	  line2:-NOTEXT;
21600	
21640	  new_line:
21680	  IF in_file.endfile THEN BEGIN ! Checks if end of infile.      ;
21720	    in_file.close;
21760	    outchr(out_file,char(12),1);
21800	    IF out_file=/=sysout THEN out_file.close;
21840	    GOTO new_file;
21880	  END;
21920	  line1:- NEW line;
21960	  in_file.image:-line1.contents;
22000	  in_file.inimage;      ! Reads new line from infile.           ;
22040	  IF in_file.endfile THEN BEGIN
22080	    in_file.image:-NOTEXT;      ! To get rid of "/*".           ;
22120	    j:=FALSE;
22160	  END;
22200	  IF firstline THEN BEGIN
22240	    page:=1;
22280	    sequense:=numbered; ! Checks if infile is numbered.         ;
22320	    IF NOT fetchar(line1.contents,1) EQ char(12) THEN
22360	    outchr(out_file,char(12),1);
22400	    firstline:=FALSE;
22440	  END;
22480	  IF sequense THEN line1.contents:-line1.contents.sub(7,133);
22520	  afterque:
22560	  IF resetj THEN BEGIN  ! To reset j after blankline.           ;
22600	    j:=TRUE;
22640	    resetj:=FALSE;
22680	  END;
22720	  dot:=FALSE;
22760	  IF line1.contents.sub(1,1) EQ "." THEN dot:=TRUE;
22800	  IF line1.contents.strip==NOTEXT
22840	  OR fetchar(line1.contents,1) EQ char(12)
22880	
22920	  COMMENT       If a line only contains blanks or if the first
22960	                character in a line is a formfeed then this is
23000	                considered as end of the previous textpart.     ;
23040	
23080	  THEN BEGIN
23120	    IF  fetchar(line1.contents,1) EQ char(12) THEN page:=page+1;
23160	    IF justify OR automatic THEN resetj:=TRUE;
23200	    j:=FALSE;
23240	    dot:=FALSE;
23280	  END;
23320	  IF dot THEN BEGIN
23360	    command:=fetchar(line1.contents,2);
23400	    IF command EQ '%' THEN BEGIN
23440	      dot:=FALSE;
23480	    END;
23520	
23560	COMMENT         Cheks if the commands are supposed to be
23600	                processed now or not until they reach the
23640	                outputprocedure.                                ;
23680	
23720	    IF command EQ '&' THEN BEGIN
23760	      slask2:=line1.contents;
23800	      slask3:=char(0);
23840	      slask3:=findtrigger(slask2,triggs);
23880	      IF NOT slask3 EQ char(0) THEN j:=FALSE;
23920	      dot:=FALSE;
23960	    END;
24000	    slask2:=scanto(switchcommands,command);
24040	    IF switchcommands.pos<8 THEN j:=FALSE;
24080	    IF switchcommands.pos<20 THEN dot:=FALSE;
24120	    switchcommands.setpos(1);
24160	  END;
24200	  no_command:
24240	  IF ready THEN
24280	
24320	COMMENT         This part of the program is only executed if
24360	                lineque is empty. This to get a faster handeling
24400	                of textparts not containing any indices or
24440	                underlinings.                                   ;
24480	
24520	  BEGIN
24560	    IF NOT dot THEN BEGIN
24600	      IF line2 NE NOTEXT THEN BEGIN
24640	        check(line2);
24680	        IF cog-l>2 THEN output(cog-l,line2) ELSE output(2,line2);
24720	        l:=0;
24760	        FOR i:=1 STEP 1 UNTIL x DO blank[i]:=TRUE;
24800	        x:=0;
24840	      END;
24880	      line2:-line1.contents;
24920	      GOTO new_line;
24960	    END ELSE IF line2 NE NOTEXT THEN BEGIN
25000	      queoutline.contents:-line2;  !TO GET LINE2 INTO QUE;
25040	      IF cog-l>2 THEN  queoutline.kog:=cog-l ELSE queoutline.kog:=2;
25080	      l:=0;
25120	      queoutline.into(lineque);
25160	      check(line2);
25200	      line2:-NOTEXT;
25240	      r:=1;
25280	    END
25320	  END;
25360	
25400	  COMMENT       This part of the program reads the commands
25440	                acoording to indices and underlinings and
25480	                calculates the correct number of halfstep
25520	                linefeeds to be performed before the output of
25560	                the current line and stores theresult in "kog". ;
25600	
25640	  IF dot THEN BEGIN
25680	    IF command EQ 'U' OR command EQ 'u' THEN BEGIN
25720	      IF NOT oldl OR b OR r>0 THEN BEGIN
25760	        ready:=TRUE;
25800	        GOTO queoutput;
25840	      END;
25880	      IF l=0 AND u=1 AND cog=4 THEN lineque.first QUA line .kog:=2;
25920	      IF u=0 THEN BEGIN
25960	        IF l=0 AND cog=4 THEN line1.kog:=3 ELSE line1.kog:=2;
26000	      END
26040	      ELSE line1.kog:=1;
26080	      u:=u+1;
26120	    END U;
26160	    IF command EQ 'L' OR command EQ 'l' THEN BEGIN
26200	      IF u>0 AND r=0 AND NOT b THEN error(5);
26240	      line1.kog:=1;
26280	      IF oldl THEN l:=0;
26320	      oldl:=FALSE;
26360	      l:=l+1;
26400	    END L;
26440	    IF command EQ '+' OR command EQ '_' THEN BEGIN
26480	      line1.kog:=0;
26520	    END + _;
26560	    IF command=' ' THEN BEGIN
26600	      IF NOT oldl OR r>0 THEN BEGIN
26640	        ready:=TRUE;
26680	        GOTO queoutput;
26720	      END;
26760	      IF b THEN line1.kog:=2 ELSE
26800	      IF u>0 THEN line1.kog:=1
26840	      ELSE IF cog-l>2 THEN line1.kog:=cog-l
26880	      ELSE line1.kog:=2;
26920	      b:=TRUE;
26960	    END;
27000	    slask2:=scanto(subcommands,command);
27040	    IF subcommands.pos>8 THEN    error(1);
27080	    subcommands.setpos(1);
27120	  END ELSE  BEGIN
27160	    IF NOT oldl OR b OR r>0 THEN BEGIN
27200	      ready:=TRUE;
27240	      GOTO queoutput;
27280	    END;
27320	    r:=r+1;
27360	    IF u>0 THEN line1.kog:=1
27400	    ELSE IF cog-l>2 THEN line1.kog:=cog-l
27440	    ELSE line1.kog:=2;
27480	  END;
27520	  ready:=FALSE;
27560	  line1.into(lineque);
27600	  check(line1.contents);
27640	  GOTO new_line;
27680	
27720	  queoutput:
27760	  WHILE NOT lineque.empty DO BEGIN
27800	    queoutline:-lineque.first;
27840	    lineque.first.out;
27880	    output(queoutline.kog,queoutline.contents);
27920	    quelines:=TRUE;
27960	  END;
28000	  FOR i:=1 STEP 1 UNTIL x DO blank[i]:=TRUE;
28040	  x:=0;
28080	  IF oldl THEN l:=0;
28120	  oldl:=TRUE;
28160	  u:=0;
28200	  b:=FALSE;
28240	  r:=0;
28280	  quelines:=FALSE;
28320	  GOTO afterque;
28360	
28400	  out:
28440	  outstring(sysout,end_videdp);
28480	  outchr(sysout,char(13),1);
28520	  outchr(sysout,char(10),1);
28560	  forceout(sysout);
28600	  exit(0);
28640	END;
28680	END;