home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / programs / spredsht / qsolve11.lbr / QSMISC.IZC / QSMISC.INC
Text File  |  1987-04-26  |  5KB  |  238 lines

  1.  
  2. procedure Bell; begin write(#7); end;
  3.  
  4.                    { screen control for H19 terminal }
  5.  
  6. procedure BlkCur; begin { write(#27'x4'); } end; { block cursor }
  7. procedure UlCur;  begin { write(#27'y4'); } end; { underline cursor }
  8.  
  9. procedure Curon;  begin { write(#27'y5'); } end; { cursor on }
  10. procedure CurOff; begin { write(#27'x5'); } end; { cursor off }
  11.  
  12. procedure Gon;    begin { write(#27'F');  } end; { enter graphics mode }
  13. procedure Goff;   begin { write(#27'G');  } end; { exit graphics mode }
  14.  
  15. function Exist(FN: str14): boolean;
  16. var
  17.   F: file;
  18. begin
  19.   Assign(F,FN);
  20.   {$I-}
  21.   Reset(F);
  22.   {$I+}
  23.   Exist:=(IOResult=0);
  24. end;
  25.  
  26. procedure Message(S: str80);
  27. begin
  28.   GotoXY(1,24);
  29.   ClrEol;
  30.   GotoXY(40-(ord(S[0]) div 2),24);
  31.   Write(S);
  32. end;
  33.  
  34. procedure Error(E: integer);
  35. begin
  36.   Bell;
  37.   HighVideo;
  38.   Err:=E;
  39.   case E of
  40.     1:  Message(' syntax error ');
  41.     2:  Message(' illegal cell referance ');
  42.     3:  Message(' division by zero ');
  43.     4:  Message(' numeric overflow ');
  44.     11: Message(' out of memory ');
  45.     51: Message(' block too wide, can''t print ');
  46.     91: Message(' can''t write file ');
  47.     92: Message(' can''t read file ');
  48.     93: Message(' can''t find file ');
  49.   end;
  50.   Delay(1500);
  51.   LowVideo;
  52.   Message('');
  53. end;
  54.  
  55. procedure UpperCase(var S: str80);
  56. begin
  57.   inline($2A/S/
  58.          $46/
  59.          $04/
  60.          $05/
  61.          $CA/*+20/
  62.          $23/
  63.          $7E/
  64.          $FE/$61/
  65.          $DA/*-9/
  66.          $FE/$7B/
  67.          $D2/*-14/
  68.          $D6/$20/
  69.          $77/
  70.          $C3/*-20);
  71. end;
  72.  
  73. procedure StrRC(S: str5; var C,R: integer);
  74. begin
  75.   C:=ord(UpCase(S[1]))-64;
  76.   R:=ord(S[2])-48;
  77.   if (ord(S[0])>2) and (S[3] in ['0'..'9']) then R:=R*10+(ord(S[3])-48);
  78. end;
  79.  
  80. function StringOf(I: integer; C: char): str80;
  81. var
  82.   L: integer;
  83.   S: str80;
  84. begin
  85.   S:='';
  86.   for L:=1 to I do S:=S+C;
  87.   StringOf:=S;
  88. end;
  89.  
  90. function CLeft: integer;
  91. var
  92.   L,N: integer;
  93. begin
  94.   L:=Pred(CC);
  95.   N:=0;
  96.   while (N+CWidth[L]<=77) and (L>=1) do
  97.   begin
  98.     N:=N+CWidth[L];
  99.     L:=Pred(L);
  100.   end;
  101.   CLeft:=CC-L;
  102. end;
  103.  
  104. function CRight: integer;
  105. var
  106.   L,N: integer;
  107. begin
  108.   L:=CC;
  109.   N:=0;
  110.   while (N+CWidth[L]<=77) and (L<=26) do
  111.   begin
  112.     N:=N+CWidth[L];
  113.     L:=Succ(L);
  114.   end;
  115.   CRight:=L-CC;
  116. end;
  117.  
  118. procedure ShowBorder;
  119. var
  120.   C,R,N: integer;
  121. begin
  122.   gotoxy(1,1);
  123.   Gon;
  124.   write('---');
  125.   clreol;
  126.   N:=CRight;
  127.   for C:=CC to CC+Pred(N) do write(Chr(C+64),StringOf(Pred(CWidth[C]),'-'));
  128.   writeln;
  129.   for R:=CR to CR+20 do writeln(R:2,'|');
  130.   Goff;
  131. end;
  132.  
  133. procedure GotoCell(C,R: integer);
  134. var
  135.   N,L: integer;
  136. begin
  137.   N:=0;
  138.   for L:=CC to Pred(C) do N:=N+CWidth[L];
  139.   gotoxy(N+4,(R-CR)+2);
  140. end;
  141.  
  142. procedure AddFormSuffix;
  143. begin
  144.   str(CForm:3,TS);
  145.   if TS[3]='0' then CFor:=CFor+'&fd';
  146.   if TS[3]='1' then CFor:=CFor+'&dol';
  147.   if TS[3]='2' then CFor:=CFor+'&sci';
  148.   if TS[3]='3' then CFor:=CFor+'&bar';
  149.   if TS[3]='4' then CFor:=CFor+'&hide';
  150.   if TS[3]<'2' then
  151.   begin
  152.     if TS[2]='1' then CFor:=CFor+'$';
  153.     if TS[2]='2' then CFor:=CFor+'%';
  154.     if TS[2]='3' then CFor:=CFor+'#';
  155.     if TS[1]=' ' then CFor:=CFor+'>';
  156.     if TS[1]='1' then CFor:=CFor+'^';
  157.     if TS[1]='2' then CFor:=CFor+'<';
  158.   end;
  159. end;
  160.  
  161. function XCol(C: integer): integer;
  162. var
  163.   L,N: byte;
  164. begin
  165.   N:=4;
  166.   for L:=CC to Pred(C) do N:=N+CWidth[L];
  167.   XCol:=N;
  168. end;
  169.  
  170. procedure ShowIndex;
  171. var
  172.   C,R,L: integer;
  173. begin
  174.   for C:=Col-1 to Col+1 do
  175.   begin
  176.     gotoxy(XCol(C),1);
  177.     if C in [CC..CC+Pred(CRight)] then
  178.       if C=Col then
  179.       begin
  180.         HighVideo;
  181.         write(Chr(C+64));
  182.         LowVideo;
  183.       end else write(Chr(C+64));
  184.   end;
  185.   for R:=Row-1 to Row+1 do
  186.   begin
  187.     Gotoxy(1,(R-CR)+2);
  188.     if R in [CR..CR+20] then
  189.       if R=Row then
  190.       begin
  191.         HighVideo;
  192.         write(R:2);
  193.         LowVideo;
  194.       end else write(R:2);
  195.   end;
  196.   gotoxy(1,23);
  197.   write('   col ',Chr(Col+64),' - row ',row:2,' / memory free ',MemEnd-(MemPos-FreeOfs):5,' / ');
  198.   if CalcOn then
  199.     write('calc / ')
  200.   else
  201.     write('     / ');
  202.   L:=CA[Col,Row];
  203.   if L<>0 then
  204.   begin
  205.     CType:=Mem[L+3];
  206.     if CType=1 then
  207.     begin
  208.       move(Mem[L+4],CText,Mem[L+4]+1);
  209.       writeln('text   ');
  210.       clreol;
  211.       write(CText);
  212.     end;
  213.     if CType=2 then
  214.     begin
  215.       move(Mem[L+4],CText,Mem[L+4]+1);
  216.       writeln('graphic');
  217.       clreol;
  218.       Gon;
  219.       write(Ctext);
  220.       Goff;
  221.     end;
  222.     if CType>=3 then
  223.     begin
  224.       Move(Mem[L+11],CFor,Mem[L+11]+1);
  225.       CForm:=Mem[L+4];
  226.       AddFormSuffix;
  227.       writeln('formula');
  228.       clreol;
  229.       write(CFor);
  230.     end;
  231.   end else
  232.   begin
  233.     clreol;
  234.     writeln;
  235.     clreol;
  236.   end;
  237. end;
  238.