home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / apps / spread / opusprg / opussrc / p.pas < prev    next >
Pascal/Delphi Source File  |  1988-05-12  |  28KB  |  674 lines

  1.  
  2.  
  3. {$M+}
  4. {$E+}
  5.  
  6. PROGRAM Mock;
  7.  
  8. {$I i:\opus.i}
  9. {$I i:\gctv.inc}
  10.  
  11. {$I i:\globsubs.def}
  12. {$I i:\gemsubs.def}
  13. {$I i:\auxsubs.def}
  14. {$I i:\vdi_aes.def}
  15. {$I d:\pascal\opus\xbios.def}
  16. {$I d:\pascal\opus\gemdos.def}
  17. {$I d:\pascal\opus\stringfn.def}
  18.  
  19.  
  20. PROCEDURE DO_PRINT ( s_row,f_row,s_col,f_col : INTEGER; hdl : INTEGER );
  21.    { Prints either to disk or printer, depending on value of "hdl"
  22.      above. 2 = serial port, 3 = parallel port, > 3 = disk }
  23.    LABEL 222;
  24.    TYPE PosRec = RECORD
  25.                     start,
  26.                     stop       : INTEGER
  27.                  END;
  28.        PosType = ARRAY [1..100] OF PosRec;          
  29.    VAR i,j,work_cols,max_cols,max_lines,line_count,
  30.        page_num,start_row,end_row,start_col,end_col,
  31.        cells_per_line,top_pos,bottom_pos,
  32.        pos_in_line,pos_in_cell,a,b,c,d               : INTEGER;
  33.        a_long                                        : LONG_INTEGER;
  34.        title_1_flag,title_2_flag,
  35.        head_flag,foot_flag                           : BOOLEAN;
  36.        out_line,title_1,title_2                      : STR255;
  37.        c_str                                         : C_STR255;
  38.        positions                                     : PosType;
  39.        line_desc                                     : LineOpArray;
  40.        ptr                                           : CellPtr;
  41.  
  42.    FUNCTION TOS_Write ( handle     : INTEGER;
  43.                         n          : LONG_INTEGER;
  44.                         VAR buffer : C_STR255 ) : LONG_INTEGER;
  45.       GEMDOS($40);
  46.  
  47.    PROCEDURE DISPLAY_PAGE_NUM ( first : BOOLEAN );
  48.       VAR temp : STR10;
  49.       BEGIN
  50.           Hide_Mouse;
  51.           int_to_string(page_num,temp);
  52.           WHILE LENGTH(temp) < 4 DO
  53.              temp := CONCAT(temp,' ');
  54.           Set_Text(page_ptr,pagenum,temp,s10,4);
  55.           IF first THEN BEGIN
  56.              Form_Center(page_ptr,a,b,c,d);
  57.              Form_Dial(0,a,b,c,d,a,b,c,d);
  58.              Obj_Draw(page_ptr,Root,Max_Depth,a,b,c,d)
  59.           END
  60.           ELSE
  61.              Obj_Draw(page_ptr,pagenum,Max_Depth,a,b,c,d);   
  62.           Show_Mouse
  63.       END; { DISPLAY_PAGE_NUM }
  64.       
  65.    FUNCTION PRINTER_READY : BOOLEAN;
  66.       BEGIN
  67.           IF port = Centronics THEN
  68.              IF PrtOut_Status = $FFFF THEN
  69.                 printer_ready := TRUE
  70.              ELSE
  71.                 printer_ready := FALSE
  72.           ELSE IF AuxOut_Status = $FFFF THEN
  73.              printer_ready := TRUE
  74.           ELSE
  75.              printer_ready := FALSE
  76.       END; { PRINTER_READY }
  77.  
  78.    FUNCTION GET_EXIT_KEY : BOOLEAN;
  79.       { ESC is the exit key while printing }
  80.       VAR event,d,key : INTEGER;
  81.       BEGIN
  82.           get_exit_key := FALSE;
  83.           event := Get_Event (E_KeyBoard|E_Timer,0,0,0,0,FALSE,0,0,0,0,
  84.                                FALSE,0,0,0,0,msg_area,key,d,d,d,d,d);
  85.           IF (event & E_KeyBoard) <> 0 THEN
  86.              IF key = $011B THEN BEGIN
  87.                 Set_Mouse(M_Arrow);
  88.                 IF Do_Alert('[3][REALLY quit printing?| ][ No | Yes ]',2)=2
  89.                 THEN
  90.                    get_exit_key := TRUE
  91.                 ELSE
  92.                    Set_Mouse(M_Bee)
  93.              END
  94.       END; { GET_EXIT_KEY }
  95.  
  96.    PROCEDURE SET_UP;
  97.       BEGIN
  98.           IF hdl = port THEN 
  99.              WHILE (NOT printer_ready) DO BEGIN
  100.                 out_line := CONCAT('[1][Printer does not respond.|' ,
  101.                                        'Please check connections and|' ,
  102.                                        'power...][ Cancel | Retry ]');
  103.                 IF Do_Alert(out_line,2) = 1 
  104.                    THEN GOTO 222
  105.              END
  106.       END; { SET_UP }
  107.  
  108.    PROCEDURE JUSTIFY ( VAR what      : STR255;
  109.                            just      : VDI_Just;
  110.                            len       : INTEGER );
  111.       VAR what_len,text_pos : INTEGER;
  112.           temp              : STR255;
  113.       BEGIN
  114.           what_len := LENGTH(what);
  115.           CASE just OF
  116.              VDI_Left : ; { assume that strings are left-justified as default }
  117.              VDI_Center : BEGIN
  118.                 text_pos := (len-what_len) DIV 2;
  119.                 StringStr(' ',text_pos,temp);
  120.                 what := CONCAT(temp,what)
  121.              END;
  122.              VDI_Right : BEGIN
  123.                 text_pos := len-what_len;
  124.                 StringStr(' ',text_pos,temp);
  125.                 what := CONCAT(temp,what)
  126.              END
  127.           END
  128.       END; { JUSTIFY }
  129.  
  130.    PROCEDURE PARSE (     source : STR255;
  131.                      VAR dest   : STR255 );
  132.       { evaluates header/footers & returns a string suitable for output
  133.         to the printer  }
  134.       VAR i,j,left_pos,center_pos,right_pos,carat  : INTEGER;
  135.           left,center,right                        : STR255;
  136.           operator                                 : CHAR;
  137.       PROCEDURE INSERT_DATE ( VAR what : STR255 );
  138.          VAR month,day,year           : INTEGER;
  139.              temp1,temp2,temp3        : STR10;
  140.              temp                     : STR255;
  141.          BEGIN
  142.              Get_Date(month,day,year);
  143.              int_to_string(month,temp1);
  144.              IF LENGTH(temp1) = 1 THEN 
  145.                 temp1 := CONCAT('0',temp1);
  146.              int_to_string(day,temp2);
  147.              IF LENGTH(temp2) = 1 THEN 
  148.                 temp2 := CONCAT('0',temp2);
  149.              int_to_string(year,temp3);
  150.              DELETE(temp3,1,2); { get rid of "19" }
  151.              temp := CONCAT(temp1,'/',temp2,'/',temp3);
  152.              IF carat > LENGTH(what) THEN
  153.                 what := CONCAT(what,temp)
  154.              ELSE 
  155.                 INSERT(temp,what,carat)
  156.          END; { INSERT_DATE }
  157.       PROCEDURE INSERT_FILE_NAME ( VAR what : STR255 );
  158.          VAR temp : STR255;
  159.          BEGIN
  160.              IF current_file = '' THEN
  161.                 temp := 'Unnamed'
  162.              ELSE
  163.                 temp := current_file;
  164.              IF carat > LENGTH(what) THEN
  165.                 what := CONCAT(what,temp)
  166.              ELSE 
  167.                 INSERT(temp,what,carat)
  168.          END;
  169.       PROCEDURE INSERT_PAGE ( VAR what : STR255 );
  170.          BEGIN
  171.              int_to_string(page_num,temp);
  172.              IF carat > LENGTH(what) THEN
  173.                 what := CONCAT(what,temp)
  174.              ELSE 
  175.                 INSERT(temp,what,carat)
  176.          END;
  177.       PROCEDURE INSERT_TIME ( VAR what : STR255 );
  178.          VAR hours,mins,secs : INTEGER;
  179.              temp1,temp2     : STR10;
  180.              temp            : STR255;
  181.          BEGIN
  182.              Get_Time(hours,mins,secs);
  183.              int_to_string(hours,temp1);
  184.              IF LENGTH(temp1) = 1 THEN 
  185.                 temp1 := CONCAT('0',temp1);
  186.              int_to_string(mins,temp2);
  187.              IF LENGTH(temp2) = 1 THEN 
  188.                 temp2 := CONCAT('0',temp2);
  189.              temp := CONCAT(temp1,':',temp2);
  190.              IF carat > LENGTH(what) THEN
  191.                 what := CONCAT(what,temp)
  192.              ELSE 
  193.                 INSERT(temp,what,carat)
  194.          END; { INSERT_TIME }
  195.       PROCEDURE EVAL_OP ( operator : CHAR; VAR what : STR255 );
  196.          BEGIN
  197.              CASE operator OF
  198.                 'd' : insert_date(what);
  199.                 'f' : insert_file_name(what);
  200.                 'p' : insert_page(what);
  201.                 't' : insert_time(what)
  202.              END
  203.          END; { EVAL_OP }
  204.       PROCEDURE EXPAND ( VAR what : STR255; endchar1,endchar2 : CHAR );
  205.          BEGIN
  206.              LOOP
  207.                 carat := POS('^',what);
  208.                 EXIT IF carat = 0;
  209.                 DELETE(what,carat,1);
  210.                 IF (what[carat] = endchar1) OR (what[carat]=endchar2) THEN
  211.                    DELETE ( what,carat,LENGTH(what)-carat+1 )
  212.                 ELSE BEGIN
  213.                    operator := what[carat];
  214.                    DELETE(what,carat,1);
  215.                    eval_op(operator,what)
  216.                 END
  217.              END
  218.          END; { EXPAND }
  219.       BEGIN { PARSE }
  220.           left := '';
  221.           center := '';
  222.           right := '';
  223.           left_pos := POS('^l',source);
  224.           center_pos := POS('^c',source);
  225.           right_pos := POS('^r',source);
  226.           IF (
  227.                (left_pos = 0) AND (center_pos = 0) AND (right_pos = 0)
  228.              ) OR
  229.              (
  230.                (center_pos = 0) AND (left_pos <> 1) AND (right_pos <> 1)
  231.              ) THEN
  232.              center_pos := -1; { because the default is centered }
  233.           IF center_pos <> 0 THEN BEGIN
  234.              center := COPY(source,center_pos+2,
  235.                             LENGTH(source)-(center_pos+2)+1);
  236.              expand(center,'l','r')
  237.           END;
  238.           IF left_pos <> 0 THEN BEGIN
  239.              left := COPY(source,left_pos+2,
  240.                           LENGTH(source)-(left_pos+2)+1);
  241.              expand(left,'c','r')
  242.           END;
  243.           IF right_pos <> 0 THEN BEGIN
  244.              right := COPY(source,right_pos+2,
  245.                            LENGTH(source)-(right_pos+2)+1);
  246.              expand(right,'l','c')
  247.           END;
  248.           { now combine the extracted left, center, and right strings into
  249.             the final destination string; i.e. the header or footer }
  250.           dest := left;
  251.           center_pos := (max_cols-LENGTH(center)) DIV 2;
  252.           IF (center <> '') AND
  253.              (center_pos+LENGTH(center)-1 < max_cols) THEN BEGIN
  254.              WHILE LENGTH(dest) < center_pos DO
  255.                 dest := CONCAT(dest,' ');
  256.              dest := CONCAT(dest,center)
  257.           END;
  258.           right_pos := max_cols-LENGTH(right);
  259.           IF right <> '' THEN BEGIN
  260.              WHILE LENGTH(dest) < right_pos DO
  261.                 dest := CONCAT(dest,' ');
  262.              dest := CONCAT(dest,right)
  263.           END
  264.       END; { PARSE }
  265.  
  266.    PROCEDURE PRINT_SHEET;
  267.       LABEL 1;
  268.       VAR i,j,line_count,row  : INTEGER;
  269.           done                : BOOLEAN;
  270.       FUNCTION CELLS_THAT_FIT : INTEGER; { fit on one line }
  271.          VAR i,width,col_index : INTEGER;
  272.          BEGIN
  273.              width := col_width[start_col,spaces];
  274.              col_index := start_col+1;
  275.              WHILE (width+col_width[col_index,spaces] <= work_cols) AND
  276.                    (col_index <= f_col) DO BEGIN
  277.                    width := width+col_width[col_index,spaces];
  278.                    col_index := col_index+1
  279.              END;
  280.              col_index := col_index-1;
  281.              cells_that_fit := col_index-start_col+1
  282.          END; { CELLS_THAT_FIT }
  283.       PROCEDURE DESCRIBE_PAGE ( row : INTEGER );
  284.          PROCEDURE TOP_OF_PAGE;
  285.             VAR i : INTEGER;
  286.             BEGIN
  287.                 line_desc[1] := LfOp;
  288.                 IF head_flag THEN
  289.                    line_desc[2] := HeaderOp
  290.                 ELSE
  291.                    line_desc[2] := LfOp;
  292.                 line_desc[3] := LfOp;
  293.                 line_desc[4] := LfOp;
  294.                 line_count := 4;
  295.                 IF page_num = 1 THEN
  296.                    IF title_1_flag THEN BEGIN
  297.                       line_count := line_count+1;
  298.                       line_desc[line_count] := Title1Op;
  299.                       IF title_2_flag THEN BEGIN
  300.                          line_count := line_count+1;
  301.                          line_desc[line_count] := Title2Op
  302.                       END;
  303.                       line_count := line_count+1;
  304.                       line_desc[line_count] := LfOp;
  305.                       line_count := line_count+1;
  306.                       line_desc[line_count] := LfOp
  307.                    END
  308.                    ELSE
  309.                       IF title_2_flag THEN BEGIN
  310.                          line_count := line_count+1;
  311.                          line_desc[line_count] := Title2Op;
  312.                          line_count := line_count+1;
  313.                          line_desc[line_count] := LfOp;
  314.                          line_count := line_count+1;
  315.                          line_desc[line_count] := LfOp
  316.                       END;
  317.                 IF p_row_col THEN BEGIN
  318.                    line_count := line_count+1;
  319.                    line_desc[line_count] := RowColOp;
  320.                    line_count := line_count+1;
  321.                    line_desc[line_count] := LfOp
  322.                 END;
  323.                 line_count := line_count+1;
  324.                 top_pos := line_count { = beginning of data area }
  325.             END; { TOP_OF_PAGE }
  326.          PROCEDURE BOTTOM_OF_PAGE;
  327.             BEGIN
  328.                 line_desc[65] := FFOp;
  329.                 IF foot_flag THEN 
  330.                    line_desc[64] := FooterOp
  331.                 ELSE 
  332.                    line_desc[64] := LfOp;
  333.                 line_desc[63] := LfOp;
  334.                 line_desc[62] := LfOp;
  335.                 bottom_pos := 61
  336.             END; { BOTTOM_OF_PAGE }
  337.          PROCEDURE BODY_OF_PAGE ( row : INTEGER );
  338.             VAR i : INTEGER;
  339.             BEGIN
  340.                 FOR i := top_pos TO bottom_pos DO BEGIN
  341.                     IF row <= f_row THEN 
  342.                        line_desc[i] := DataOp
  343.                     ELSE 
  344.                        line_desc[i] := LfOp;
  345.                     row := row+1
  346.                 END
  347.             END; { BODY_OF_PAGE }
  348.          BEGIN { DESCRIBE_PAGE }
  349.              top_of_page;
  350.              bottom_of_page;
  351.              body_of_page ( row );
  352.          END; { DESCRIBE_PAGE }
  353.       PROCEDURE CREATE_LINE ( VAR row : INTEGER );
  354.          VAR f,i,j,k,width,temp_len,str_st,
  355.              abs_border,tentative_pos,len,
  356.              string_index,result,pos_index,
  357.              additional,last_pos            : INTEGER;
  358.              found                          : BOOLEAN;
  359.              temp1                          : STR255;      
  360.              a                              : AssignedStatus;
  361.          PROCEDURE STYLE ( what : PrinterSpecial );
  362.             VAR k,len : INTEGER;
  363.             BEGIN
  364.                 len := LENGTH(printer_codes[what]);
  365.                 { probably unnecessary to check for following but better
  366.                   safe than sorry! }
  367.                 IF positions[i].start > LENGTH(out_line) THEN
  368.                    out_line := CONCAT(out_line,printer_codes[what])
  369.                 ELSE
  370.                    INSERT(printer_codes[what],out_line,positions[i].start);
  371.                 FOR k := i TO pos_index DO BEGIN
  372.                     positions[k].start := positions[k].start+len;
  373.                     positions[k].stop := positions[k].stop+len
  374.                 END;
  375.                 IF positions[i].stop > LENGTH(out_line) THEN
  376.                    out_line := CONCAT(out_line,printer_codes[SUCC(what)])
  377.                 ELSE
  378.                    INSERT(printer_codes[SUCC(what)],out_line,positions[i].stop);
  379.                 len := LENGTH(printer_codes[SUCC(what)]);                   
  380.                 FOR k := i TO pos_index DO BEGIN
  381.                     IF k > i THEN
  382.                        positions[k].start := positions[k].start+len;
  383.                     positions[k].stop := positions[k].stop+len
  384.                 END
  385.             END; { STYLE }
  386.          BEGIN
  387.              out_line := '';
  388.              CASE line_desc[line_count] OF
  389.                 HeaderOp : parse(header,out_line);
  390.                 FooterOp : parse(footer,out_line);
  391.                 RowColOp : BEGIN
  392.                    out_line := '      ';
  393.                    FOR i := start_col TO end_col DO BEGIN
  394.                        temp := col_name[i];
  395.                        width := col_width[i,spaces];
  396.                        justify(temp,VDI_Center,width);
  397.                        WHILE LENGTH(temp) < width DO 
  398.                            temp := CONCAT(temp,' ');
  399.                        out_line := CONCAT(out_line,temp)
  400.                    END;
  401.                    IF (hdl <= Centronics) AND (NOT condensed_print) THEN
  402.                       out_line := CONCAT(printer_codes[BoldOn],out_line,
  403.                                          printer_codes[BoldOff])
  404.                 END;
  405.                 DataOp  : IF row <= end_row THEN BEGIN
  406.                    pos_in_line := 1;
  407.                    last_pos := 0;
  408.                    additional := 0;
  409.                    IF p_row_col THEN BEGIN
  410.                       int_to_string(row,temp);
  411.                       justify(temp,VDI_Right,5);
  412.                       IF (hdl <= Centronics) AND 
  413.                          (NOT condensed_print) THEN BEGIN
  414.                          out_line := CONCAT(printer_codes[BoldOn],temp,
  415.                                             printer_codes[BoldOff]);
  416.                          pos_in_line := 7+LENGTH(printer_codes[BoldOn])+
  417.                                           LENGTH(printer_codes[BoldOff]);
  418.                          last_pos := pos_in_line-1;                 
  419.                          additional := pos_in_line-7
  420.                       END
  421.                       ELSE BEGIN
  422.                          out_line := temp;
  423.                          pos_in_line := 7;
  424.                          last_pos := 6
  425.                       END
  426.                    END;
  427.                    abs_border := pos_in_line;
  428.                    WHILE LENGTH(out_line) < 255 DO 
  429.                       out_line := CONCAT(out_line,' ');
  430.                    pos_index := 1;
  431.                    FOR i := start_col TO end_col DO BEGIN
  432.                        width := col_width[i,spaces];
  433.                        temp := '';
  434.                        a := assigned(row,i,ptr);
  435.                        IF (a <> Void) AND (a <> Desolate) THEN BEGIN
  436.                           CASE ptr^.class OF
  437.                              Val  : prepare_num(ptr,temp);
  438.                              Labl : temp := ptr^.str^;
  439.                              Expr : IF print_formulas THEN
  440.                                        temp := ptr^.str^
  441.                                     ELSE
  442.                                        prepare_num(ptr,temp)
  443.                           END;
  444.                           str_st := 1;
  445.                           len := LENGTH(temp);
  446.                           CASE find_just(ptr) OF
  447.                              VDI_Right : BEGIN
  448.                                 WHILE LENGTH(temp) < width DO BEGIN
  449.                                    temp := CONCAT(' ',temp);
  450.                                    str_st := str_st+1
  451.                                 END;
  452.                                 pos_in_cell := width-LENGTH(temp)
  453.                              END;
  454.                              VDI_Left : BEGIN
  455.                                 WHILE LENGTH(temp) < width DO
  456.                                    temp := CONCAT(temp,' ');
  457.                                 pos_in_cell := 0
  458.                              END;
  459.                              VDI_Center : BEGIN
  460.                                 pos_in_cell := (width-LENGTH(temp)) DIV 2;
  461.                                 FOR j := 1 TO pos_in_cell DO BEGIN
  462.                                     temp := CONCAT(' ',temp);
  463.                                     str_st := str_st+1
  464.                                 END;
  465.                                 FOR j := LENGTH(temp) TO width DO
  466.                                     temp := CONCAT(temp,' ');
  467.                                 pos_in_cell := (width-LENGTH(temp)) DIV 2
  468.                              END
  469.                           END; { CASE }
  470.                           string_index := 1;
  471.                           tentative_pos := pos_in_line+pos_in_cell;
  472.                           WHILE tentative_pos < abs_border DO BEGIN
  473.                              tentative_pos := tentative_pos+1;
  474.                              string_index := string_index+1
  475.                           END;
  476.                           j := string_index;
  477.                           k := 0;
  478.                           found := FALSE;
  479.                           WHILE j <= str_st+len-1 DO BEGIN
  480.                              out_line[tentative_pos+k] := temp[j];
  481.                              last_pos := tentative_pos+k;
  482.                              IF (j >= str_st) AND (NOT found) THEN BEGIN
  483.                                 positions[pos_index].start := tentative_pos+k;
  484.                                 found := TRUE
  485.                              END;
  486.                              positions[pos_index].stop := tentative_pos+k+1;
  487.                              j := j+1;   
  488.                              k := k+1
  489.                           END
  490.                        END { IF }
  491.                        ELSE { not assigned }
  492.                           WITH positions[pos_index] DO BEGIN
  493.                              start := pos_in_line;
  494.                              stop := pos_in_line+width-1
  495.                           END;
  496.                        pos_index := pos_index+1;
  497.                        pos_in_line := pos_in_line+width
  498.                    END; { FOR i }
  499.                    WHILE LENGTH(out_line) > last_pos DO
  500.                       DELETE(out_line,LENGTH(out_line),1);
  501.                    WHILE LENGTH(out_line) > max_cols+additional DO
  502.                       DELETE(out_line,LENGTH(out_line),1);
  503.                    IF (hdl <= Centronics) AND (NOT condensed_print) THEN BEGIN
  504.                       pos_index := pos_index-1;
  505.                       j := start_col; 
  506.                       FOR i := 1 TO pos_index DO BEGIN
  507.                           a := assigned(row,j,ptr);
  508.                           IF (a <> Void) AND (a <> Desolate) THEN BEGIN
  509.                              f := ptr^.format & style_mask;
  510.                              IF f & bold_mask <> 0 THEN
  511.                                 style(BoldOn);
  512.                              IF f & italic_mask <> 0 THEN
  513.                                 style(ItalicOn);
  514.                              IF f & under_mask <> 0 THEN 
  515.                                 style(UnderOn)
  516.                           END;
  517.                           j := j+1
  518.                       END
  519.                    END;
  520.                    row := row+1
  521.                 END; { CASE DataOp }
  522.                 Title1Op : 
  523.                    IF (hdl <= Centronics) AND (NOT condensed_print) THEN
  524.                       out_line := CONCAT(printer_codes[BoldOn],title_1,
  525.                                          printer_codes[BoldOff])
  526.                    ELSE 
  527.                       out_line := title_1;
  528.                 Title2Op : 
  529.                    IF (hdl <= Centronics) AND (NOT condensed_print) THEN
  530.                       out_line := CONCAT(printer_codes[BoldOn],title_2,
  531.                                          printer_codes[BoldOff])
  532.                    ELSE
  533.                       out_line := title_2;
  534.                 LfOp : ;
  535.                 FFOp : IF hdl <= Centronics THEN
  536.                           out_line := printer_codes[PageTerm]
  537.              END { CASE }
  538.          END; { CREATE_LINE }
  539.       BEGIN { PRINT_SHEET }
  540.           start_row := s_row;
  541.           start_col := s_col;
  542.           end_row := f_row;
  543.           end_col := f_col;
  544.           done := FALSE;
  545.           row := start_row;
  546.           IF hdl <= Centronics THEN BEGIN
  547.              FOR i := 1 TO LENGTH(printer_codes[Init]) DO
  548.                  c_str[i] := printer_codes[Init,i];
  549.              a_long := TOS_Write(hdl,LENGTH(printer_codes[Init]),c_str);
  550.              IF a_long <> LENGTH(printer_codes[Init]) THEN BEGIN
  551.                 IF a_long >= 0 THEN
  552.                    Form_Error(-10)
  553.                 ELSE
  554.                    Form_Error(a_long);
  555.                 GOTO 1
  556.              END;
  557.              IF NOT draft_final THEN BEGIN
  558.                 FOR i := 1 TO LENGTH(printer_codes[Final]) DO
  559.                    c_str[i] := printer_codes[Final,i];
  560.                 a_long := TOS_Write(hdl,LENGTH(printer_codes[Final]),c_str);
  561.                 IF a_long <> LENGTH(printer_codes[Final]) THEN BEGIN
  562.                    IF a_long >= 0 THEN
  563.                       Form_Error(-10)
  564.                    ELSE
  565.                       Form_Error(a_long);
  566.                    GOTO 1
  567.                 END
  568.              END;
  569.              IF condensed_print THEN BEGIN
  570.                 FOR i := 1 TO LENGTH(printer_codes[Condensed]) DO
  571.                    c_str[i] := printer_codes[Condensed,i];   
  572.                 a_long := TOS_Write(hdl,LENGTH(printer_codes[Condensed]),
  573.                                     c_str);
  574.                 IF a_long <> LENGTH(printer_codes[Condensed]) THEN BEGIN
  575.                    IF a_long >= 0 THEN
  576.                       Form_Error(-10)
  577.                    ELSE
  578.                       Form_Error(a_long);
  579.                    GOTO 1
  580.                 END
  581.              END
  582.           END;
  583.           display_page_num(TRUE);
  584.           REPEAT
  585.                cells_per_line := cells_that_fit;
  586.                end_col := start_col+cells_per_line-1;
  587.                IF end_col > f_col THEN
  588.                   end_col := f_col;
  589.                WHILE row <= f_row DO BEGIN  { this will do as many pages as }
  590.                    display_page_num(FALSE); { are needed at 66 lines/page   }
  591.                    describe_page(row);      { to print current columns      }
  592.                    line_count := 1;
  593.                    FOR i := 1 TO 65 DO BEGIN { this does a page }
  594.                        IF get_exit_key THEN
  595.                           GOTO 1;
  596.                        create_line(row);
  597.                        IF out_line <> printer_codes[PageTerm] THEN
  598.                           out_line := CONCAT(out_line,printer_codes[LineTerm]);
  599.                        FOR j := 1 TO LENGTH(out_line) DO
  600.                            c_str[j] := out_line[j];
  601.                        a_long := TOS_Write(hdl,LENGTH(out_line),c_str);
  602.                        IF a_long <> LENGTH(out_line) THEN BEGIN
  603.                           IF a_long >= 0 THEN
  604.                              Form_Error(-10)
  605.                           ELSE
  606.                              Form_Error(a_long);
  607.                           GOTO 1
  608.                        END;
  609.                        line_count := line_count+1
  610.                    END;
  611.                    page_num := page_num+1
  612.                END;
  613.                IF end_col = f_col THEN
  614.                   done := TRUE
  615.                ELSE BEGIN
  616.                   row := start_row;
  617.                   start_col := end_col+1
  618.                END;
  619.                IF get_exit_key THEN
  620.                   done := TRUE;
  621.           UNTIL done;
  622. 1:        Form_Dial(3,a,b,c,d,a,b,c,d)
  623.       END; { PRINT_SHEET }
  624.    BEGIN { DO_PRINT }
  625.        max_lines := 66;
  626.        page_num := 1;
  627.        IF p_row_col THEN
  628.           IF condensed_print THEN
  629.              work_cols := con_chr_line-7
  630.           ELSE
  631.              work_cols := nl_chr_line-7
  632.        ELSE IF condensed_print THEN
  633.           work_cols := con_chr_line
  634.        ELSE
  635.           work_cols := nl_chr_line;
  636.        IF condensed_print THEN
  637.           max_cols := con_chr_line
  638.        ELSE   
  639.           max_cols := nl_chr_line;
  640.        IF p_title_1 <> '' THEN BEGIN
  641.           title_1_flag := TRUE;
  642.           title_1 := p_title_1;
  643.           justify(title_1,VDI_Center,max_cols)
  644.        END
  645.        ELSE
  646.           title_1_flag := FALSE;
  647.        IF p_title_2 <> '' THEN BEGIN
  648.           title_2_flag := TRUE;
  649.           title_2 := p_title_2;
  650.           justify(title_2,VDI_Center,max_cols)
  651.        END
  652.        ELSE
  653.           title_2_flag := FALSE;
  654.        IF header <> '' THEN
  655.           head_flag := TRUE
  656.        ELSE
  657.           head_flag := FALSE;
  658.        IF footer <> '' THEN
  659.           foot_flag := TRUE
  660.        ELSE
  661.           foot_flag := FALSE;
  662.        set_up;
  663.        Set_Mouse(M_Bee);
  664.        print_sheet;
  665. 222:   Set_Mouse(M_Arrow);
  666.    END; { DO_PRINT }
  667.  
  668.  
  669. BEGIN
  670. END.
  671.  
  672.  
  673.  
  674.