home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / ME494-6.ZIP / DOCUMENT.SRC < prev    next >
Encoding:
Text File  |  1990-05-29  |  73.9 KB  |  2,416 lines

  1. $MACRO_FILE DOCUMENT;
  2. {******************************************************************************
  3.                                                      MULTI-EDIT MACRO FILE DOCUMENT
  4. FPRINT - The print formatter
  5. FCMD - Top level menu for inserting print formatter
  6. F_CODE_SUBMENU - Sub level menu for inserting print formatter codes
  7. INSERT_F_CODES - Inserts codes for the print formatter
  8.  
  9.                              (C) Copyright 1989 by American Cybernetics, Inc.
  10. ******************************************************************************}
  11.  
  12. $MACRO FPRINT TRANS;
  13. {******************************************************************************
  14.                                                                 MULTI-EDIT MACRO
  15.  
  16. Name: FPRINT
  17.  
  18. Description: This macro is a pretty printer utility which decodes special
  19.                          formatting chars to perform word processing formatting.
  20.  
  21. Current Formatting Commands:
  22.  
  23. Command    Default   Function
  24.  
  25. .pb n      n=+1      Page break(start page number n)
  26. The form feed character(ASCII 12) will also perform a page break.  The
  27. difference is there is no page number parameter.  Instead, there is an optional
  28. parameter that will force the next printed page to be even or odd.  If it is a
  29. 1 then it will be odd.  If 2, it will be even.  If omitted or anything else, it
  30. will paginate normally.  A closely related command is the ".bp".
  31.  
  32. .ff n      n=0       Use form feed characters at the end of each page. 0 = off
  33.                                          anything else = on.
  34. .bp n      n=0       Put headers an footers on blank pages due to forced even/
  35.                                          odd parameter after form feed page break.  0 means no, 1
  36.                                          means yes.
  37. .ce                  Center this line
  38. .df n str  Empty     Define footer. if n = 2 then footer will be footer 2
  39. .dh n str  Empty     Define header. if n = 2 then header will be header 2
  40. .sf                  Supress footer this page
  41. .sh                  Supress header this page
  42. .ls n      n=1       Line spacing is n
  43. .pl n      n=66      Set page length to n
  44. .rm n      n=80      Set right margin to n
  45. .lm n      n=1       Set left margin to n
  46. .ig                  Ignore, do not decode this line.
  47. .tm n      n=5       Set top margin to n
  48. .bm n      n=60      Set bottom margin to n
  49. .hm n      n=2       Set header margin to n
  50. .fm n      n=64      Set footer margin to n
  51. .np                  Don't print this line
  52.  
  53. User definable formatting commands:
  54. These are "macro" type formatting commands which the user can define.  Since
  55. they are processed in a "search and replace" type manner, they can be very
  56. versitile.  In defining, everything to the right of the command is considered
  57. to be part of the definition.  Whenever a mactching execute command is
  58. encountered, the command is replaced by the definition string.  Anything(normal
  59. text, other commands, etc.)  will be processed as though it were imbedded at
  60. the point of the execution command.  The value of n can be from 1 to 10.
  61. One caution:  If the insertion of the definition string results in a string
  62. length which exeeds 255, the definition string will be truncated until it fits,
  63. yielding unpredictable results.
  64.  
  65. .du n      n=1       Define user formatting command n
  66. .ud n      n=1       Execute user formmating command n
  67.  
  68. Printer specific formatting commands:
  69. These commands are used in conjuction with the global variable "Printer_Type".
  70. These codes are set up via the Modify Printer Codes option in either the Print
  71. macro or the Install macro.  Typical examples would be:
  72. .ub       Underline begin
  73. .ue                Underline end
  74.  
  75. These correspond to printer specific control codes set up by the user.  Any code
  76. in the text which matches a code set up for the current printer type will be
  77. replaced by that code.  Since these are completely user definable, it is the
  78. responsibility of the user to put the correct codes as defined in his printer
  79. type, and to insure there are no conflicts between user defined printer codes
  80. and fprint's formatting codes.  As it stands right now, fprint's codes will
  81. take precedence.
  82.  
  83. Current Formatting variables:
  84.  
  85. Code      Name
  86.  
  87. .fn       File name
  88. .ti       Time
  89. .da       Date
  90. .pa       Page number
  91.  
  92. Table of contents generator:
  93. To create a table of contents, the user must define a table of contents, then
  94. add table entry codes.
  95.  
  96. .tc       Define table of contents. At least 2 parameters are expected, and up
  97.                     to 12 will be recognized.  The first parameter will determine the
  98.                     right margin for all levels.  The second will determine whether or
  99.                     not to pad the void between each table entry and the corresponding
  100.                     page number with spaces or with periods(.).  The third will determine
  101.                     the amount of indenting for the first level.  The fourth determines
  102.                     the format of the first level.  The 3rd and 4th are repeated for each
  103.                     of the 5 possible levels, and are read by the program as pairs.
  104.  
  105. 0 = plain               EXAMPLE:  COMPILING A MACRO                        10
  106. 1 = numeric             EXAMPLE:  1. COMPILING A MACRO                     10
  107. 2 = alpha               EXAMPLE:  A. COMPILING A MACRO                     10
  108. 3 = roman numeral       EXAMPLE:  I. COMPILING A MACRO                     10
  109.  
  110. .te       One parameter is expected, which is the table level of the current
  111.                     Table entry. Everything on this line beginning with the first word
  112.                     after the parameter and up to the delimiter "(" or more than one
  113.                     space will be considered part of the table entry.
  114.  
  115.                                                             INDEX GENERATOR
  116. We have started an index generator.  Although too primitive to mention in the
  117. manual, it does have the ability to create an unformatted index.  The index
  118. generator is activated automatically by the first occurance of an index
  119. definition:
  120.  
  121. .X[heading^sub heading]
  122.  
  123. Whatever is inside the [] will appear in the index.  The entire definition will
  124. be stripped from the body of the document.  Subheadings are optional, but there
  125. must be a main heading before the caret^.  The format of the generated index
  126. is:
  127.  
  128. heading (page number)
  129.                 subheading1 (page number)
  130.                 subheading2 (page number)
  131.  
  132. The index is sorted in alphabetically by heading and by subheading.
  133.  
  134.                              (C) Copyright 1989 by American Cybernetics, Inc.
  135. ******************************************************************************}
  136.  
  137.     Def_Str(Line_In[2048],Line_Out,Command[2],Commands[80],Header1,Header2,Footer1,
  138.                     Footer2,Cur_Time[7],Cur_Date[8],Cur_File_Name[40],Blank_Line,Temp_String,
  139.                     Temp_Line_Out,Table_Line,Table_Page_Str[4],Temp_Param[10],
  140.                     Printer_Type[20],Attribute_Commands[40],Table_Delimits[40],
  141.                     Index_Main[80],Index_Sub[80],Percentage[4]);
  142.  
  143.     Def_Char(Code_Delimiter);
  144.  
  145.     Def_Int(End_Of_File,Cur_Page_Num,Text_Length,Val_Error,Param_Space,
  146.                     Page_Length,Cur_Line_Num,Top_Margin,Bottom_Margin,Left_Margin,
  147.                     Rght_Margin,Header_Margin,Footer_Margin,Comment,Supress_Header,
  148.                     Supress_Footer,Page_Break,Line_Spacing,New_Page_Num,Param_Pos,
  149.                     Delimiter_Pos,Temp_Integer,Text_Window,Print_Window,Move_Count,
  150.                     Making_Margin,Print_HF,Table_Window,Table_Style,Table_Indent,
  151.                     Table_Level,Table_Count,Table_Margin,Table_Count1,Table_Indent1,
  152.                     Table_Style1,Table_Count2,Table_Indent2,Table_Style2,Table_Count3,
  153.                     Table_Indent3,Table_Style3,Table_Count4,Table_Indent4,Table_Style4,
  154.                     Table_Count5,Table_Indent5,Table_Style5,Table_Defined,Periods,
  155.                     Table_Line_Num,Table_Page_Num,Abort,Todds_Jx,Todds_Jx2,Todds_Jx3,
  156.                     Todds_Jx4,HF_Toggle,For_Table,Parameter,Default,Temp_Flag,
  157.                     Leave_Blank,Blank_Page,Jx,Jy,Temp_Undo,Form_Feed,T_Reg_Exp_Stat,
  158.                     T_Insert_Mode,Index_Window,Footer_Set,Bottom_Set,Header_Copied,
  159.                     Footer_Copied,Supress_Table_Header,Supress_Table_Footer,F_Mode);
  160.  
  161.     Temp_Undo := Undo_Stat;
  162.     Undo_Stat := False;
  163.     T_Reg_Exp_Stat := Reg_Exp_Stat;
  164.     Reg_Exp_Stat := True;
  165.     T_Insert_Mode := Insert_Mode;
  166.     Insert_Mode := True;
  167.     Refresh := False;
  168.     Messages := False;
  169.     Abort := False;
  170.     F_Mode := Parse_Int('/M=',MParm_Str);
  171.     Code_Delimiter := Global_Str('Format_Code_Delimit');
  172.     IF (Code_Delimiter = '|0') THEN
  173.         Code_Delimiter := '.';
  174.     END;
  175.     Table_Delimits := '!@#^&()[]`"~\|<>{}*';
  176.     Jx := XPos(Code_Delimiter,Table_Delimits,1);
  177.     IF (Jx) THEN
  178.         Table_Delimits := Str_Del(Table_Delimits,Jx,1);
  179.     END;
  180.     Working;
  181.  
  182.  
  183.     Blank_Line := '                                                                                ';
  184.     Printer_Type := Parse_Str('PT=',Global_Str('PRINTER_TYPE'));
  185.     Put_Box(2,4,61,10,0,M_B_Color,'PRINT FORMATTER',True);
  186.     Set_Global_Str('@PFEV#1','/T=Cancel/KC=<ESC>/K1=27/K2=1/R=1/W=11/X=25/Y=9');
  187.     RM('CheckEvents /M=2/G=@PFEV#/#=1');
  188.     If (Printer_Type = '') Then
  189.         Write('Warning!  Printer type is unspecified.',4,5,0,M_B_Color);
  190.     Else
  191.         Write('Printer type: '  + Printer_Type,4,5,0,M_B_Color);
  192.     End;
  193.     Write('Format code delimiter: '  + Code_Delimiter,4,6,0,M_B_Color);
  194.     Write('Formatting: '  + Truncate_Path(File_Name) + ' for printing.  ',4,7,0,M_B_Color);
  195.     Write('░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░   0% Complete.',4,8,0,M_B_Color);
  196.  
  197.     EOF;
  198. {Store last line of the file into a variable}
  199.     End_Of_File := C_LINE;
  200.     TOF;
  201. {Initialize Variables to defaults}
  202.     Header1 := '';
  203.     Header2 := '';
  204.     Footer1 := '';
  205.     Footer2 := '';
  206.     HF_Toggle := True;
  207.     Cur_Page_Num := 1;
  208.     Cur_Line_Num := 1;
  209.     Page_Length := 66;
  210.     Left_Margin := 0;
  211.     Rght_Margin := 80;
  212.     Top_Margin := 5;
  213.     Bottom_Margin := 60;
  214.     Header_Margin := 2;
  215.     Footer_Margin := 64;
  216.     Footer_Set := False;
  217.     Bottom_Set := False;
  218.     Line_Spacing := 1;
  219.     Supress_Header := False;
  220.     Supress_Footer := False;
  221.     Page_Break := False;
  222.     Cur_File_Name := Caps(File_Name);
  223.     Cur_Date := Date;
  224.     Cur_Time := Copy(Time,1,5) + Copy(Time,9,2);
  225.     Making_Margin := False;
  226. {Defaults for table of contents}
  227.     Table_Defined := False;
  228.     Table_Margin := 75;
  229.     Periods := False;
  230.     Table_Count1 := 0;
  231.     Table_Count2 := 0;
  232.     Table_Count3 := 0;
  233.     Table_Count4 := 0;
  234.     Table_Count5 := 0;
  235.     Table_Indent1 := 0;
  236.     Table_Indent2 := 5;
  237.     Table_Indent3 := 10;
  238.     Table_Indent4 := 15;
  239.     Table_Indent5 := 20;
  240.     Table_Style1 := 0;
  241.     Table_Style2 := 0;
  242.     Table_Style3 := 0;
  243.     Table_Style4 := 0;
  244.     Table_Style5 := 0;
  245.     For_Table := False;
  246.     Leave_Blank := 0;
  247.     Blank_Page := 0;
  248.     Form_Feed := 0;
  249.     Print_HF := False;
  250.     Supress_Table_Header := False;
  251.     Supress_Table_Footer := False;
  252.  
  253. {This is a global you would initialize in STARTUP if you wanted different
  254. defaults}
  255.     IF (Global_Str('@FPRINT_DEFAULT@') <> '') THEN
  256.         Line_In := Global_Str('@FPRINT_DEFAULT@');
  257.         IF (XPos('/MODE=',Line_In,1)) THEN
  258.             F_MODE := Parse_Int('/MODE=',Line_In);
  259.         END;
  260.         IF (XPos('/PL=',Line_In,1)) THEN
  261.             Page_Length := Parse_Int('/PL=',Line_In);
  262.         END;
  263.         IF (XPos('/LM=',Line_In,1)) THEN
  264.             Left_Margin := Parse_Int('/LM=',Line_In);
  265.         END;
  266.         IF (XPos('/RM=',Line_In,1)) THEN
  267.             Rght_Margin := Parse_Int('/RM=',Line_In);
  268.         END;
  269.         IF (XPos('/TM=',Line_In,1)) THEN
  270.             Top_Margin := Parse_Int('/TM=',Line_In);
  271.         END;
  272.         IF (XPos('/BM=',Line_In,1)) THEN
  273.             Bottom_Margin := Parse_Int('/BM=',Line_In);
  274.         END;
  275.         IF (XPos('/HM=',Line_In,1)) THEN
  276.             Header_Margin := Parse_Int('/HM=',Line_In);
  277.         END;
  278.         IF (XPos('/FM=',Line_In,1)) THEN
  279.             Footer_Margin := Parse_Int('/FM=',Line_In);
  280.         END;
  281.         IF (XPos('/LS=',Line_In,1)) THEN
  282.             Line_Spacing := Parse_Int('/LS=',Line_In);
  283.         END;
  284.         IF (XPos('/FF=',Line_In,1)) THEN
  285.             Form_Feed := Parse_Int('/FF=',Line_In);
  286.         END;
  287.         IF (XPos('/DH1=',Line_In,1)) THEN
  288.             Header1 := Parse_Str('/DH1=',Line_In);
  289.             Header2 := Header1;
  290.         END;
  291.         IF (XPos('/DF1=',Line_In,1)) THEN
  292.             Footer1 := Parse_Str('/DF1=',Line_In);
  293.             Footer2 := Footer1;
  294.         END;
  295.     END;
  296.  
  297. {The ascii 127 char delimiting the commands is there to prevent false
  298. interpretation of commands}
  299.     IF (F_MODE) THEN
  300.         Commands := '';
  301.     ELSE
  302.         Commands := 'PBDFDHSHSFLSPLRMLMNPTMBMHMFMTCTEIGBPDUUDFFX[';
  303.     END;
  304.     Text_Window := Window_Id;
  305.     Temp_String := Caps(Truncate_Extension(File_Name));
  306.     Line_In := Format_Line;
  307.  
  308. {Create a window for the printable file if one does not already exist}
  309.     Jx := 0;
  310.  
  311. SEEK_PRT_WINDOW:
  312.     ++Jx;
  313.     Switch_Window(Jx);
  314.     IF ((File_Name <> (Temp_String + '.PRT')) and
  315.             (Jx < Window_Count)) THEN
  316.         Goto SEEK_PRT_WINDOW;
  317.     END;
  318.  
  319.     IF ((File_Name = (Temp_String + '.PRT')) and
  320.             (Window_Id <> Text_Window)) THEN
  321.         Erase_Window;
  322.     ELSE
  323.         Create_Window;
  324.     END;
  325.  
  326.     Format_Line := Line_In;
  327.     Print_Window := Window_Id;
  328.     Line_Terminator := '|13';
  329.     File_Name := Temp_String + '.PRT';
  330.     Create_Window;
  331.     Line_Terminator := '|13';
  332.     Index_Window := Window_Id;
  333.     File_Name := Temp_String + '.NDX';
  334. {Get printer specific data}
  335. {Add a trailing "" character to help in parsing later}
  336. {Create a string of all printer commands for this printer to use when stripping
  337. them out of a line}
  338.     Attribute_Commands := '';
  339.     IF (F_Mode = 0) THEN
  340.         Jx := 1;
  341.         WHILE (Jx < 19) DO
  342.             Attribute_Commands := Attribute_Commands + Parse_Str('F' + Str(Jx) + '=',
  343.                 Global_Str('PRINTER_TYPE'));
  344.             ++Jx;
  345.         END;
  346.         Attribute_Commands := Caps(Attribute_Commands);
  347.     END;
  348.  
  349. { special development code for testing execution time
  350. Def_Int(Start_Minutes,Start_Seconds,End_Minutes,End_Seconds);
  351. If ((Val(Start_Minutes,Copy(Time,4,2))) and (Val(Start_Seconds,Copy(Time,7,2)))) Then
  352. End;
  353. }
  354.     Switch_Win_Id(Text_Window);
  355.  
  356. {Set up variables for reporting percentage done}
  357.     Todds_Jx3 := End_Of_File;
  358.     If Todds_Jx3 < 20 then
  359.         Todds_Jx3 := 20;
  360.     END;
  361.     Todds_Jx3 := Todds_Jx3 / 20;
  362.  
  363.     Todds_Jx4 := 0;
  364.  
  365. {Main program loop}
  366.  
  367.     While (C_Line <= End_Of_File) Do
  368. {Report percentage done}
  369.         ++Todds_Jx4;
  370.         If Todds_Jx4 > 4 THEN
  371.             Todds_Jx := (C_line * 5) / Todds_Jx3;
  372.             If (Todds_Jx > 99) Then Todds_Jx := 99; End;
  373.             Todds_Jx2 := (Todds_Jx * 2) / 5;
  374.             Percentage := Str(Todds_jx);
  375.  
  376.             Write(Copy('▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓',1,Todds_Jx2) +
  377.                         Copy('░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░',1,40 - Todds_Jx2) + ' ' +
  378.                         Copy('    ',1,3 - Svl(Percentage)) + Percentage + '% Complete.',4,8,0,M_B_Color);
  379.             Todds_jx4 := 0;
  380.         end;
  381.  
  382. {Check for the user pressing <ESC>}
  383.         If (Check_Key) Then
  384.             If (Key1 = 27) Then
  385.         MOU_ESC:
  386.                 Abort := True;
  387.                 Kill_Box;
  388.                 Goto END_OF_MAC;
  389.             ELSif (key1 = 0) AND (key2 = 250) THEN
  390.                 RM('CheckEvents /G=@PFEV#/M=1/#=1');
  391.                 IF (Return_Int) THEN
  392.                     Goto MOU_ESC;
  393.                 END;
  394.             End;
  395.         End;
  396.  
  397.         Line_Out := '';
  398.         Comment := False;
  399.         Line_In := Get_Line;
  400. {Strip out HARD_CR if present}
  401.         IF (Hard_Cr <> '|0') THEN
  402. STRIP_HARD_CR:
  403.             Jx := XPos(Hard_Cr,Line_In,1);
  404.             IF (Jx) THEN
  405.                 Line_In := Str_Del(Line_In,Jx,1);
  406.                 Goto STRIP_HARD_CR;
  407.             END;
  408.         END;
  409.  
  410. {Page break char}
  411.         If (XPos('|12',Line_In,1)) Then
  412. {This is the part that can force a new page to start on an even or odd page number}
  413.             Default := 0;
  414.             Line_In := Str_Del(Line_In,1,1);
  415.             Call GET_PARAMETER;
  416.             New_Page_Num := Cur_Page_Num + 1;
  417.             Blank_Page := False;
  418.             IF (Parameter = 2) THEN
  419.                 IF (New_Page_Num MOD 2) THEN
  420.                     Blank_Page := True;
  421.                 END;
  422.             END;
  423.             IF (Parameter = 1) THEN
  424.                 IF ((New_Page_Num MOD 2) = 0) THEN
  425.                     Blank_Page := True;
  426.                 END;
  427.             END;
  428.             Page_Break := True;
  429.             Goto SKIP_PRINTING;
  430.         End;
  431.  
  432. {If the format code delimiter('.' default) is not in the line of text, bypass
  433. all this stuff and use as is.}
  434.         If (XPos(Code_Delimiter,Line_In,1) = 0) Then
  435.             Line_Out := Line_In;
  436.  
  437.             Goto NO_COMMAND;
  438.         End;
  439.  
  440.         Temp_Integer := XPos(Code_Delimiter + 'IG',Caps(Line_In),1);
  441.         If (Temp_Integer) Then                                             {Ignore}
  442.             If (Temp_Integer =  XPos(Code_Delimiter,Line_In,1)) Then
  443. {If there is some text before this command, then output the line so far}
  444.                 If (Temp_Integer > 1) Then
  445.                     Temp_String := Copy(Line_In,1,Temp_Integer - 1);
  446.                     Line_Out := Line_Out + Temp_String;
  447.                 End;
  448.                 Line_In := Copy(Line_In,Temp_Integer + 3,SVL(Line_In) - Temp_Integer - 2);
  449.                 If (Line_Out <> '') Then
  450.                     Call Print_Line;
  451.                 End;
  452.  
  453. {We put the formatted lines into a second window instead of sending directly to
  454. the printer or altering the original file.  It would be possible to alter this
  455. macro to do either option.  Feel especially ambitious today?}
  456.  
  457.                 SWITCH_WIN_Id(Print_Window);
  458.                 Put_Line('|10' + Copy(Blank_Line,1,Left_Margin) + Line_In);
  459.                 DOWN;
  460.                 ++Cur_Line_Num;
  461.                 GOTO_COL(1);
  462.                 SWITCH_WIN_Id(Text_Window);
  463.                 Goto SKIP_PRINTING;
  464.             End;
  465.         End;
  466.  
  467.         While (SVL(Line_In) > 0) Do
  468.             Delimiter_Pos := XPos(Code_Delimiter,Line_In,1);
  469.             If (Delimiter_Pos = 0) Then
  470.                 Line_Out := Line_Out + Line_In;
  471.                 Line_In := '';
  472.                 Goto NO_COMMAND;
  473.             Else
  474. {When a format code delimiter is detected, see if it is a command.}
  475.                 Line_Out := Line_Out + Copy(Line_In,1,Delimiter_Pos - 1);
  476.                 Temp_String := Copy(Line_In,Delimiter_Pos + 1,2);
  477.                 Line_In := Str_Del(Line_In,1,Delimiter_Pos + 2);
  478.                 Command := Caps(Temp_String);
  479.                 If ((XPos('' + Command + '',Commands,1) = 0) or (Command = '')) Then
  480. {If the suspected command is invalid, then treat it as if it were text.}
  481.                     Line_Out := Line_Out + Code_Delimiter + Temp_String;
  482.                 Else
  483. {At this point we are certain that we have a valid command}
  484.  
  485.                     If (Command = 'DU') Then             {Define user formatting command}
  486. {The remainder of the line is assumed to be part of the command definition so
  487. output the line so far}
  488.                         If (Line_Out <> '') and Not(Comment) Then
  489.                             Call Print_Line;
  490.                         End;
  491.                         Default := 1;
  492.                         Call GET_PARAMETER;
  493.                         If ((Parameter > 0) and (Parameter < 11)) Then
  494.                             Set_Global_Str(Code_Delimiter + 'UD' + Str(Parameter),Line_In);
  495.                         End;
  496.                         Line_Out := '';
  497.                         Goto SKIP_PRINTING;
  498.                     End;
  499.  
  500.                     If (Command = 'UD') Then            {Execute user formatting command}
  501.                         Default := 1;
  502.                         Call GET_PARAMETER;
  503.                         If ((Parameter > 0) and (Parameter < 11)) Then
  504.                             Line_In := Copy(Global_Str(Code_Delimiter + 'UD' + Str(Parameter)),1,255 - SVL(Line_In)) + Line_In;
  505.                         End;
  506.                         Goto COMMAND_DECODED;
  507.                     End;
  508.  
  509.                     If Command = 'NP' Then                                      {Comment}
  510.                         Comment := TRUE;
  511. {If there is some text before the comment, then output the line so far}
  512.                         If (Line_Out <> '') Then
  513.                             Call Print_Line;
  514.                             Line_Out := '';
  515.                         End;
  516.                         Goto COMMAND_DECODED;
  517.                     End;
  518.                     If (Command = 'PB') Then                                 {Page break}
  519.                         Default := Cur_Page_Num + 1;
  520.                         Call GET_PARAMETER;
  521.                         New_Page_Num := Parameter;
  522.                         Page_Break := True;
  523.                         Goto COMMAND_DECODED;
  524.                     End;
  525.  
  526.                     If (Command = 'X[') Then                                                 {INDEX}
  527. {Parse out index definition, process it, then print out line}
  528.                         Call PROCESS_INDEX;
  529.                         Goto COMMAND_DECODED;
  530.                     End;
  531.  
  532.  
  533.                     If (Command = 'DF') Then                             {Define footer}
  534. {The remainder of the line is assumed to be part of the footer definition so
  535. output the line so far}
  536.                         If (Line_Out <> '') and Not(Comment) Then
  537.                             Call Print_Line;
  538.                         End;
  539.                         Default := 1;
  540.                         Call GET_PARAMETER;
  541.                         If (Parameter = 2) Then
  542.                             Footer_Copied := False;
  543.                             Footer2 := Line_In;
  544.                         Else
  545.                             Footer1 := Line_In;
  546.                             If ((Footer2 = '') or (Footer_Copied = True)) Then
  547.                                 Footer_Copied := True;
  548.                                 Footer2 := Line_In;
  549.                             End;
  550.                         End;
  551.                         Line_Out := '';
  552.                         Goto SKIP_PRINTING;
  553.                     End;
  554.                     If (Command = 'DH') Then                             {Define header}
  555. {The remainder of the line is assumed to be part of the header definition so
  556. output the line so far}
  557.                         If (Line_Out <> '') and Not(Comment) Then
  558.                             Call Print_Line;
  559.                         End;
  560.                         Default := 1;
  561.                         Call GET_PARAMETER;
  562.                         If (Parameter = 2) Then
  563.                             Header2 := Line_In;
  564.                             Header_Copied := False;
  565.                         Else
  566.                             Header1 := Line_In;
  567.                             If ((Header2 = '') or (Header_Copied = True)) Then
  568.                                 Header_Copied := True;
  569.                                 Header2 := Line_In;
  570.                             End;
  571.                         End;
  572.                         Line_Out := '';
  573.                         Goto SKIP_PRINTING;
  574.                     End;
  575.  
  576.                     If (Command = 'SF') Then                            {Supress footer}
  577.                         Supress_Footer := True;
  578.                         Goto COMMAND_DECODED;
  579.                     End;
  580.                     If (Command = 'SH') Then                            {Supress header}
  581.                         Supress_Header := True;
  582.                         Goto COMMAND_DECODED;
  583.                     End;
  584.                     If (Command = 'LS') Then                              {Line spacing}
  585. {See if we have a parameter}
  586.                         Default := 1;
  587.                         Call GET_PARAMETER;
  588.                         Line_Spacing := Parameter;
  589.                         Goto COMMAND_DECODED;
  590.                     End;
  591.                     If (Command = 'BP') Then {print Headers/Footers on blank pages}
  592.                         Default := 0;
  593.                         Call GET_PARAMETER;
  594.                         Leave_Blank := Parameter;
  595.                         Goto COMMAND_DECODED;
  596.                     End;
  597.                     If (Command = 'FF') Then {insert form feed characters at page break}
  598.                         Default := 0;
  599.                         Call GET_PARAMETER;
  600.                         Form_Feed := Parameter;
  601.                         Goto COMMAND_DECODED;
  602.                     End;
  603.  
  604. {This is the table of contents stuff}
  605.  
  606.                     If (Command = 'TE') Then                                {Table entry}
  607. {Ignore table entry if table is not defined}
  608.                         If (Table_Defined = False) Then
  609.                             Goto SKIP_ENTRY;
  610.                         End;
  611.  
  612.                         Default := 1;
  613.                         Call GET_PARAMETER;
  614.  
  615.                         Table_Level := Parameter;
  616.  
  617.                         Table_Line := Line_In;
  618.  
  619. {Delete leading spaces}
  620.                         While (Copy(Table_Line,1,1) = ' ') Do
  621.                             Table_Line := Str_Del(Table_Line,1,1);
  622.                         End;
  623. {This is a special case of striping out any index entry, although later on
  624. a routine is run to strip out all codes, the [ character of the index code
  625. is striped out beforehand, which will confuse the code stripping routine.}
  626. STRIP_IDX:
  627.                         Jx := XPos('.X[',Caps(Table_Line),1);
  628.                         IF (Jx) THEN
  629.                             Jy := XPos(']',Table_Line,Jx);
  630.                             IF (Jy = 0) THEN
  631.                                 Jy := Svl(Table_Line);
  632.                             END;
  633.                             Table_Line := Str_Del(Table_Line,Jx,Jy - Jx + 1);
  634.                             Goto STRIP_IDX;
  635.                         END;
  636.  
  637. {Truncate line according to the presense of certain delimiters}
  638. {The following are considered by M.E. to be word delimiters !@#$^&()[]''`"~\|,<>
  639. also the curly braces used to enclose this comment.}
  640. {We had to remove the $ char and add the * char for the macro manual}
  641.                         Temp_Integer := Svl(Table_Delimits);
  642.                         While (Temp_Integer > 0) Do
  643.                             If XPos(Copy(Table_Delimits,Temp_Integer,1),Table_Line,1) Then
  644.                                 Table_Line := Copy(Table_Line,1,XPos(Copy(Table_Delimits,
  645.                                                                              Temp_Integer,1),Table_Line,1) - 1);
  646.                             End;
  647.                             --Temp_Integer;
  648.                         End;
  649. {We want to truncate if there is more than one consecutive space char}
  650.                         If XPos('  ',Table_Line,1) Then
  651.                             Table_Line := Copy(Table_Line,1,XPos('  ',Table_Line,1) - 1);
  652.                         End;
  653.  
  654.                         IF ((Table_Level < 1) or (Table_Level > 5)) THEN
  655.                             Table_Level := 1;
  656.                         END;
  657.  
  658.                         If Table_Level = 1 Then
  659.                             Table_Count := Table_Count1;
  660.                             Table_Indent := Table_Indent1;
  661.                             Table_Style := Table_Style1;
  662. {We must reset all subseqent Table_Counts}
  663.                             Table_Count2 := 0;
  664.                             Table_Count3 := 0;
  665.                             Table_Count4 := 0;
  666.                             Table_Count5 := 0;
  667.                         End;
  668.                         If Table_Level = 2 Then
  669.                             Table_Count := Table_Count2;
  670.                             Table_Indent := Table_Indent2;
  671.                             Table_Style := Table_Style2;
  672.                             Table_Count3 := 0;
  673.                             Table_Count4 := 0;
  674.                             Table_Count5 := 0;
  675.                         End;
  676.                         If Table_Level = 3 Then
  677.                             Table_Count := Table_Count3;
  678.                             Table_Indent := Table_Indent3;
  679.                             Table_Style := Table_Style3;
  680.                             Table_Count4 := 0;
  681.                             Table_Count5 := 0;
  682.                         End;
  683.                         If Table_Level = 4 Then
  684.                             Table_Count := Table_Count4;
  685.                             Table_Indent := Table_Indent4;
  686.                             Table_Style := Table_Style4;
  687.                             Table_Count5 := 0;
  688.                         End;
  689.                         If Table_Level = 5 Then
  690.                             Table_Count := Table_Count5;
  691.                             Table_Indent := Table_Indent5;
  692.                             Table_Style := Table_Style5;
  693.                         End;
  694.  
  695.                         If (Table_Style = 1) Then
  696.                             Table_Line := Str(Table_Count + 1) + '. ' + Table_Line;
  697.                             Line_In := Str(Table_Count + 1) + '. ' + Line_In;
  698.                         End;
  699.  
  700.                         If (Table_Style = 2) Then
  701.                             Table_Line := Char(Table_Count + 65) + '. ' + Table_Line;
  702.                             Line_In := Char(Table_Count + 65) + '. ' + Line_In;
  703.                         End;
  704.  
  705.                         If (Table_Style = 3) Then
  706.                             Table_Line := Remove_Space(Copy(
  707.                                          'I.   II.  III. IV.  V.   VI.  VII. VIII.IX.  X.   XI.  ',
  708.                                                                     (Table_Count * 5) + 1,5)) + ' ' + Table_Line;
  709.                             Line_In := Remove_Space(Copy(
  710.                                          'I.   II.  III. IV.  V.   VI.  VII. VIII.IX.  X.   XI.  ',
  711.                                                                          (Table_Count * 5) + 1,5)) + ' ' + Line_In;
  712.                         End;
  713.  
  714.                         ++Table_Count;
  715.                         If Table_Level = 1 Then
  716.                             Table_Count1 := Table_Count;
  717.                         End;
  718.                         If Table_Level = 2 Then
  719.                             Table_Count2 := Table_Count;
  720.                         End;
  721.                         If Table_Level = 3 Then
  722.                             Table_Count3 := Table_Count;
  723.                         End;
  724.                         If Table_Level = 4 Then
  725.                             Table_Count4 := Table_Count;
  726.                         End;
  727.                         If Table_Level = 5 Then
  728.                             Table_Count5 := Table_Count;
  729.                         End;
  730.                         Switch_Win_Id(Table_Window);
  731.  
  732.  
  733.                         If (Table_Line_Num = Bottom_Margin) Then
  734.                             IF ((Footer_Margin > (Page_Length + 1)) or
  735.                                     (Supress_Table_Footer = True)) THEN
  736.                                 Goto NO_TABLE_FOOTER;
  737.                             END;
  738.  
  739.                             IF (XPos('|10',Get_Line,1) = 0) THEN
  740.                                 Goto_Col(1);
  741.                                 Text('|10');
  742.                             END;
  743.                             While ((Table_Line_Num < (Footer_Margin - 1)) and
  744.                                                                                         (Table_Line_Num < Page_Length))  Do
  745.                                 Down;
  746.                                 Put_Line('|10');
  747.                                 ++Table_Line_Num;
  748.                             End;
  749.                             If (Table_Line_Num <= Page_Length) Then
  750.                                 Temp_Line_Out := Line_Out;
  751.                                 If (Table_Page_Num = ((Table_Page_Num / 2) * 2)) Then
  752.                                     Line_Out := Footer2;
  753.                                 Else
  754.                                     Line_Out := Footer1;
  755.                                 End;
  756.  
  757.                                 Temp_String := Caps(Line_Out);
  758.  
  759.                                 If (XPos(Code_Delimiter + 'PA',Temp_String,1)) Then
  760.                                     Table_Page_Str := Remove_Space(Copy(
  761.                                                                 'i   ii  iii iv  v   vi  vii viiiix  x   xi  ',
  762.                                                                                         ((Table_Page_Num - 1) * 4) + 1,4));
  763.  
  764.                                     Line_Out := Copy(Line_Out,1,XPos(Code_Delimiter + 'PA',Temp_String,1) - 1)
  765.                                         + Table_Page_Str +
  766.                                         Copy(Line_Out,XPos(Code_Delimiter + 'PA',Temp_String,1) + 3,254);
  767.                             End;
  768.                                 For_Table := True;
  769.                                 Call PRINT_LINE;
  770.                                 Jx := XPos(Code_Delimiter + 'CE',Temp_String,1);
  771.                                 IF (Jx) THEN
  772.                                     Line_Out := Str_Del(Line_Out,Jx,3);
  773.                                     Call CENTER_LINE;
  774.                                 END;
  775.                                 Switch_Win_Id(Table_Window);
  776.  
  777.                                 Put_Line('|10' + Copy(Blank_Line,1,Left_Margin) + Line_Out);
  778.                                 Line_Out := Temp_Line_Out;
  779.                             End;
  780. NO_TABLE_FOOTER:
  781.                             IF (Form_Feed) THEN
  782.                                 Eol;
  783.                                 Text('|12|13');
  784.                             ELSE
  785.                                 While (Table_Line_Num <= Page_Length)  Do
  786.                                     Down;
  787.                                     Put_Line('|10');
  788.                                     ++Table_Line_Num;
  789.                                 End;
  790.                             END;
  791.                             ++Table_Page_Num;
  792.                             Table_Line_Num := 1;
  793.                         End;
  794.  
  795.                         If (Table_Line_Num = 1) Then
  796.                             While ((Table_Line_Num <= Header_Margin) and
  797.                                                                                         (Table_Line_Num < Page_Length))  Do
  798.                                 Down;
  799.                                 Put_Line('|10');
  800.                                 ++Table_Line_Num;
  801.                             End;
  802.                             Goto_Col(1);
  803.                             Temp_Line_Out := Line_Out;
  804.                             IF (Supress_Table_Header) THEN
  805.                                 Line_Out := '';
  806.                             ELSE
  807.                                 If (Table_Page_Num = ((Table_Page_Num / 2) * 2)) Then
  808.                                     Line_Out := Header2;
  809.                                 Else
  810.                                     Line_Out := Header1;
  811.                                 End;
  812.                                 Temp_String := Caps(Line_Out);
  813.                                 If (XPos(Code_Delimiter + 'PA',Temp_String,1)) Then
  814.                                     Table_Page_Str := Remove_Space(Copy(
  815.                                                                     'i   ii  iii iv  v   vi  vii viiiix  x   xi  ',
  816.                                                                                             ((Table_Page_Num - 1) * 4) + 1,4));
  817.                                     Line_Out := Copy(Line_Out,1,XPos(Code_Delimiter + 'PA',Temp_String,1) - 1)
  818.                                         + Table_Page_Str +
  819.                                         Copy(Line_Out,XPos(Code_Delimiter + 'PA',Temp_String,1) + 3,254);
  820.                                 End;
  821.                             END;
  822.                             For_Table := True;
  823.                             Call PRINT_LINE;
  824.                             Jx := XPos(Code_Delimiter + 'CE',Temp_String,1);
  825.                             IF (Jx) THEN
  826.                                 Line_Out := Str_Del(Line_Out,Jx,3);
  827.                                 Call CENTER_LINE;
  828.                             END;
  829.                             Eol;
  830.  
  831.                             Text(Copy(Blank_Line,1,Left_Margin) + Line_Out);
  832.  
  833.                             Line_Out := Temp_Line_Out;
  834.                             While ((Table_Line_Num <= Top_Margin) and
  835.                                                                                          (Table_Line_Num < Page_Length)) Do
  836.                                 ++Table_Line_Num;
  837.                                 Down;
  838.                                 Put_Line('|10');
  839.                             End;
  840.                             If (Table_Page_Num = 1) Then
  841.                                 Line_Out := 'Table of Contents';
  842.                                 Call CENTER_LINE;
  843.                                 Put_Line('|10' + Copy(Blank_Line,1,Left_Margin) + Line_Out);
  844.                                 Down;
  845.                                 Put_Line('|10');
  846.                                 Down;
  847.                                 Table_Line_Num := Table_Line_Num + 2;
  848.                                 Line_Out := Temp_Line_Out;
  849.                             End;
  850.                         End;
  851. {Strip out any remaining formatting codes}
  852.                         Temp_String := Table_Line;
  853.                         Call STRIP_CODES;
  854.                         Table_Line := Temp_String;
  855.                         Put_Line('|10' + Copy(Blank_Line,1,Left_Margin + Table_Indent) + Temp_String);
  856.                         Eol;
  857.                         If (Periods) Then
  858.                             Text(Copy('...................................................................................'
  859.                                                 ,1,(Table_Margin - Table_Indent) - SVL(Table_Line) -
  860.                                                                  Left_Margin - Length(Str(Cur_Page_Num)) - 2));
  861.                         End;
  862.                         Table_Line := Str(Cur_Page_Num);
  863.                         Goto_Col(Table_Margin - SVL(Table_Line) + 1);
  864.                         Text(Table_Line);
  865.                         ++Table_Line_Num;
  866.                         Down;
  867.                         Goto_Col(1);
  868.                         Switch_Win_Id(Text_Window);
  869.                         Goto COMMAND_DECODED;
  870.  
  871. SKIP_ENTRY:
  872.                     End;
  873.  
  874.                     If (Command = 'TC') Then                   {Define table of contents}
  875. {Ignore table definition if table is already defined}
  876.                         If (Table_Defined) Then
  877.                             Goto SKIP_DEFINITION;
  878.                         Else
  879.                             Table_Defined := True;
  880.                         End;
  881.  
  882.                         Table_Line_Num := 1;
  883.                         Table_Page_Num := 1;
  884.                         Temp_String := File_Name;
  885.  
  886. {Create a window for the Table of contents}
  887.                         Create_Window;
  888.                         Line_Terminator := '|13';
  889.                         Table_Window := Window_Id;
  890.                         File_Name := Truncate_Extension(Temp_String) + '.TOC';
  891.                         Switch_Win_Id(Text_Window);
  892.  
  893. {See if we have a parameter}
  894.                         Default := 75;
  895.                         Call GET_PARAMETER;
  896.                         Table_Margin := Parameter;
  897. {See if user wants to pad between table entry and page number with spaces or
  898. periods}
  899.                         Default := 0;
  900.                         Call GET_PARAMETER;
  901.                         Periods := Parameter;
  902.  
  903.                         Default := 0;
  904.                         Call GET_PARAMETER;
  905.                         Supress_Table_Header := Parameter > 0;
  906.                         Default := 0;
  907.                         Call GET_PARAMETER;
  908.                         Supress_Table_Footer := Parameter > 0;
  909.  
  910.                         Default := 0;
  911.                         Call GET_PARAMETER;
  912.                         Table_Indent1 := Parameter;
  913.                         Default := 0;
  914.                         Call GET_PARAMETER;
  915.                         Table_Style1 := Parameter;
  916.                         Default := 5;
  917.                         Call GET_PARAMETER;
  918.                         Table_Indent2 := Table_Indent1 + Parameter;
  919.                         Default := 0;
  920.                         Call GET_PARAMETER;
  921.                         Table_Style2 := Parameter;
  922.                         Default := 5;
  923.                         Call GET_PARAMETER;
  924.                         Table_Indent3 := Table_Indent2 + Parameter;
  925.                         Default := 0;
  926.                         Call GET_PARAMETER;
  927.                         Table_Style3 := Parameter;
  928.                         Default := 5;
  929.                         Call GET_PARAMETER;
  930.                         Table_Indent4 := Table_Indent3 + Parameter;
  931.                         Default := 0;
  932.                         Call GET_PARAMETER;
  933.                         Table_Style4 := Parameter;
  934.                         Default := 5;
  935.                         Call GET_PARAMETER;
  936.                         Table_Indent5 := Table_Indent4 + Parameter;
  937.                         Default := 0;
  938.                         Call GET_PARAMETER;
  939.                         Table_Style5 := Parameter;
  940.                         Goto COMMAND_DECODED;
  941. SKIP_DEFINITION:
  942.                     End;
  943.  
  944.  
  945.                     If (Command = 'TM') Then                                 {Top Margin}
  946. {See if we have a parameter}
  947.                         Default := 5;
  948.                         Call GET_PARAMETER;
  949.                         Top_Margin := Parameter;
  950.                         Call CHECK_MARGINS;
  951.                         Goto COMMAND_DECODED;
  952.                     End;
  953.  
  954.                     If (Command = 'BM') Then                              {Bottom Margin}
  955. {See if we have a parameter}
  956.                         Default := Page_Length - 6;
  957.                         Call GET_PARAMETER;
  958.                         Bottom_Margin := Parameter;
  959.                         Call CHECK_MARGINS;
  960.                         Bottom_Set := True;
  961.                         Goto COMMAND_DECODED;
  962.                     End;
  963.  
  964.                     If (Command = 'PL') Then                               {Page Length}
  965. {See if we have a parameter}
  966.                         Default := 66;
  967.                         Call GET_PARAMETER;
  968.                         Page_Length := Parameter;
  969.                         IF (Bottom_Set = False) THEN
  970.                             Bottom_Margin := Page_Length - 6;
  971.                         END;
  972.                         IF (Footer_Set = False) THEN
  973.                             Footer_Margin := Page_Length - 2;
  974.                         END;
  975.                         Call CHECK_MARGINS;
  976.                         Goto COMMAND_DECODED;
  977.                     End;
  978.                     If (Command = 'RM') Then                              {Right Margin}
  979. {See if we have a parameter}
  980.                         Default := 80;
  981.                         Call GET_PARAMETER;
  982.                         Rght_Margin := Parameter;
  983.                         Goto COMMAND_DECODED;
  984.                     End;
  985.                     If (Command = 'LM') Then                               {Left Margin}
  986. {See if we have a parameter}
  987.                         Print_margin := 0;
  988.                         Default := 1;
  989.                         Call GET_PARAMETER;
  990.                         Left_Margin := Parameter - 1;
  991.                         Goto COMMAND_DECODED;
  992.                     End;
  993.                     If (Command = 'HM') Then                              {Header Margin}
  994. {See if we have a parameter}
  995.                         Default := 2;
  996.                         Call GET_PARAMETER;
  997.                         Header_Margin := Parameter;
  998.                         Call CHECK_MARGINS;
  999.                         Goto COMMAND_DECODED;
  1000.                     End;
  1001.  
  1002.                     If (Command = 'FM') Then                              {Footer Margin}
  1003. {See if we have a parameter}
  1004.                         Default := Page_Length - 2;
  1005.                         Call GET_PARAMETER;
  1006.                         Footer_Margin := Parameter;
  1007.                         Call CHECK_MARGINS;
  1008.                         Footer_Set := True;
  1009.                         Goto COMMAND_DECODED;
  1010.                     End;
  1011.  
  1012. COMMAND_DECODED:
  1013.                 End;
  1014.             End;
  1015.         End;
  1016.  
  1017. NO_COMMAND:
  1018. {Process top and header margins, print header}
  1019.         If ((Cur_Line_Num = 1) and (Comment = false)) Then
  1020. {If we have an unprinted line in memory, we need to save it}
  1021.             Temp_Line_Out := Line_Out;
  1022.             Temp_Flag := Comment;
  1023. {Put in header(if header is null, just another blank line will be printed)}
  1024.             Comment := False;
  1025.             If Header_Margin < 0 then
  1026.                 Goto NO_HEADER;
  1027.             End;
  1028. {fill in header margin}
  1029.             Move_Count := Header_Margin;
  1030.             Call MOVE_DOWN;
  1031.             If (Supress_Header = False) Then
  1032. {If on an even numbered page then}
  1033.                 If (Cur_Page_Num = ((Cur_Page_Num / 2) * 2)) Then
  1034.                     Line_Out := Header2;
  1035.                 Else
  1036.                     Line_Out := Header1;
  1037.                 End;
  1038.             Else
  1039.                 Line_Out := '';
  1040.             End;
  1041.             Supress_Header := False;
  1042.             Print_HF := True;
  1043.             Call PRINT_LINE;
  1044. NO_HEADER:
  1045. {fill in top margin}
  1046.             Move_Count := (Top_Margin - Cur_Line_Num) + 1;
  1047.             Call MOVE_DOWN;
  1048.             Line_Out := Temp_Line_Out;
  1049.             Comment := Temp_Flag;
  1050.             If Line_Out = '' Then
  1051.                 Goto SKIP_PRINTING;
  1052.             End;
  1053.         End;
  1054. HERE:
  1055.         If (Comment) Then
  1056.             Goto SKIP_PRINTING;
  1057.         End;
  1058.  
  1059. PREPARE_TO_PRINT:
  1060.         Call PRINT_LINE;
  1061.         If Line_Spacing > 1 Then
  1062.             Move_Count := Line_Spacing - 1;
  1063.             Call MOVE_DOWN;
  1064.         End;
  1065.  
  1066. SKIP_PRINTING:
  1067.         If ((Cur_Line_Num >= Bottom_Margin) or ((Page_Break = True) and (Cur_Line_Num > 1)))Then
  1068. {fill in footer margin}
  1069. {
  1070.             If ((Footer_Margin > (Page_Length)) or (Supress_Footer = True) or
  1071.                                                                             ((Footer1 = '') and (Footer2 = ''))) Then
  1072.                 Goto NO_FOOTER;
  1073.             End;
  1074. }
  1075.  
  1076.             If ((Footer_Margin > (Page_Length + 1)) or (Supress_Footer = True) or
  1077.                                                                             ((Footer1 = '') and (Footer2 = ''))) Then
  1078.                 Goto NO_FOOTER;
  1079.             End;
  1080.  
  1081.             Making_Margin := True;
  1082.             Move_Count := (Footer_Margin - Cur_Line_Num) - 1;
  1083.             Call MOVE_DOWN;
  1084. {If on an even numbered page then}
  1085.                 If (Cur_Page_Num = ((Cur_Page_Num / 2) * 2)) Then
  1086.                     Line_Out := Footer2;
  1087.                 Else
  1088.                     Line_Out := Footer1;
  1089.                 End;
  1090.             Print_HF := True;
  1091. {Put in footer(if footer is null, just another blank line will be printed)}
  1092.             Call PRINT_LINE;
  1093. NO_FOOTER:
  1094.             Supress_Footer := False;
  1095. {fill in bottom margin}
  1096. {we go one line beyond the page length to get on line one of the next page}
  1097.             IF (Form_Feed) THEN
  1098.                 Print_HF := True;
  1099.                 IF (Switch_Win_Id(Print_Window)) THEN
  1100.                     Up;
  1101.                     Eol;
  1102.                     Text('|12|13');
  1103.                 END;
  1104.             ELSE
  1105.                 Move_Count := (Page_Length - Cur_Line_Num) + 1;
  1106.                 Call MOVE_DOWN;
  1107.             END;
  1108.  
  1109.             If (Page_Break) Then
  1110.                 Cur_Page_Num := New_Page_Num;
  1111.                 Page_Break := False;
  1112.             Else
  1113.                 ++Cur_Page_Num;
  1114.             End;
  1115.             Cur_Line_Num := 1;
  1116.             Making_Margin := False;
  1117.             HF_Toggle := Not(HF_Toggle);
  1118. {This is the part for the forced odd/even page numbers}
  1119.             If (Blank_Page) Then
  1120.                 HF_Toggle := Not(HF_Toggle);
  1121.                 If (Leave_Blank) Then
  1122.                     Page_Break := True;
  1123.                     Blank_Page := False;
  1124.                     Goto NO_COMMAND;
  1125.                 Else
  1126.                     ++Cur_Page_Num;
  1127.  
  1128.                     IF (Form_Feed) THEN
  1129.                         Print_HF := True;
  1130.                         IF (Switch_Win_Id(Print_Window)) THEN
  1131.                             Up;
  1132.                             Eol;
  1133.                             Text('|12|13');
  1134.                         END;
  1135.                     ELSE
  1136.                         Move_Count := Page_Length;
  1137.                         Call MOVE_DOWN;
  1138.                     END;
  1139.  
  1140.                     Blank_Page := False;
  1141.                     Cur_Line_Num := 1;
  1142.                 End;
  1143.             End;
  1144.         ELSE
  1145.             Page_Break := False;
  1146.         End;
  1147.         Switch_Win_Id(Text_Window);
  1148.         Down;
  1149.         Goto_Col(1);
  1150.     End;
  1151.  
  1152. {End of main program loop}
  1153.     IF (Line_Out = '|12') THEN
  1154.         Line_Out := '';
  1155.     END;
  1156.  
  1157.     If ((Cur_Line_Num = 1) and (Line_Out <> '')) Then
  1158. {If we have an unprinted line in memory, we need to save it}
  1159.         Temp_Line_Out := Line_Out;
  1160.         Temp_Flag := Comment;
  1161. {Put in header(if header is null, just another blank line will be printed)}
  1162.         Comment := False;
  1163.         If ((Header_Margin < 0) or (Header1 = '')) then
  1164.             Goto NO_LAST_HEADER;
  1165.         End;
  1166. {fill in header margin}
  1167.         Move_Count := Header_Margin;
  1168.         Call MOVE_DOWN;
  1169.         If (Supress_Header = False) Then
  1170. {If on an even numbered page then}
  1171.             If (Cur_Page_Num = ((Cur_Page_Num / 2) * 2)) Then
  1172.                 Line_Out := Header2;
  1173.             Else
  1174.                 Line_Out := Header1;
  1175.             End;
  1176.         Else
  1177.             Line_Out := '';
  1178.         End;
  1179.         Supress_Header := False;
  1180.         Print_HF := True;
  1181.         Call PRINT_LINE;
  1182. NO_LAST_HEADER:
  1183. {fill in top margin}
  1184.         Move_Count := (Top_Margin - Cur_Line_Num) + 1;
  1185.         Call MOVE_DOWN;
  1186.         Line_Out := Temp_Line_Out;
  1187.         Comment := Temp_Flag;
  1188.     End;
  1189.  
  1190.     If Cur_Line_Num > 1 Then
  1191. {
  1192.         If ((Footer_Margin > (Page_Length)) or (Footer1 = '')) Then
  1193.             Goto DONE;
  1194.         End;
  1195. }
  1196.  
  1197.         If ((Footer_Margin > (Page_Length + 1)) or (Footer1 = '')) Then
  1198.             Goto DONE;
  1199.         End;
  1200.  
  1201. {fill in bottom margin and footer for last page}
  1202.         Making_Margin := True;
  1203.         Move_Count := (Footer_Margin - Cur_Line_Num) - 1;
  1204.         Call MOVE_DOWN;
  1205.  
  1206.         If (Supress_Footer = False) Then
  1207. {If on an even numbered page then}
  1208.                 If (Cur_Page_Num = ((Cur_Page_Num / 2) * 2)) Then
  1209.                     Line_Out := Footer2;
  1210.                 Else
  1211.                     Line_Out := Footer1;
  1212.                 End;
  1213.             Else
  1214.                 Line_Out := '';
  1215.         End;
  1216.         Print_HF := True;
  1217.         Supress_Footer := False;
  1218. {Put in footer(if footer is null, just another blank line will be printed)}
  1219.         Call PRINT_LINE;
  1220.     End;
  1221.  
  1222. DONE:
  1223. {Get rid of blank lines at the end this is a kludge, but I don't have time
  1224. right now to fix it right}
  1225.     SWITCH_WIN_Id(Print_Window);
  1226. KILL_BLANKS:
  1227.     EOL;
  1228.     IF ((C_Col = 1) and (C_Line > 1)) THEN
  1229.         Back_Space;
  1230.         Goto KILL_BLANKS;
  1231.     END;
  1232.     Temp_Flag := (Get_Line = '|12');
  1233.     Cr;
  1234.     SWITCH_WIN_Id(Text_Window);
  1235.     IF ((Form_Feed) and (Temp_Flag = False)) THEN
  1236.         Print_HF := True;
  1237.         IF (Switch_Win_Id(Print_Window)) THEN
  1238.             Up;
  1239.             Eol;
  1240.             Text('|12|13');
  1241.         END;
  1242.     END;
  1243.  
  1244.     If (Table_Defined) Then
  1245.         Switch_Win_Id(Table_Window);
  1246.  
  1247.         IF (XPos('|10',Get_Line,1) = 0) THEN
  1248.             Goto_Col(1);
  1249.             Text('|10');
  1250.         END;
  1251.         While ((Table_Line_Num < (Footer_Margin - 1)) and
  1252.                                                                                         (Table_Line_Num < Page_Length))  Do
  1253.             Down;
  1254.             Put_Line('|10');
  1255.             ++Table_Line_Num;
  1256.         End;
  1257.         If (Table_Line_Num <= Page_Length) Then
  1258.             If ((Footer_Margin > (Page_Length + 1)) or
  1259.                     (Footer1 = '') or (Supress_Table_Footer = true)) Then
  1260. {
  1261.             IF (Footer_Margin >= Page_Length) THEN
  1262. }
  1263.                 Goto NO_LAST_TABLE_FOOTER;
  1264.             END;
  1265.             If (Table_Page_Num = ((Table_Page_Num / 2) * 2)) Then
  1266.                 Line_Out := Footer2;
  1267.             Else
  1268.                 Line_Out := Footer1;
  1269.             End;
  1270.  
  1271.             Temp_String := Caps(Line_Out);
  1272.  
  1273.             If (XPos(Code_Delimiter + 'PA',Temp_String,1)) Then
  1274.                 Table_Page_Str := Remove_Space(Copy(
  1275.                                                                 'i   ii  iii iv  v   vi  vii viiiix  x   xi  ',
  1276.                                                                                         ((Table_Page_Num - 1) * 4) + 1,4));
  1277.                 Line_Out := Copy(Line_Out,1,XPos(Code_Delimiter + 'PA',Temp_String,1) - 1)
  1278.                     + Table_Page_Str +
  1279.                     Copy(Line_Out,XPos(Code_Delimiter + 'PA',Temp_String,1) + 3,254);
  1280.  
  1281.             End;
  1282.  
  1283.             For_Table := True;
  1284.             Call PRINT_LINE;
  1285.             Jx := XPos(Code_Delimiter + 'CE',Temp_String,1);
  1286.             IF (Jx) THEN
  1287.                 Line_Out := Str_Del(Line_Out,Jx,3);
  1288.                 Call CENTER_LINE;
  1289.             END;
  1290.             Switch_Win_Id(Table_Window);
  1291.             Put_Line('|10' + Copy(Blank_Line,1,Left_Margin) + Line_Out);
  1292.  
  1293. NO_LAST_TABLE_FOOTER:
  1294.             IF (Form_Feed) THEN
  1295.                 Eol;
  1296.                 Text('|12|13');
  1297.             ELSE
  1298.                 While (Table_Line_Num < Page_Length) Do
  1299.                     Down;
  1300.                     Put_Line('|10');
  1301.                     ++Table_Line_Num;
  1302.                 END;
  1303.             END;
  1304.         End;
  1305.         Block_Begin;
  1306.         Tof;
  1307.         Block_End;
  1308.         Jx := Cur_Window;
  1309.         Switch_Win_Id(Print_Window);
  1310.         Tof;
  1311.  
  1312.         Window_Move(Jx);
  1313.         IF (Form_Feed) THEN
  1314.             Goto_Line(Block_Line2);
  1315.             Eol;
  1316.             Del_Char;
  1317.             Del_Char;
  1318.         END;
  1319.  
  1320.         Block_Off;
  1321.         Tof;
  1322.  
  1323.         Switch_Win_Id(Table_Window);
  1324.         Delete_Window;
  1325.     End;
  1326.     Write('▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100% Complete.',4,8,0,M_B_Color);
  1327. {If an index was generated, merge it to the bottom of the document.}
  1328.     IF (Switch_Win_Id(Index_Window)) THEN
  1329.         Tof;
  1330.         IF (Not(At_Eof)) THEN
  1331.             Cr;
  1332.             Up;
  1333.             Put_Line('|10' + '******INDEX******');
  1334.             Block_Begin;
  1335.             Eof;
  1336.             Block_End;
  1337.             Jx := Cur_Window;
  1338.             Switch_Win_Id(Print_Window);
  1339.             Eof;
  1340.             IF (C_Col > 1) THEN
  1341.                 Down;
  1342.             END;
  1343.             Window_Move(Jx);
  1344.             Block_Off;
  1345.         END;
  1346.         IF (Switch_Win_Id(Index_Window)) THEN
  1347.             Delete_Window;
  1348.         END;
  1349.     END;
  1350.     Kill_Box;
  1351.     Switch_Win_Id(Text_Window);
  1352.     Tof;
  1353.     Switch_Win_Id(Print_Window);
  1354.     Tof;
  1355.     IF (Cur_Char = '|10') THEN
  1356.         Del_Char;
  1357.     END;
  1358.     Refresh := True;
  1359.     New_Screen;
  1360.     Make_Message('Formatting complete.  Print document file name is: ' +
  1361.                                                                                                                              File_Name);
  1362.     Goto END_OF_MAC;
  1363.  
  1364. {********************************** SUBROUTINES ******************************}
  1365.  
  1366. PROCESS_INDEX:
  1367.     Jx := XPos(']',Line_In,1);
  1368.     IF (Jx = 0) THEN
  1369.         Index_Main := Line_In;
  1370.         Line_In := '';
  1371.     ELSE
  1372.         Index_Main := Copy(Line_In,1,Jx - 1);
  1373.         Line_In := Str_Del(Line_In,1,Jx);
  1374.     END;
  1375.     IF (Svl(Index_Main)) THEN
  1376.         IF (Switch_Win_Id(Index_Window)) THEN
  1377.             Jx := XPos('^',Index_Main,1);
  1378.             IF (Jx) THEN
  1379.                 IF (Jx < Svl(Index_Main)) THEN
  1380.                     Index_Sub := '     ' + Copy(Index_Main,Jx + 1,75);
  1381.                 ELSE
  1382.                     Index_Sub := '';
  1383.                 END;
  1384.                 Index_Main := Copy(Index_Main,1,Jx - 1);
  1385.             ELSE
  1386.                 Index_Sub := '';
  1387.             END;
  1388.             IF (Svl(Index_Main)) THEN
  1389.                 Tof;
  1390.                 IF (At_Eof) THEN
  1391. {If this is the first entry, skip the unnecessary garbage and put the stuff in}
  1392.                     Put_Line('|10' + Caps(Index_Main));
  1393.                     IF (Svl(Index_Sub)) THEN
  1394.                         Down;
  1395.                         Goto_Col(1);
  1396.                         Text('|10' + Caps(Index_Sub));
  1397.                     END;
  1398.                     Text(' (' + Str(Cur_Page_Num) + ')');
  1399.                     RET;
  1400.                 END;
  1401.  
  1402.                 IF (Search_Fwd('%|10' + Index_Main + '{ (}||$',0)) THEN
  1403. {If we found an identical index entry, simply add the page number to it}
  1404.  
  1405.                     IF (Svl(Index_Sub)) THEN
  1406.                         Down;
  1407. FIND_SUB:
  1408.  
  1409.                         IF ((Caps(Copy(Get_Line,2,Svl(Index_Sub))) <= Caps(Index_Sub)) and
  1410.                                 (At_Eof = False)) THEN
  1411.                             IF (Copy(Get_Line,2,5) = '     ') THEN
  1412.                                 Down;
  1413.                                 Goto FIND_SUB;
  1414.                             END;
  1415.                         ELSE
  1416.                             Up;
  1417.                         END;
  1418.                         IF (Caps(Copy(Get_Line,2,Svl(Index_Sub))) <> Caps(Index_Sub)) THEN
  1419.                             Eol;
  1420.                             Cr;
  1421.                             Text('|10' + Caps(Index_Sub) + ' (' + Str(Cur_Page_Num) + ')');
  1422.                         END;
  1423.                     END;
  1424.                     IF (XPos('(' + Str(Cur_Page_Num) + ')',Get_Line,1) = 0) THEN
  1425.                         Eol;
  1426. {If we already have a page number on this main heading, put in a comma}
  1427.                         IF (Copy(Get_Line,Length(Get_Line),1) = ')') THEN
  1428.                             Text(',');
  1429.                         END;
  1430.                         Text(' (' + Str(Cur_Page_Num) + ')');
  1431.                     END;
  1432.                 ELSE
  1433. {Search for the closest thing to our entry}
  1434. FIND_MAIN:
  1435.                     IF (Caps(Copy(Get_Line,2,Svl(Index_Main))) < Caps(Index_Main)) THEN
  1436.                         Down;
  1437.                         WHILE (Copy(Get_Line,2,5) = '     ') DO
  1438.                             Down;
  1439.                         END;
  1440.                         IF (Not(At_Eof)) THEN
  1441.                             Goto FIND_MAIN;
  1442.                         END;
  1443.                     END;
  1444. {We should now be at the line below where we want to insert the new index}
  1445.                     Cr;
  1446.                     Up;
  1447.                     Text('|10' + Caps(Index_Main));
  1448.                     IF (Svl(Index_Sub)) THEN
  1449.                         Eol;
  1450.                         Cr;
  1451.                         Text('|10' + Caps(Index_Sub));
  1452.                     END;
  1453.                     Text(' (' + Str(Cur_Page_Num) + ')');
  1454.                 END;
  1455.             END;
  1456.         END;
  1457.  
  1458.         Switch_Win_Id(Text_Window);
  1459.     END;
  1460.     RET;
  1461.  
  1462. PRINT_LINE:
  1463.     IF ((F_MODE = 0) or (PRINT_HF = TRUE)) THEN
  1464. {the following lines will decode any variables imbedded in the line}
  1465.         If XPos(Code_Delimiter,Line_Out,1) Then
  1466.             Temp_String := Caps(Line_Out);
  1467.  
  1468.             While XPos(Code_Delimiter + 'PA',Temp_String,1) Do
  1469.                 Line_Out := Copy(Line_Out,1,XPos(Code_Delimiter + 'PA',Temp_String,1) - 1) +
  1470.                                         Str(Cur_Page_Num) +
  1471.                                         Copy(Line_Out,XPos(Code_Delimiter + 'PA',Temp_String,1) + 3,
  1472.                                                 SVL(Line_Out) - (XPos(Code_Delimiter + 'PA',Temp_String,1)) - 2);
  1473.                 Temp_String := Caps(Line_Out);
  1474.             End;
  1475.             While XPos(Code_Delimiter + 'DA',Temp_String,1) Do
  1476.                 Line_Out := Copy(Line_Out,1,XPos(Code_Delimiter + 'DA',Temp_String,1) - 1) + Cur_Date + Copy(Line_Out,Pos(Code_Delimiter + 'DA',Temp_String) + 3,SVL(Line_Out) - (XPos(Code_Delimiter + 'DA',Temp_String,1)) - 2);
  1477.                 Temp_String := Caps(Line_Out);
  1478.             End;
  1479.             While XPos(Code_Delimiter + 'FN',Temp_String,1) Do
  1480.                 Line_Out := Copy(Line_Out,1,XPos(Code_Delimiter + 'FN',Temp_String,1) - 1) + Cur_File_Name + Copy(Line_Out,Pos(Code_Delimiter + 'FN',Temp_String) + 3,SVL(Line_Out) - (XPos(Code_Delimiter + 'FN',Temp_String,1)) - 2);
  1481.                 Temp_String := Caps(Line_Out);
  1482.             End;
  1483.             While XPos(Code_Delimiter + 'TI',Temp_String,1) Do
  1484.                 Line_Out := Copy(Line_Out,1,XPos(Code_Delimiter + 'TI',Temp_String,1) - 1) + Cur_Time + Copy(Line_Out,XPos(Code_Delimiter + 'TI',Temp_String,1) + 3,SVL(Line_Out) - (XPos(Code_Delimiter + 'TI',Temp_String,1)) - 2);
  1485.                 Temp_String := Caps(Line_Out);
  1486.             End;
  1487.  
  1488.             While XPos(Code_Delimiter + 'CE',Temp_String,1) Do
  1489.                 Line_Out := Copy(Line_Out,1,XPos(Code_Delimiter + 'CE',Temp_String,1) - 1) +
  1490.                                             Copy(Line_Out,XPos(Code_Delimiter + 'CE',Temp_String,1) + 3,SVL(Line_Out) -
  1491.                                                                                                     (XPos(Code_Delimiter + 'CE',Temp_String,1)) - 2);
  1492.                 Call CENTER_LINE;
  1493.                 Temp_String := Caps(Line_Out);
  1494.             End;
  1495.  
  1496. {Decode any possible printer specific codes}
  1497.             Temp_Integer := 1;
  1498. GET_PS_CODE:
  1499.             Delimiter_Pos := XPos(Code_Delimiter,Line_Out,Temp_Integer);
  1500.       IF ((Delimiter_Pos > 0) and (Delimiter_Pos < (Svl(Line_Out) - 1))) THEN
  1501.                 Temp_Integer := Delimiter_Pos + 1;
  1502.                 Command := Caps(Copy(Line_Out,Temp_Integer,2));
  1503.                 Call GET_PRINTER_CODE;
  1504.                 IF (Return_Int) THEN
  1505.                     Line_Out := Copy(Line_Out,1,Delimiter_Pos - 1) + Return_Str
  1506.                                 + Copy(Line_Out,Delimiter_Pos + 3,255);
  1507.                 END;
  1508.                 Goto GET_PS_CODE;
  1509.             END;
  1510.         End;
  1511.     END;
  1512.  
  1513.     If (For_Table) Then
  1514.         For_Table := False;
  1515.         RET;
  1516.     End;
  1517.     SWITCH_WIN_Id(Print_Window);
  1518.     Tabs_To_Spaces(Line_Out); {convert tabs to spaces}
  1519.     {Add in margin unless we are printing a header or a footer}
  1520.     Eol;
  1521.     IF (C_Col = 1) THEN
  1522.         Put_Line('|10' + Copy(Blank_Line,1,Left_Margin) + Line_Out);
  1523.     ELSE
  1524.         TEXT(Copy(Blank_Line,1,Left_Margin) + Line_Out);
  1525.     END;
  1526.     DOWN;
  1527.     GOTO_COL(1);
  1528.  
  1529.     Print_HF := False;
  1530.     ++Cur_Line_Num;
  1531.     SWITCH_WIN_Id(Text_Window);
  1532.     RET;
  1533.  
  1534. MOVE_DOWN:
  1535.     SWITCH_WIN_Id(Print_Window);
  1536.     IF (Xpos('|10',Get_Line,1) = 0) THEN
  1537.         Goto_Col(1);
  1538.         Text('|10');
  1539.     END;
  1540.     While (Move_Count > 0) Do
  1541.         DOWN;
  1542.         Put_Line('|10');
  1543.         --Move_Count;
  1544.         ++Cur_Line_Num;
  1545.         If ((Cur_Line_Num =  Bottom_Margin) and Not(Making_Margin) and (Blank_Page = 0)) Then
  1546.             Goto NO_MORE_SPACES;
  1547.         End;
  1548.     End;
  1549.  
  1550.     NO_MORE_SPACES:
  1551.     Goto_Col(1);
  1552.     SWITCH_WIN_Id(Text_Window);
  1553.     RET;
  1554.  
  1555. GET_PARAMETER:
  1556.     If (Line_In = '') Then
  1557.         Parameter := Default;
  1558.         Ret;
  1559.     End;
  1560.     Temp_Param := '';
  1561.     If (Copy(Line_In,1,1) = ' ') Then
  1562. {Strip off leading space}
  1563.         Line_In := Str_Del(Line_In,1,1);
  1564.         Param_Space := True;
  1565.     Else
  1566.         Param_Space := False;
  1567.     End;
  1568.     Temp_Integer := Val(Parameter,Line_In);
  1569.     IF (Temp_Integer = 0) THEN
  1570.         Temp_Integer := SVL(Line_In) + 1;
  1571.     END;
  1572.     If (Temp_Integer > 1) Then
  1573.         Val_Error := Val(Parameter,Copy(Line_In,1,Temp_Integer - 1));
  1574.         Line_In := Str_Del(Line_In,1,Temp_Integer - 1);
  1575.     Else
  1576.         Parameter := Default;
  1577.         If (Param_Space) Then
  1578.             Line_In := ' ' + Line_In;
  1579.         End;
  1580.     End;
  1581.     RET;
  1582.  
  1583. IMBEDDED_PARAMETER:
  1584.     Temp_Param := '';
  1585.     If Line_Out = '' Then
  1586.         Parameter := Default;
  1587.         Ret;
  1588.     End;
  1589.     If (Copy(Line_Out,Param_Pos,1) = ' ') Then
  1590. {Strip off leading space}
  1591.         Line_Out := Str_Del(Line_Out,Param_Pos,1);
  1592.         Param_Space := True;
  1593.     Else
  1594.         Param_Space := False;
  1595.     End;
  1596.     While ((XPos(Copy(Line_Out,Param_Pos,1),'0123456789',1) > 0) and (Line_Out <> '') and (Copy(Line_Out,Param_Pos,1) <> '')) Do
  1597.         Temp_Param := Temp_Param + Copy(Line_Out,Param_Pos,1);
  1598.         Line_Out := Str_Del(Line_Out,Param_Pos,1);
  1599.     End;
  1600. {If no parameter, then add the space back in if there was one before}
  1601.     If (Temp_Param = '') Then
  1602.         Parameter := Default;
  1603.         If (Param_Space) Then
  1604.             Line_Out := Str_Ins(' ',Line_Out,Param_Pos + 1);
  1605.         End;
  1606.     Else
  1607.         Val_Error := Val(Parameter,Temp_Param);
  1608.     End;
  1609.     RET;
  1610.  
  1611. CENTER_LINE:
  1612. {Determine the length of the text}
  1613.     If (Line_Out = '') Then
  1614.         RET;
  1615.     End;
  1616.     If (Print_HF) Then
  1617.         SWITCH_WIN_Id(Print_Window);
  1618.         Goto_Col(Left_Margin + 1);
  1619.         SWITCH_WIN_Id(Text_Window);
  1620.     End;
  1621. {Strip Out leading spaces}
  1622.  
  1623.  
  1624. {We must strip out any printer specific formatting codes and any associated
  1625. parameters to calculate the proper text length}
  1626.     Temp_String := Caps(Line_Out);
  1627.     CALL STRIP_ATTRIBUTES;
  1628.     While (Copy(Temp_String,1,1) = ' ') DO
  1629.         Temp_String := Str_Del(Temp_String,1,1);
  1630.     END;
  1631.     While (Copy(Line_Out,1,1) = ' ') DO
  1632.         Line_Out := Str_Del(Line_Out,1,1);
  1633.     END;
  1634.     Return_Str := Line_Out;
  1635.     Call FIND_TEXT_BEGINNING;
  1636.     While (Copy(Line_Out,Return_Int,1) = ' ') DO
  1637.         Line_Out := Str_Del(Line_Out,Return_Int,1);
  1638.     END;
  1639.  
  1640.     Text_Length := SVL(Temp_String);
  1641.  
  1642.     If Text_Length > (Rght_Margin - Left_Margin - 2) Then
  1643.         RET;
  1644.     End;
  1645.     Line_Out := Copy(Blank_Line,1,((((Rght_Margin - Left_Margin) - Text_Length) / 2))) + Line_Out;
  1646. {
  1647.     Line_Out := Copy(Blank_Line,1,((((Rght_Margin - Left_Margin) - Text_Length) / 2) - 1)) + Line_Out;
  1648. }
  1649.     RET;
  1650.  
  1651. STRIP_CODES:
  1652. {This subroutine strips out all legal fprint codes from Temp_String}
  1653.     If XPos(Code_Delimiter,Temp_String,1) Then
  1654. {Strip out all codes which use no parameters}
  1655.         Temp_Integer := 0;
  1656.         WHILE (Temp_Integer < 9) DO
  1657. STRIP_NO_PARAM:
  1658.             Jx := XPos(Code_Delimiter + Copy('THCESFSHIGFNTIDAPA',(Temp_Integer * 2) + 1,2),
  1659.                                                                                                                  Caps(Temp_String),1);
  1660.             If (Jx) Then
  1661.                 Temp_String := Str_Del(Temp_String,Jx,3);
  1662.                 Goto STRIP_NO_PARAM;
  1663.             End;
  1664.             ++Temp_Integer;
  1665.         END;
  1666.  
  1667. {Strip out all codes wich use 1 parameter}
  1668.         Temp_Integer := 0;
  1669.         WHILE (Temp_Integer < 19) DO
  1670. STRIP_1_PARAM:
  1671.             Jx := XPos(Code_Delimiter + Copy('TMBMHMFMNPPBDFDHLSPLRMLMULEMITDWTEDUUD'
  1672.                                                                  ,(Temp_Integer * 2) + 1,2),Caps(Temp_String),1);
  1673.             If (Jx) Then
  1674.                 Temp_String := Str_Del(Temp_String,Jx,3);
  1675. {Strip out parameter if present}
  1676.                 If (XPos(' ',Temp_String,Jx) = Jx) Then
  1677.                     Param_Space := True;
  1678.                     Temp_String := Str_Del(Temp_String,Jx,1);
  1679.                 Else
  1680.                     Param_Space := False;
  1681.                 End;
  1682. STRIP_1_NUMERIC:
  1683.                 IF ((XPos(Copy(Temp_String,Jx,1),'1234567890-',1) > 0)
  1684.                                                                                  and (Jx <= SVL(Temp_String))) THEN
  1685.                     Temp_String := Str_Del(Temp_String,Jx,1);
  1686.                     Param_Space := False;
  1687.                     Goto STRIP_1_NUMERIC;
  1688.                 End;
  1689.                 If (Param_Space) Then
  1690.                     Temp_String := Str_Ins(' ',Temp_String,Jx);
  1691.                 End;
  1692.                 Goto STRIP_1_PARAM;
  1693.             End;
  1694.             ++Temp_Integer;
  1695.         END;
  1696.  
  1697. {Strip out .tc which has up to 12 paramters}
  1698. STRIP_TC:
  1699.         Jx := XPos(Code_Delimiter + 'TC',Caps(Temp_String),1);
  1700.         IF (Jx) THEN
  1701.             Temp_String := Str_Del(Temp_String,Jx,3);
  1702. {Strip out parameters if present}
  1703.             WHILE ((XPos(Copy(Temp_String,Jx,1),'1234567890- ',1) > 0)
  1704.                                                                                  and (Jx <= SVL(Temp_String))) DO
  1705.                 Temp_String := Str_Del(Temp_String,Jx,1);
  1706.             END;
  1707.             GOTO STRIP_TC;
  1708.         END;
  1709.     End;
  1710.  
  1711. {Strip out any printer specific commands}
  1712. STRIP_ATTRIBUTES:
  1713.     If XPos(Code_Delimiter,Temp_String,1) Then
  1714.         Jx := 0;
  1715.         WHILE (Jx < (SVL(Attribute_Commands) / 2)) DO
  1716. STRIP_ATTR:
  1717.             Jy := XPos(Code_Delimiter + Copy(Attribute_Commands,(Jx * 2) + 1,2),Caps(Temp_String),1);
  1718.             IF (Jy) THEN
  1719.                 Temp_String := Str_Del(Temp_String,Jy,3);
  1720.                 Goto STRIP_ATTR;
  1721.             END;
  1722.             ++Jx
  1723.         END;
  1724.     End;
  1725. {Strip out index entry}
  1726.     Jx := XPos(Code_Delimiter + 'X[',Caps(Temp_String),1);
  1727.     IF (Jx) THEN
  1728.         Jy := XPos(']',Temp_String,Jx);
  1729.         IF (Jy = 0) THEN
  1730.             Jy := Svl(Temp_String);
  1731.         END;
  1732.         Temp_String := Str_Del(Temp_String,Jx,Jy - Jx + 1);
  1733.     END;
  1734.     RET;
  1735.  
  1736. CHECK_MARGINS:
  1737. {This checks to make sure that all margins and the page length are all in
  1738. proper numeric order}
  1739.     IF (Header_Margin >= Top_Margin) THEN
  1740.         Header_Margin := Top_Margin - 1;
  1741.     END;
  1742.     IF (Top_Margin >= Bottom_Margin) THEN
  1743.         Bottom_Margin := Top_Margin + 1;
  1744.     END;
  1745.     IF (Bottom_Margin >= Footer_Margin) THEN
  1746.         Footer_Margin := Bottom_Margin + 1;
  1747.     END;
  1748.     RET;
  1749.  
  1750. GET_PRINTER_CODE:
  1751.     Return_Int := False;
  1752. {See if the print formatter code is in the printer code list}
  1753.     Jx := XPos('=' + Caps(Command) + '',Caps(Global_Str('PRINTER_TYPE') + ''),1);
  1754.  
  1755.     IF (Jx) THEN
  1756.         Jy := -1;
  1757.         WHILE (Copy(Global_Str('PRINTER_TYPE'),Jx,1) <> 'F') DO
  1758.             --Jx;
  1759.             ++Jy;
  1760.         END;
  1761. {Get numeric part of the field name}
  1762.         IF (Val(Jx,Copy(Global_Str('PRINTER_TYPE'),Jx + 1,Jy))) THEN
  1763.             RET;
  1764.         END;
  1765. {Now, parse out the corresponding printer code}
  1766.         Return_Str := Parse_Str('C' + Str(Jx) + '=',Global_Str('PRINTER_TYPE'));
  1767.         Return_Int := True;
  1768.     END;
  1769.     RET;
  1770.  
  1771. FIND_TEXT_BEGINNING:
  1772. {This routine finds the position of the first non-code character}
  1773.     Return_Str := Caps(Return_Str);
  1774.     Return_Int := 1;
  1775.     IF (Xpos(Code_Delimiter,Return_Str,1) = 0) THEN
  1776.         Ret;
  1777.     END;
  1778.  
  1779. {Skip over printer attribute commands}
  1780. LOOK_AGAIN:
  1781.     Temp_Integer := 0;
  1782.     While (Temp_Integer < (SVL(Attribute_Commands) / 2)) Do
  1783.         IF (Copy(Return_Str,Return_Int,3) = (Code_Delimiter + Copy(Attribute_Commands,(Temp_Integer * 2) + 1,2))) THEN
  1784.             Return_Int := Return_Int + 3;
  1785.             Goto LOOK_AGAIN;
  1786.         END;
  1787.         ++Temp_Integer;
  1788.     End;
  1789.     RET;
  1790.  
  1791. END_OF_MAC:
  1792. {Deallocate user defined commands}
  1793.     Temp_Integer := 1;
  1794.     WHILE (Temp_Integer < 11) DO
  1795.         Set_Global_Str('.UD' + Str(Temp_Integer),'');
  1796.         ++Temp_Integer;
  1797.     END;
  1798.     If (Abort) Then
  1799.         Refresh := True;
  1800.         Redraw;
  1801.         Make_Message('Print formatter aborted by user.');
  1802.     End;
  1803.     Refresh := True;
  1804.     Messages := True;
  1805.     Undo_Stat := Temp_Undo;
  1806.  
  1807.     Reg_Exp_Stat := T_Reg_Exp_Stat;
  1808.     Insert_Mode := T_Insert_Mode;
  1809.     return_int := 100;
  1810.     error_level := 0;
  1811.  
  1812. { special development code for testing execution time
  1813. If ((Val(End_Minutes,Copy(Time,4,2))) and (Val(End_Seconds,Copy(Time,7,2)))) Then
  1814. End;
  1815. If (Start_Seconds > End_Seconds) Then
  1816.     End_Seconds := End_Seconds + 60;
  1817.     --End_Minutes;
  1818. End;
  1819. If (Start_Minutes > End_Minutes) Then
  1820.     End_Minutes := End_Minutes + 60;
  1821. End;
  1822. Switch_Win_Id(Print_Window);
  1823. Text('Elapsed time ' + Str(End_Minutes - Start_Minutes) + ':' + Str(End_Seconds - Start_Seconds));
  1824. }
  1825. END_MACRO;
  1826.  
  1827. $MACRO FCMD TRANS;
  1828. {******************************************************************************
  1829.                                                                 MULTI-EDIT MACRO
  1830.  
  1831. Name:    FCMD
  1832.  
  1833. Description: The top level menu for inserting print formatting codes.
  1834.  
  1835.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1836. ******************************************************************************}
  1837.     Set_Global_Str('FCT_1','/H=PRNFORM^FMTCODEMISC/M=F_CODE_SUBMENU /MC=1');
  1838.     Set_Global_Str('XFCT_1','Misc');
  1839.     Set_Global_Str('FCT_2','/H=PRNFORM^FMTCODEVAR/M=F_CODE_SUBMENU /MC=2');
  1840.     Set_Global_Str('XFCT_2','Variables');
  1841.     Set_Global_Str('FCT_3','/H=PRNFORM^FMTCODEATT/M=F_CODE_SUBMENU /MC=3');
  1842.     Set_Global_Str('XFCT_3','Attributes');
  1843.     Set_Global_Str('FCT_4','/H=PRNFORM^FMTCODEPGSTUP/M=F_CODE_SUBMENU /MC=4');
  1844.     Set_Global_Str('XFCT_4','Page-setup');
  1845.     Set_Global_Str('FCT_5','/H=PRNFORM^FMTCODEHDRFTR/M=F_CODE_SUBMENU /MC=5');
  1846.     Set_Global_Str('XFCT_5','Headers-footers');
  1847.     Set_Global_Str('FCT_6','/H=PRNFORM^TOFC/M=F_CODE_SUBMENU /MC=6');
  1848.     Set_Global_Str('XFCT_6','Table-of-contents');
  1849.  
  1850.     RM('USERIN^TOPMENU /M=XFCT_/G=FCT_/#=6/X=3/S=1/BC=1/L=INSERT PRINT FORMATTER CODES/Y=4');
  1851.  
  1852.     Set_Global_Str('FCT_1','');
  1853.     Set_Global_Str('XFCT_1','');
  1854.     Set_Global_Str('FCT_2','');
  1855.     Set_Global_Str('XFCT_2','');
  1856.     Set_Global_Str('FCT_3','');
  1857.     Set_Global_Str('XFCT_3','');
  1858.     Set_Global_Str('FCT_4','');
  1859.     Set_Global_Str('XFCT_4','');
  1860.     Set_Global_Str('FCT_5','');
  1861.     Set_Global_Str('XFCT_5','');
  1862.     Set_Global_Str('FCT_6','');
  1863.     Set_Global_Str('XFCT_6','');
  1864.     return_int := 100;
  1865. END_MACRO;
  1866.  
  1867. $MACRO F_CODE_SUBMENU;
  1868. {******************************************************************************
  1869.                                                                 MULTI-EDIT MACRO
  1870.  
  1871. Name:    F_CODE_SUBMENU
  1872.  
  1873. Description: The sub level menu for inserting print formatting codes.
  1874.  
  1875.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1876. ******************************************************************************}
  1877.     Def_Int(Main_Choice,Sub_Count);
  1878.     Def_Str(Sub_Str,Sub_Title);
  1879.  
  1880.     Main_Choice := Parse_Int('/MC=',MParm_Str);
  1881.  
  1882.     If (Main_Choice = 1) Then
  1883.         Set_Global_Str('FCS_1','/H=PRNFORM^FMTCODEMISC/M=INSERT_F_CODES /MC=1/SC=1');
  1884.         Set_Global_Str('XFCS_1','page Break');
  1885.         Set_Global_Str('FCS_2','/M=INSERT_F_CODES /MC=1/SC=2');
  1886.         Set_Global_Str('XFCS_2','Center');
  1887.         Set_Global_Str('FCS_3','/M=INSERT_F_CODES /MC=1/SC=3');
  1888.         Set_Global_Str('XFCS_3','cOmment');
  1889.         Set_Global_Str('FCS_4','/M=INSERT_F_CODES /MC=1/SC=4');
  1890.         Set_Global_Str('XFCS_4','iGnore');
  1891.         Set_Global_Str('FCS_5','/M=INSERT_F_CODES /MC=1/SC=5');
  1892.         Set_Global_Str('XFCS_5','Define user code');
  1893.         Set_Global_Str('FCS_6','/M=INSERT_F_CODES /MC=1/SC=6');
  1894.         Set_Global_Str('XFCS_6','Execute user code');
  1895.         Sub_Count := 6;
  1896.         Sub_Title := 'MISCELLANEOUS';
  1897.     End;
  1898.  
  1899.     If (Main_Choice = 2) Then
  1900.         Set_Global_Str('FCS_1','/H=PRNFORM^FMTCODEVAR/M=INSERT_F_CODES /MC=2/SC=1');
  1901.         Set_Global_Str('XFCS_1','File name');
  1902.         Set_Global_Str('FCS_2','/M=INSERT_F_CODES /MC=2/SC=2');
  1903.         Set_Global_Str('XFCS_2','Time');
  1904.         Set_Global_Str('FCS_3','/M=INSERT_F_CODES /MC=2/SC=3');
  1905.         Set_Global_Str('XFCS_3','Date');
  1906.         Set_Global_Str('FCS_4','/M=INSERT_F_CODES /MC=2/SC=4');
  1907.         Set_Global_Str('XFCS_4','Page number');
  1908.         Sub_Count := 4;
  1909.         Sub_Title := 'VARIABLES';
  1910.     End;
  1911.  
  1912.     If (Main_Choice = 3) Then
  1913.         RM('INSERT_F_CODES /MC=3' + mparm_str);
  1914.  
  1915.         IF (return_int < 1) THEN
  1916.             Goto EXIT2;
  1917.         END;
  1918.         Goto EXIT;
  1919.     End;
  1920.  
  1921.  
  1922.     If (Main_Choice = 4) Then
  1923.         Set_Global_Str('FCS_1','/H=PRNFORM^FMTCODEPGSTUP/M=INSERT_F_CODES /MC=4/SC=1');
  1924.         Set_Global_Str('XFCS_1','line Spacing');
  1925.         Set_Global_Str('FCS_2','/M=INSERT_F_CODES /MC=4/SC=2');
  1926.         Set_Global_Str('XFCS_2','Page length');
  1927.         Set_Global_Str('FCS_3','/M=INSERT_F_CODES /MC=4/SC=3');
  1928.         Set_Global_Str('XFCS_3','Right margin');
  1929.         Set_Global_Str('FCS_4','/M=INSERT_F_CODES /MC=4/SC=4');
  1930.         Set_Global_Str('XFCS_4','Left margin');
  1931.         Set_Global_Str('FCS_5','/M=INSERT_F_CODES /MC=4/SC=5');
  1932.         Set_Global_Str('XFCS_5','Top margin');
  1933.         Set_Global_Str('FCS_6','/M=INSERT_F_CODES /MC=4/SC=6');
  1934.         Set_Global_Str('XFCS_6','Bottom margin');
  1935.         Set_Global_Str('FCS_7','/M=INSERT_F_CODES /MC=4/SC=7');
  1936.         Set_Global_Str('XFCS_7','Form feeds');
  1937.         Sub_Count := 7;
  1938.         Sub_Title := 'PAGE SETUP';
  1939.     End;
  1940.  
  1941.     If (Main_Choice = 5) Then
  1942.         Set_Global_Str('FCS_1','/H=PRNFORM^FMTCODEHDRFTR/M=INSERT_F_CODES /MC=5/SC=1');
  1943.         Set_Global_Str('XFCS_1','define Header');
  1944.         Set_Global_Str('FCS_2','/M=INSERT_F_CODES /MC=5/SC=2');
  1945.         Set_Global_Str('XFCS_2','define Footer');
  1946.         Set_Global_Str('FCS_3','/M=INSERT_F_CODES /MC=5/SC=3');
  1947.         Set_Global_Str('XFCS_3','Suppress header');
  1948.         Set_Global_Str('FCS_4','/M=INSERT_F_CODES /MC=5/SC=4');
  1949.         Set_Global_Str('XFCS_4','sUpress footer');
  1950.         Set_Global_Str('FCS_5','/M=INSERT_F_CODES /MC=5/SC=5');
  1951.         Set_Global_Str('XFCS_5','header Margin');
  1952.         Set_Global_Str('FCS_6','/M=INSERT_F_CODES /MC=5/SC=6');
  1953.         Set_Global_Str('XFCS_6','footer mArgin');
  1954.         Sub_Count := 6;
  1955.         Sub_Title := 'HEADERS//FOOTERS';
  1956.     End;
  1957.  
  1958.     If (Main_Choice = 6) Then
  1959.         Set_Global_Str('FCS_1','/H=PRNFORM^TOFC/M=INSERT_F_CODES /MC=6/SC=1');
  1960.         Set_Global_Str('XFCS_1','Define table');
  1961.         Set_Global_Str('FCS_2','/M=INSERT_F_CODES /MC=6/SC=2');
  1962.         Set_Global_Str('XFCS_2','table Entry');
  1963.         Sub_Count := 2;
  1964.         Sub_Title := 'TABLE OF CONTENTS';
  1965.     End;
  1966.  
  1967.     RM('USERIN^SUBMENU /GCLR=1/M=XFCS_/G=FCS_/S=1/L=' + Sub_Title + '/#='
  1968.         + Str(Sub_Count) + '/X=' + Parse_Str('/X=',MParm_Str) + '/Y=' +
  1969.         Parse_Str('/Y=',MParm_Str));
  1970.     IF (Return_Int < 1) THEN
  1971.     {    IF (Return_int = -1) THEN
  1972.             Key1 := 0;
  1973.             Key2 := 72;
  1974.         END;
  1975.         Return_int := 0; }
  1976.         Goto EXIT2;
  1977.     END;
  1978.  
  1979. EXIT:
  1980.     return_int := 100;
  1981. EXIT2:
  1982.     Sub_Count := 7;
  1983.     WHILE (Sub_Count) DO
  1984.         Set_Global_Str('FCS_' + Str(Sub_Count),'');
  1985.         Set_Global_Str('XFCS_' + Str(Sub_Count),'');
  1986.         --Sub_Count;
  1987.     END;
  1988.  
  1989. END_MACRO;
  1990.  
  1991. $MACRO INSERT_F_CODES TRANS;
  1992. {******************************************************************************
  1993.                                                                 MULTI-EDIT MACRO
  1994.  
  1995. Name:    INSERT_F_CODES
  1996.  
  1997. Description: Inserts print formatting codes based on menu choices from
  1998. F_CODE_SUBMENU.
  1999.  
  2000.                              (C) Copyright 1989 by American Cybernetics, Inc.
  2001. ******************************************************************************}
  2002.  
  2003. Def_Int(Temp_Integer,Main_Choice,Sub_Choice,Jx,Jy,Temp_Refresh,
  2004.                 Temp_Insert_Mode);
  2005. Def_Str(Temp_String,Temp_String2,Printer_Type[20]{,Temp_Word_Delimits[40]});
  2006. Def_Char(Code_Delimiter);
  2007.  
  2008.     Temp_Refresh := Refresh;
  2009.     Refresh := False;
  2010.     Temp_Insert_Mode := Insert_Mode;
  2011.     Printer_Type := Parse_Str('PT=',Global_Str('Printer_Type'));
  2012.     Main_Choice := 1;
  2013.     Sub_Choice := 1;
  2014.     Code_Delimiter := Global_Str('Format_Code_Delimit');
  2015.     IF (Code_Delimiter = '') THEN
  2016.         Code_Delimiter := '.';
  2017.     END;
  2018.  
  2019.         Main_Choice := Parse_Int('/MC=',MParm_Str);
  2020.         Sub_Choice := Parse_Int('/SC=',MParm_Str);
  2021.  
  2022.         If (Main_Choice = 1) Then
  2023.             If (Sub_Choice = 0) Then
  2024.                 Goto DONT_INSERT_CODE;
  2025.             End;
  2026.  
  2027.             Temp_String := '';
  2028.             If (Sub_Choice = 1) Then
  2029. {Querybox is a general purpose "boxed" prompt.}
  2030.                 Return_Int := 0;
  2031.                 RM('QUERYBOX /N=1/P=Enter new page number:/H=PRNFORM^FMTCODEMISC/C=5/L=7/W=4' +
  2032.                                     '/T=PAGE BREAK/MIN=0');
  2033.                 IF (Return_Str = 'FALSE') THEN
  2034.                     Goto BACK_UP;
  2035.                 END;
  2036.                 Temp_String := Str(Return_Int);
  2037.             End;
  2038.             If (Sub_Choice = 5) Then
  2039.                 Return_Int := 1;
  2040.                 RM('QUERYBOX /N=1/P=Enter number of user code(1-10):/H=PRNFORM^FMTCODEMISC/C=5' +
  2041.                                     '/L=7/W=2/T=DEFINE USER CODE/MIN=1/MAX=10');
  2042.                 IF (Return_Str = 'FALSE') THEN
  2043.                     Goto BACK_UP;
  2044.                 END;
  2045.                 Temp_String := Str(Return_Int);
  2046.             End;
  2047.             If (Sub_Choice = 6) Then
  2048.                 Return_Int := 1;
  2049.                 RM('QUERYBOX /N=1/P=Enter number of user code(1-10):/H=PRNFORM^FMTCODEMISC/C=5' +
  2050.                                     '/L=7/W=2/T=DEFINE USER CODE/MIN=1/MAX=10');
  2051.                 IF (Return_Str = 'FALSE') THEN
  2052.                     Goto BACK_UP;
  2053.                 END;
  2054.                 Temp_String := Str(Return_Int);
  2055.             End;
  2056.             Temp_String := Copy('pbcenpigduud',((Sub_Choice - 1) * 2) + 1,2) +
  2057.                                                                                                                             Temp_String;
  2058.             Goto INSERT_CODE;
  2059.         End;
  2060.  
  2061.         If (Main_Choice = 2) Then
  2062.             If (Sub_Choice = 0) Then
  2063.                 Kill_Box;
  2064.                 Goto DONT_INSERT_CODE;
  2065.             End;
  2066.             Temp_String := Copy('fntidapa',((Sub_Choice - 1) * 2) + 1,2);
  2067.             Goto INSERT_CODE;
  2068.         End;
  2069.  
  2070.         If (Main_Choice = 3) Then
  2071.             IF (Printer_Type = '') THEN
  2072.                 RM('MEERROR^Beeps /C=1');
  2073.                 Make_Message('Printer type not specified!  Use Install or Print.  Press any key.');
  2074.                 Goto DONT_INSERT_CODE;
  2075.             END;
  2076.  
  2077.             RM('MEUTIL3^PRINT_CODE_MENU /F=1' + MParm_Str);
  2078.  
  2079.             IF (Return_Int < 1) THEN
  2080.                 Goto ATTRIBUTE_EXIT;
  2081.             END;
  2082.             IF (Parse_Str('/F=',Return_Str) = '') THEN
  2083.                 Goto BACK_UP;
  2084.             ELSE
  2085.                 Temp_String := Parse_Str('/F=',Return_Str);
  2086.                 Goto INSERT_CODE;
  2087.             END;
  2088.         End;
  2089.  
  2090.  
  2091.         If (Main_Choice = 4) Then
  2092.             If (Sub_Choice = 0) Then
  2093.                 Kill_Box;
  2094.                 Goto DONT_INSERT_CODE;
  2095.             End;
  2096.  
  2097.             Temp_String := '';
  2098.             If (Sub_Choice = 1) Then
  2099.                 Return_Int := 1;
  2100.                 RM('QUERYBOX /N=1/P=Enter line spacing:/H=PRNFORM^FMTCODEPGSTUP/C=31/L=7/W=2' +
  2101.                                     '/T=LINE SPACING/MIN=1');
  2102.                 IF (Return_Str = 'FALSE') THEN
  2103.                     Goto BACK_UP;
  2104.                 END;
  2105.                 Temp_String := Str(Return_Int);
  2106.             End;
  2107.             If (Sub_Choice = 2) Then
  2108.                 Return_Int := 66;
  2109.                 RM('QUERYBOX /N=1/P=Enter page length:/H=PRNFORM^FMTCODEPGSTUP/C=31/L=7/W=3' +
  2110.                                     '/T=PAGE LENGTH/MIN=1');
  2111.                 IF (Return_Str = 'FALSE') THEN
  2112.                     Goto BACK_UP;
  2113.                 END;
  2114.                 Temp_String := Str(Return_Int);
  2115.             End;
  2116.             If (Sub_Choice = 3) Then
  2117.                 Return_Int := 80;
  2118.                 RM('QUERYBOX /N=1/P=Enter right margin:/H=PRNFORM^FMTCODEPGSTUP/C=31/L=7/W=3' +
  2119.                                     '/T=RIGHT MARGIN/MIN=2/MAX=254');
  2120.                 IF (Return_Str = 'FALSE') THEN
  2121.                     Goto BACK_UP;
  2122.                 END;
  2123.                 Temp_String := Str(Return_Int);
  2124.             End;
  2125.             If (Sub_Choice = 4) Then
  2126.                 Return_Int := 0;
  2127.                 RM('QUERYBOX /N=1/P=Enter left margin:/H=PRNFORM^FMTCODEPGSTUP/C=31/L=7/W=2' +
  2128.                                     '/T=LEFT MARGIN/MIN=1');
  2129.                 IF (Return_Str = 'FALSE') THEN
  2130.                     Goto BACK_UP;
  2131.                 END;
  2132.                 Temp_String := Str(Return_Int);
  2133.             End;
  2134.             If (Sub_Choice = 5) Then
  2135.                 Return_Int := 5;
  2136.                 RM('QUERYBOX /N=1/P=Enter top margin:/H=PRNFORM^FMTCODEPGSTUP/C=31/L=7/W=2' +
  2137.                                     '/T=TOP MARGIN/MIN=-1');
  2138.                 IF (Return_Str = 'FALSE') THEN
  2139.                     Goto BACK_UP;
  2140.                 END;
  2141.                 Temp_String := Str(Return_Int);
  2142.             End;
  2143.             If (Sub_Choice = 6) Then
  2144.                 Return_Int := 60;
  2145.                 RM('QUERYBOX /N=1/P=Enter bottom margin:/H=PRNFORM^FMTCODEPGSTUP/C=31/L=7/W=3' +
  2146.                                     '/T=BOTTOM MARGIN/MIN=1');
  2147.                 IF (Return_Str = 'FALSE') THEN
  2148.                     Goto BACK_UP;
  2149.                 END;
  2150.                 Temp_String := Str(Return_Int);
  2151.             End;
  2152.             If (Sub_Choice = 7) Then
  2153.                 Put_Box(31,7,67,10,0,M_B_Color,'FORM FEEDS',True);
  2154.                 Write('Form feeds at page breaks:',32,8,0,M_B_Color);
  2155.                 RM('USERIN^XMENU /T=0/X=59/Y=8/S=2/M=On(PRNFORM^FMTCODEPGSTUP)oFf()');
  2156.                 Temp_Integer := Return_Int;
  2157.                 Kill_Box;
  2158.                 If (Temp_Integer < 1) Then
  2159.                     Goto BACK_UP;
  2160.                 End;
  2161.                 Temp_String := Copy('10',Temp_Integer,1);
  2162.             End;
  2163.  
  2164.             Temp_String := Copy('lsplrmlmtmbmff',((Sub_Choice - 1) * 2) + 1,2) + Temp_String;
  2165.             Goto INSERT_CODE;
  2166.         End;
  2167.  
  2168.         If (Main_Choice = 5) Then
  2169.             If (Sub_Choice = 0) Then
  2170.                 Kill_Box;
  2171.                 Goto DONT_INSERT_CODE;
  2172.             End;
  2173.             Temp_String := '';
  2174.             If (Sub_Choice = 1) Then
  2175.                 Put_Box(42,7,76,10,0,M_B_Color,'DEFINE HEADER',True);
  2176.                 Write('Which header?',43,8,0,M_B_Color);
  2177.                 RM('USERIN^XMENU /T=0/X=57/Y=8/S=1/M=Primary(PRNFORM^FMTCODEHDRFTR)Secondary()');
  2178.                 Temp_Integer := Return_Int;
  2179.                 Kill_Box;
  2180.                 If (Temp_Integer < 1) Then
  2181.                     Goto BACK_UP;
  2182.                 End;
  2183.                 Temp_String := Copy('12',Temp_Integer,1);
  2184.             End;
  2185.  
  2186.             If (Sub_Choice = 2) Then
  2187.                 Put_Box(42,7,76,10,0,M_B_Color,'DEFINE FOOTER',True);
  2188.                 Write('Which footer?',43,8,0,M_B_Color);
  2189.                 RM('USERIN^XMENU /T=0/X=57/Y=8/S=1/M=Primary(PRNFORM^FMTCODEHDRFTR)Secondary()');
  2190.                 Temp_Integer := Return_Int;
  2191.                 Kill_Box;
  2192.                 If (Temp_Integer < 1) Then
  2193.                     Goto BACK_UP;
  2194.                 End;
  2195.                 Temp_String := Copy('12',Temp_Integer,1);
  2196.             End;
  2197.  
  2198.             If (Sub_Choice = 5) Then
  2199.                 Return_Int := 2;
  2200.                 RM('QUERYBOX /N=1/P=Enter header margin:/H=PRNFORM^FMTCODEHDRFTR/C=42/L=7/W=2' +
  2201.                                     '/T=HEADER MARGIN/MIN=-1');
  2202.                 IF (Return_Str = 'FALSE') THEN
  2203.                     Goto BACK_UP;
  2204.                 END;
  2205.                 Temp_String := Str(Return_Int);
  2206.             End;
  2207.  
  2208.             If (Sub_Choice = 6) Then
  2209.                 Return_Int := 64;
  2210.                 RM('QUERYBOX /N=1/P=Enter footer margin:/H=PRNFORM^FMTCODEHDRFTR/C=42/L=7/W=3' +
  2211.                                     '/T=FOOTER MARGIN/MIN=2');
  2212.                 IF (Return_Str = 'FALSE') THEN
  2213.                     Goto BACK_UP;
  2214.                 END;
  2215.                 Temp_String := Str(Return_Int);
  2216.             End;
  2217.             Temp_String := Copy('dhdfshsfhmfm',((Sub_Choice - 1) * 2) + 1,2) + Temp_String;
  2218.             Goto INSERT_CODE;
  2219.         End;
  2220.  
  2221.         If (Main_Choice = 6) Then
  2222.             If (Sub_Choice = 0) Then
  2223.                 Kill_Box;
  2224.                 Goto DONT_INSERT_CODE;
  2225.             End;
  2226.  
  2227.             Temp_String := '';
  2228.             If (Sub_Choice = 1) Then
  2229.                 Set_Global_Int('IINT_1',75);
  2230.                 Set_Global_Str('IPARM_1','/T=Right margin for page numbers                     /TP=1/C=1/L=1/W=3/H=PRNFORM^TOFC');
  2231.                 Set_Global_Str('ISTR_2','/T=Yes/F=No');
  2232.                 Set_Global_Str('IPARM_2','/T=Use periods between table entry and page number   /TP=5/C=1/L=2/W=3/H=PRNFORM^TOFC');
  2233.                 Set_Global_Int('IINT_2',0);
  2234.  
  2235.                 Set_Global_Str('ISTR_3','/T=Yes/F=No');
  2236.                 Set_Global_Str('IPARM_3','/T=Include headers in table of contents              /TP=5/C=1/L=3/W=3/H=PRNFORM^TOFC');
  2237.                 Set_Global_Int('IINT_3',1);
  2238.                 Set_Global_Str('ISTR_4','/T=Yes/F=No');
  2239.                 Set_Global_Str('IPARM_4','/T=Include footers in table of contents              /TP=5/C=1/L=4/W=3/H=PRNFORM^TOFC');
  2240.                 Set_Global_Int('IINT_4',1);
  2241.  
  2242.                 Set_Global_Int('IINT_5',0);
  2243.                 Set_Global_Str('IPARM_5','/T=Amount of indenting from left margin for level 1  /TP=1/C=1/L=6/W=2/H=PRNFORM^TOFC');
  2244.                 Set_Global_Str('ISTR_6','Plain(PRNFORM^TOFC)Numeric()Alpha()Roman numeral()');
  2245.                 Set_Global_Int('IINT_6',1);
  2246.                 Set_Global_Str('IPARM_6','/T=Level 1 table style                               /TP=3/C=1/L=7/W=13/H=PRNFORM^TOFC');
  2247.  
  2248.                 Set_Global_Int('IINT_7',5);
  2249.                 Set_Global_Str('IPARM_7','/T=Amount of indenting from level 1 for level 2      /TP=1/C=1/L=9/W=2/H=PRNFORM^TOFC');
  2250.                 Set_Global_Str('ISTR_8','Plain(PRNFORM^TOFC)Numeric()Alpha()Roman numeral()');
  2251.                 Set_Global_Int('IINT_8',1);
  2252.                 Set_Global_Str('IPARM_8','/T=Level 2 table style                               /TP=3/C=1/L=10/W=13/H=PRNFORM^TOFC');
  2253.  
  2254.                 Set_Global_Int('IINT_9',5);
  2255.                 Set_Global_Str('IPARM_9','/T=Amount of indenting from level 2 for level 3      /TP=1/C=1/L=12/W=2/H=PRNFORM^TOFC');
  2256.                 Set_Global_Str('ISTR_10','Plain(PRNFORM^TOFC)Numeric()Alpha()Roman numeral()');
  2257.                 Set_Global_Int('IINT_10',1);
  2258.                 Set_Global_Str('IPARM_10','/T=Level 3 table style                               /TP=3/C=1/L=13/W=13/H=PRNFORM^TOFC');
  2259.  
  2260.                 Set_Global_Int('IINT_11',5);
  2261.                 Set_Global_Str('IPARM_11','/T=Amount of indenting from level 3 for level 4      /TP=1/C=1/L=15/W=2/H=PRNFORM^TOFC');
  2262.                 Set_Global_Str('ISTR_12','Plain(PRNFORM^TOFC)Numeric()Alpha()Roman numeral()');
  2263.                 Set_Global_Int('IINT_12',1);
  2264.                 Set_Global_Str('IPARM_12','/T=Level 4 table style                               /TP=3/C=1/L=16/W=13/H=PRNFORM^TOFC');
  2265.  
  2266.                 Set_Global_Int('IINT_13',5);
  2267.                 Set_Global_Str('IPARM_13','/T=Amount of indenting from level 4 for level 5      /TP=1/C=1/L=18/W=2/H=PRNFORM^TOFC');
  2268.                 Set_Global_Str('ISTR_14','Plain(PRNFORM^TOFC)Numeric()Alpha()Roman numeral()');
  2269.                 Set_Global_Int('IINT_14',1);
  2270.                 Set_Global_Str('IPARM_14','/T=Level 5 table style                               /TP=3/C=1/L=19/W=13/H=PRNFORM^TOFC');
  2271.  
  2272.  
  2273.                 RM( 'USERIN^DATA_IN /A=2/#=14/S=1/X=3/T=DEFINE TABLE OF CONTENTS/X=17/Y=4');
  2274.  
  2275.                 Temp_String := ' ' + Str(Global_Int('IINT_1')) +
  2276.                 ' ' + Str(Global_Int('IINT_2')) +
  2277.                 ' ' + Str(Not(Global_Int('IINT_3'))) +
  2278.                 ' ' + Str(Not(Global_Int('IINT_4'))) +
  2279.                 ' ' + Str(Global_Int('IINT_5')) +
  2280.                 ' ' + Str(Global_Int('IINT_6') - 1) +
  2281.                 ' ' + Str(Global_Int('IINT_7')) +
  2282.                 ' ' + Str(Global_Int('IINT_8') - 1) +
  2283.                 ' ' + Str(Global_Int('IINT_9')) +
  2284.                 ' ' + Str(Global_Int('IINT_10') - 1) +
  2285.                 ' ' + Str(Global_Int('IINT_11')) +
  2286.                 ' ' + Str(Global_Int('IINT_12') - 1) +
  2287.                 ' ' + Str(Global_Int('IINT_13')) +
  2288.                 ' ' + Str(Global_Int('IINT_14') - 1);
  2289.  
  2290. {
  2291.                 Put_Box(19,7,80,10,0,M_B_Color,'DEFINE TABLE',True);
  2292.  
  2293.                 return_Int := 75;
  2294.                 RM( 'USERIN^QUERYBOX /NB=1/N=1/MIN=5/MAX=254/P=Enter right margin for table: /W=3/C=19/L=7/H=PRNFORM^TOFC' );
  2295.                 temp_string := Str(Return_Int);
  2296.                 IF (return_str = 'TRUE') THEN
  2297.                     Temp_String := ' ' + Temp_String;
  2298.                 Else
  2299.                     Kill_Box;
  2300.                     Goto BACK_UP;
  2301.                 End;
  2302.  
  2303. {
  2304.                 Write('Enter right margin for table: ',20,8,0,M_B_Color);
  2305.                 return_str := temp_string;
  2306.                 RM( 'USERIN^USERSTR /W=3/X=49/Y=8/H=PRNFORM^TOFC' );
  2307.                 temp_string := return_str;
  2308.                 IF return_int THEN
  2309.                     Temp_String := ' ' + Temp_String;
  2310.                 Else
  2311.                     Kill_Box;
  2312.                     Goto BACK_UP;
  2313.                 End;
  2314. }
  2315.  
  2316.                 Write('Press <ESC> to default the remaining table parameters',23,9,0,M_B_Color);
  2317.                 Write('Use periods between table entry and page number?',20,8,0,M_B_Color);
  2318.                 RM('USERIN^XMENU /T=0/X=71/Y=8/S=1/M=No(PRNFORM^TOFC)Yes()');
  2319.                 IF (Return_int < 1) THEN
  2320.                     Goto NO_MORE_LEVELS;
  2321.                 END;
  2322.                 Temp_String := Temp_String + Copy(' 0 1',((Return_int - 1) * 2) + 1,2);
  2323.  
  2324.                 Draw_Char(32,20,8,M_B_Color,58);
  2325.                 Write('Allow header to be printed in table of contents?',20,8,0,M_B_Color);
  2326.                 RM('USERIN^XMENU /T=0/X=69/Y=8/S=1/M=Yes(PRNFORM^TOFC)No()');
  2327.                 IF (Return_int < 1) THEN
  2328.                     Goto NO_MORE_LEVELS;
  2329.                 END;
  2330.                 Temp_String := Temp_String + Copy(' 0 1',((Return_int - 1) * 2) + 1,2);
  2331.                 Write('Allow footer to be printed in table of contents?',20,8,0,M_B_Color);
  2332.                 RM('USERIN^XMENU /T=0/X=69/Y=8/S=1/M=Yes(PRNFORM^TOFC)No()');
  2333.                 IF (Return_int < 1) THEN
  2334.                     Goto NO_MORE_LEVELS;
  2335.                 END;
  2336.                 Temp_String := Temp_String + Copy(' 0 1',((Return_int - 1) * 2) + 1,2);
  2337.  
  2338.                 Temp_Integer := 1;
  2339.                 Draw_Char(32,20,8,M_B_Color,58);
  2340. MORE_LEVELS:
  2341.                 Write('Enter amount of indenting for table level ' + Str(Temp_Integer) + ':',20,8,0,M_B_Color);
  2342.                 Temp_String2 := '';
  2343.                 Return_Str := Temp_String2;
  2344.                 RM( 'USERIN^USERSTR /W=3/X=64/Y=8/H=PRNFORM^TOFC' );
  2345.                 temp_string2 := return_str;
  2346.                 IF not( return_int ) THEN
  2347.                     Goto NO_MORE_LEVELS;
  2348.                 End;
  2349.                 If (Temp_String2 <> '') Then
  2350.                     Temp_String := Temp_String + ' ' + Temp_String2;
  2351.                 End;
  2352.                 Draw_Char(32,20,8,M_B_Color,58);
  2353.  
  2354.                 Write('Enter style for table level ' + Str(Temp_Integer) + ':',20,8,0,M_B_Color);
  2355.                 RM('USERIN^XMENU /T=0/X=51/Y=8/S=1/M=Plain(PRNFORM^TOFC)Numeric()Alpha()Roman numeral()');
  2356.                 IF (return_int < 1) THEN
  2357.                     Goto NO_MORE_LEVELS;
  2358.                 End;
  2359.                 Temp_String := Temp_String + ' ' + Str(Return_Int - 1);
  2360. {
  2361.                 Write('Enter format for table level ' + Str(Temp_Integer) + ':',20,8,0,M_B_Color);
  2362.                 Return_Str := Temp_String2;
  2363.                 RM( 'USERIN^USERSTR /W=3/X=51/Y=8/H=PRNFORM^TOFC' );
  2364.                 temp_string2 := return_str;
  2365.                 IF NOT(return_int) THEN
  2366.                     Goto NO_MORE_LEVELS;
  2367.                 End;
  2368.                 If (Temp_String2 <> '') Then
  2369.                     Temp_String := Temp_String + ' ' + Temp_String2;
  2370.                 End;
  2371. }
  2372.  
  2373.                 Temp_Integer := Temp_Integer + 1;
  2374.                 If (Temp_Integer > 5) Then
  2375.                     Goto NO_MORE_LEVELS;
  2376.                 Else
  2377.                     Goto MORE_LEVELS;
  2378.                 End;
  2379. NO_MORE_LEVELS:
  2380.                 Kill_Box;
  2381. }
  2382.             End;
  2383.  
  2384.             If (Sub_Choice = 2) Then
  2385.                 Return_Int := 1;
  2386.                 RM('QUERYBOX /N=1/P=Enter table indent level:/H=PRNFORM^TOFC/C=50/L=7/W=1' +
  2387.                                     '/T=TABLE ENTRY/MIN=1/MAX=5');
  2388.                 IF (Return_Str = 'FALSE') THEN
  2389.                     Goto BACK_UP;
  2390.                 END;
  2391.                 Temp_String := Str(Return_Int);
  2392.             End;
  2393.             Temp_String := Copy('tcte',((Sub_Choice - 1) * 2) + 1,2) + Temp_String;
  2394.             Goto INSERT_CODE;
  2395.         End;
  2396.  
  2397.         GOTO DONT_INSERT_CODE;
  2398.  
  2399. BACK_UP:
  2400.     Return_Int := 0;
  2401.     Goto BACK_UP_EXIT;
  2402.  
  2403. INSERT_CODE:
  2404.     Insert_Mode := True;
  2405.     Text(Code_Delimiter + Temp_String);
  2406. DONT_INSERT_CODE:
  2407.     Return_Int := 1;
  2408. BACK_UP_EXIT:
  2409.     Goto END_OF_MAC;
  2410.  
  2411. END_OF_MAC:
  2412.     return_int := 100;
  2413. ATTRIBUTE_EXIT:
  2414.     Refresh := Temp_Refresh;
  2415.     Insert_Mode := Temp_Insert_Mode;
  2416. END_MACRO;