home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TURBO5.ZIP / TOOLKIT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-12-26  |  3.8 KB  |  123 lines

  1. { TOOLKIT - screen handling/attribute routines for IBM Pascal     }
  2. { under PC-DOS 2.0                          }
  3. {                                  }
  4. { This file, "TOOLKIT.PAS", allows you to incorporate easy to use }
  5. { screen handling routines into your IBM Pascal program. You must }
  6. { link your compiled code with the "DOSP.OBJ" file as in:         }
  7. {    A>LINK <filespec>+DOSP                          }
  8. { in order to arrive at a working .EXE file. The screen attri-    }
  9. { butes (normal, blink, boldface, underline and reverse) use the  }
  10. { ANSI.SYS extended I/O driver present on the DOS 2.0, as does    }
  11. { clear routine. In order to use them you must include a file on  }
  12. { your boot disk called CONFIG.SYS, which contains this line:     }
  13. {    DEVICE=ANSI.SYS                          }
  14. { for further information, see chapters 9 (Configuring your Sys-  }
  15. { tem) and 13 (Extended Keyboard/Screen Routines) of the DOS 2.0  }
  16. { manual.                                  }
  17. {                                  }
  18. { Although the extended keyboard/screen driver includes a routine }
  19. { for directly locating the cursor (programmable in Pascal as:    }
  20. {    write(chr(27),'[<row number>;<column number>H');)         }
  21. { for reasons I don't understand you can't place this routine in  }
  22. { a procedure (as I have done for the screen attribute calls) and }
  23. { pass the row and column values to it. All you get is an actual  }
  24. { write of the row and column values and the letter 'H' written   }
  25. { to the screen. In any event, the external compiled assembler    }
  26. { routine DOSSUB is a general DOS function call, and the cursor   }
  27. { routine in this listing makes use of it. You can can also use   }
  28. { DOSSUB for any DOS calls - the variables are:                  }
  29. {    retcd - the returned error code                  }
  30. {    intno - interrupt number                  }
  31. {    ah through dl - the 8088 registers                  }
  32. { Obviously, such use demands thorough familiarity with DOS and   }
  33. { the values it expects to find in the appropriate registers for  }
  34. { the various service calls. See Peter Norton's excellent book,   }
  35. { "Inside the IBM PC" for the straight poop.              }
  36. {                                  }
  37. { This documentation and the following program code are copyright }
  38. { (c) David A. Basskin 1983 and may be reproduced for any non-    }
  39. { commercial purpose.                          }
  40.  
  41.  
  42. procedure dossub(var retcd,intno,ah,al,bh,bl,ch,cl,dh,dl:word); extern;
  43.  
  44. procedure normal;
  45.     begin
  46.         write(chr(27),'[0m')
  47.     end;
  48.  
  49. procedure blink;
  50.     begin
  51.         write(chr(27),'[5m')
  52.     end;
  53.  
  54. procedure boldface;
  55.     begin
  56.         write(chr(27),'[1m')
  57.     end;
  58.  
  59. procedure reverse;
  60.     begin
  61.         write(chr(27),'[7m')
  62.     end;
  63.  
  64. procedure underline;
  65.     begin
  66.         write(chr(27),'[4m')
  67.     end;
  68.  
  69. procedure clear;
  70.     begin
  71.         write(chr(27),'[2J')
  72.     end;
  73.  
  74. procedure timeout;
  75.     var time1 , time2 : integer;
  76.     begin
  77.         for time1 := 1 to 1000 do
  78.           begin
  79.             for time2 := 1 to 750 do
  80.           end
  81.     end;
  82.  
  83. procedure cursor(row,column : word);
  84.     var retcd,intno,ah,al,bh,bl,ch,cl,dh,dl:word;
  85.     begin (* Cursor *)
  86.         intno:=16;
  87.         ah:=2;     {locate cursor}
  88.         bh:=0;     {page number}
  89.         row:=row-1;    {cursor row}
  90.         column:=column-1;    {cursor column}
  91.         dossub(retcd,intno,ah,al,bh,bl,ch,cl,row,column);
  92.     end; (* Cursor *)
  93.  
  94. procedure drawbox;
  95.     var count : word;
  96.     begin
  97.         cursor(1,1);
  98.         write(chr(201));
  99.         for count := 2 to 79 do
  100.           begin
  101.             cursor(1,count);
  102.             write(chr(205))
  103.           end;
  104.         cursor(1,80);
  105.         write(chr(187));
  106.         for count := 2 to 23 do
  107.           begin
  108.             cursor(count,1);
  109.             write(chr(186));
  110.             cursor(count,80);
  111.             write(chr(186))
  112.           end;
  113.         cursor(24,1);
  114.         write(chr(200));
  115.         for count := 2 to 79 do
  116.           begin
  117.             cursor(24,count);
  118.             write(chr(205))
  119.           end;
  120.         cursor(24,80);
  121.         write(chr(188))
  122.     end;
  123.