home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / WHEELS.ZIP / READTHIS.NOW < prev    next >
Encoding:
Text File  |  1984-12-20  |  29.6 KB  |  572 lines

  1.  
  2.  
  3.                            T U R B O   W H E E L S
  4.           
  5.                                version 1.00
  6.           
  7.                       Copyright 1984 by Neil J. Rubenking
  8.           
  9.  
  10.                     
  11.           This disk contains quite a few procedures and functions that
  12.           
  13.      make TURBO Pascal easier to use.  Why re-invent the wheel when
  14.           
  15.      you can get TURBO WHEELS?  I am releasing it for distribution in
  16.           
  17.      the User Group/Bulletin Board network subject to the following
  18.           
  19.      stipulations:
  20.           
  21.  
  22.                     
  23.      1)  Anyone may get a copy of these files for examina-
  24.           
  25.      tion, either through their local Users Group or
  26.           
  27.      Bulletin Board, or by sending me a blank, DOUBLE-sided
  28.           
  29.      diskette and a prepaid, self-addressed diskette
  30.           
  31.      mailer.  Regardless of how the disk is obtained, anyone
  32.           
  33.      who actually finds the contents USEFUL should send me
  34.           
  35.      $10, so I can continue writing and releasing software
  36.           
  37.      in this User-Supported fashion.  Send $10 to:
  38.           
  39.  
  40.                     
  41.                Neil J. Rubenking
  42.           
  43.                300 Page St.
  44.           
  45.                San Francisco, CA  94102
  46.           
  47.  
  48.           
  49.      2)  I retain all rights to the SOURCE code.  Recipients
  50.           
  51.      of the procedures may freely $INCLUDE them in compiled
  52.           
  53.      programs, but may not release the SOURCE.
  54.           
  55.  
  56.                     
  57.      3)  Clubs may freely copy and distribute the disk for a
  58.           
  59.      nominal fee, not to exceed $8.
  60.           
  61.  
  62.           
  63.           With the legalities aside, I hope you find these procedures
  64.           
  65.      useful in your programs.  Each has at least one "driver" program,
  66.           
  67.      to illustrate its actual use.  If you are new to the concept of
  68.           
  69.      $INCLUDEing pre-written code in your TURBO Pascal programs, study
  70.           
  71.      the drivers.  There are also several minor applications/utilities
  72.           
  73.      constructed using 8 or 10 of the handy procedures.  A listing and
  74.           
  75.      description of the procedures follows.
  76.           
  77.  
  78.           
  79.           A keen observer might correctly deduce the following from
  80.           
  81.      the type of files I have put on this disk.
  82.           
  83.           1) I don't have a Color/Graphics display
  84.           
  85.           2) I don't do much in math and scientific programming
  86.           
  87.      3) I do write programs that involve creating and manipu-
  88.           
  89.      lating disk files.
  90.           
  91.      4) I do like my programs to look and sound good.
  92.           
  93.  
  94.           
  95.           You may have noticed other disks of TURBO files on the
  96.           
  97.      market.  One that I have found useful is just called "Procedures
  98.           
  99.      and Functions for TURBO Pascal", from:
  100.           
  101.                The Success Press
  102.           
  103.                P.O. Box 2795
  104.           
  105.                Des Plaines, IL
  106.           
  107.      Send Bill Todd $20 to receive these procedures.  A list of
  108.           
  109.      them is on this disk as "SUCCESS.DOC".
  110.           
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.                                                 TURBO WHEELS   page 2
  125.  
  126.  
  127.           
  128.  
  129.      *** SETTING UP THE DISK ***
  130.           
  131.  
  132.           Format a blank diskette with the /S option, to make it a
  133.           
  134.      "bootable" DOS disk.  Copy COMMAND.COM onto it, too.  Copy all
  135.           
  136.      the files from this diskette onto the new diskette, and finally
  137.           
  138.      copy the files TURBO.COM and TURBO.MSG from the TURBO Pascal disk.
  139.           
  140.      Now your TURBO is a more powerful development tool -- it has WHEELS!
  141.               development tool -- it has WHEELS!
  142.           
  143.  
  144.           
  145.  
  146.           
  147.      *** FILES ON THIS DISK ***
  148.           
  149.  
  150.           The file "README.###" is a list of all the files, with a
  151.           
  152.      one-line description of each for quick reference.  The files for
  153.           
  154.      INCLUsion in your programs have the extension .LIB or .TYP.
  155.           
  156.      Almost every .LIB file has a short program to illustrate its
  157.           
  158.      action (often called a "driver").  The drivers have the same name
  159.           
  160.      as their .LIB file, but the extension is .PAS.  There are several
  161.           
  162.      utility application programs that use 8 or 10 .LIB files, and a
  163.           
  164.      few data files (extension .DAT).  Now on to the descriptions of
  165.           
  166.      the individual files.
  167.           
  168.  
  169.           
  170.      *** TYPE DECLARATION FILES ***
  171.           
  172.           Most of the files on this disk use variables of type REGPACK
  173.           
  174.      (for REGister PACK) or FILENAME_TYPE.  The description at the top
  175.           
  176.      of the INCLUDE file will indicate if these or any other files
  177.           
  178.      need to also be present.  The reason to NOT write these type
  179.           
  180.      declarations directly into the files that require them is that
  181.           
  182.      TURBO objects to multiple descriptions of the same TYPE.
  183.           
  184.  
  185.           
  186.      FILENAME.TYP contains the definition of "filename_type" as a
  187.           
  188.           string of up to 64 characters.
  189.           
  190.  
  191.           
  192.      REGPACK.TYP describes the type of variable required as input by
  193.           
  194.           TURBO's procedures INTR and MSDOS.  You do not need to
  195.           
  196.           understand these to use them!  (But if you DO, you can do a
  197.           
  198.           lot!)
  199.           
  200.  
  201.           
  202.      SCREENS.TYP is the declaration of variable type SCREEN, which is
  203.           
  204.           exactly the same "shape" as the (text) video display
  205.           
  206.           memory.  Using variables of this TYPE, you can easily do
  207.           
  208.           direct screen manipulation.
  209.           
  210.  
  211.           
  212.      ERRMESSG.LIB is another file that is required by quite a few
  213.           
  214.           others.  It contains the function MESSAGE which receives as
  215.           
  216.           input a one-byte error code (output of a DOS function) and
  217.           
  218.           returns the "translation" of that code, as specified in the
  219.           
  220.           DOS 2.0 manual.
  221.           
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.                                                 TURBO WHEELS   page 3
  237.  
  238.           
  239.      *** DOS 2.0 FILE HANDLING ***
  240.           
  241.  
  242.           
  243.           TURBO's file handling procedures do NOT work with subdirec-
  244.           
  245.      tories, as you may have found out.  The following procedures are
  246.           
  247.      implementations of the DOS 2.0 procedures--all the ordinary ones
  248.           
  249.      and some new ones, too.
  250.           
  251.  
  252.           
  253.      EXTENDIO.DAT is an exact description of the parameters passed to
  254.           
  255.           and from these new IO functions.  Until you are used to
  256.           
  257.           using them, you may want to actually insert this document
  258.           
  259.           into your source for reference (or refer to it using
  260.           
  261.           SIDEKICK!).
  262.           
  263.  
  264.           
  265.      EXTENDIO.LIB, for EXTENDed Input/Output contains 2.0 versions of
  266.           
  267.           Reset, Rewrite, Close, Read, Write, Seek, and Erase.  Each
  268.           
  269.           new procedure has the same name as the one it replaces,
  270.           
  271.           preceded by an X (Xreset, Xclose, etc.).  Any time you use
  272.           
  273.           these Extended IO procedures, you will also have to $INCLUDE
  274.           
  275.           the TYPE files REGPACK.TYP and FILENAME.TYP, and the file
  276.           
  277.           ERRMESSG.LIB--all of these procedures return a one-byte
  278.           
  279.           error code if anything goes wrong, and ERRMESSG.LIB lets you
  280.           
  281.           interpret the error by saying "writeLn(message(error))".
  282.           
  283.                In the DOS 2.0 mode, instead of a File Variable (a
  284.           
  285.           variable of TYPE "file of something") you will use an
  286.           
  287.           INTEGER File Handle.  XReset and XRewrite receive a full-
  288.           
  289.           path filename (up to 64 characters) and return the file
  290.           
  291.           handle, which you will use for all further references to the
  292.           
  293.           file.  XClose receives just the file handle (any open file
  294.           
  295.           has a handle), and XErase receives just the path/filename.
  296.           
  297.                Since DOS 2.0 files are effectively just files of
  298.           
  299.           bytes, the XRead and XWrite operations work rather diffe-
  300.           
  301.           rently from their forebears.  You pass the File Handle, the
  302.           
  303.           variable to/from which data is to be read/written, and the
  304.           
  305.           SIZE of that variable (easily obtained with TURBO's SizeOf
  306.           
  307.           function).  If the variable is a 1K array, then 1K will be
  308.           
  309.           read into it (or written from it).  The Size-passing is
  310.           
  311.           necessary.  Without it, you would have to write a new XRead
  312.           
  313.           and XWrite for each type of variable!
  314.           
  315.                XSeek is a bit complicated.  You pass the File Handle
  316.           
  317.           (as usual), the Size of the records in your file, and the
  318.           
  319.           point from which you want to start your XSeek (Beginning,
  320.           
  321.           End, or Current position), and you get back the new current
  322.           
  323.           position.  Even if you don't want the new current position
  324.           
  325.           (e.g., you just wanted to set the file pointer back to the
  326.           
  327.           beginning, or all the way to the end for APPEND), you still
  328.           
  329.           have to provide a dummy variable for it.
  330.           
  331.                For very detailed descriptions of the parameters to
  332.           
  333.           pass to and from these EXTENDed Input Output operations, see
  334.           
  335.           EXTENDIO.DAT.
  336.           
  337.  
  338.           
  339.      MOVEFILE.LIB might well be called "XRename", because it does
  340.           
  341.           serve to rename files on any path.  However, the Renaming
  342.           
  343.           extends to the full path--you can MOVE a file to a different
  344.           
  345.           subdirectory simply by changing its path.  You pass the old
  346.           
  347.           path and the new path, and receive the usual one-byte error
  348.           
  349.           code if anything goes wrong.
  350.           
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.                                                 TURBO WHEELS   page 4
  360.  
  361.           
  362.      GETFILE.LIB contains two procedures, Find_First and Find_Next.
  363.           
  364.           Find_First serves to find the first occurrence of a file
  365.           
  366.           matching the template you supply (using the standard DOS
  367.           
  368.           wildcard characters, ? for any character and * for anything
  369.           
  370.           at all, AND using full-path filenames).  You also specify
  371.           
  372.           the File Attribute--you can GET files that are Read-Only,
  373.           
  374.           Hidden, System, Volume label, or Directory.  Find_First sets
  375.           
  376.           the DTA (Disk Transfer Area) to a buffer supplied by you and
  377.           
  378.           either puts information about the file in the buffer, or
  379.           
  380.           returns an error code.  Once you have Found the First
  381.           
  382.           occurrence, you repeat Find_Next until you don't find any
  383.           
  384.           more.
  385.           
  386.  
  387.           
  388.      ALLFILES.LIB is a very handy procedure to include in any program
  389.           
  390.           that makes use of other files (e.g., a word processor,
  391.           
  392.           picture editor, music maker, &c.).  You pass the top left
  393.           
  394.           and bottom right coordinates of an available screen area,
  395.           
  396.           and a template for the files you want, and ALLFILES takes
  397.           
  398.           over.  It opens and frames a window at the coordinates and
  399.           
  400.           displays all matching files.  The user positions a pointer
  401.           
  402.           at the required file and presses <return> to select it.  If
  403.           
  404.           there are more files than will fit in the window, the user
  405.           
  406.           has the choice of selecting a visible file or going on to
  407.           
  408.           another window full.  Once a file is selected, ALLFILES
  409.           
  410.           erases its window and returns the filename.  Note that your
  411.           
  412.           program will not have to test for existence of the file
  413.           
  414.           before trying to open it--you KNOW it exists.
  415.           
  416.                For an extremely classy use of ALLFILES, you may want
  417.           
  418.          to use the technique described in SCREENS.LIB to save
  419.           
  420.          whatever is on the screen before calling ALLFILES and pop it
  421.           
  422.          right back when ALLFILES is done.
  423.           
  424.  
  425.           
  426.      MKRMDIR.LIB brings the DOS MKDIR and RMDIR (MaKe DIRectory and
  427.           
  428.          DIRectory) into TURBO.  If you want to do it, you can.
  429.           
  430.  
  431.           
  432.      FILEATTR.LIB lets you change the File Attribute byte (Read-Only,
  433.           
  434.           Hidden, System, Archive) of a file on any path.
  435.           
  436.  
  437.           
  438.      GTSETDIR.LIB lets you GET or SET the current subDIRectory.  It
  439.           
  440.           may well be used in conjunction with GETSTDD below.
  441.           
  442.  
  443.           
  444.  
  445.           
  446. *** DOS 1 OR 2 FILE HANDLING ***
  447.           
  448.  
  449.           
  450.     GETSETDD.LIB uses DOS function calls to GET or SET the Default
  451.           
  452.          Drive.
  453.           
  454.  
  455.           
  456.      EXISTFIL.LIB checks for the existence of a file.  You pass it the
  457.           
  458.          "old-fashioned" filename (no subdirectory!) and it returns
  459.           
  460.          true or false.  (The EXTENDed I/O operations do not directly
  461.           
  462.          crash your program if the file requested does not exist, so
  463.           
  464.          they don't need a corresponding 2.0 function.)
  465.           
  466.  
  467.           
  468. *** DISK READ/WRITE PROCEDURES ***
  469.           
  470.  
  471.           
  472.      DISKTYP.LIB checks the type of disk (single/double sided, 8/9
  473.           
  474.           sectors per track).  You pass the drive letter, and it
  475.           
  476.           returns the number of K of disk space (an integer, 160, 180,
  477.           
  478.           320, or 360), 0 if an invalid drive was specified, or 1 for
  479.           
  480.           a non-standard format.
  481.  
  482.  
  483.  
  484.  
  485.           
  486.                                                 TURBO WHEELS   page 5
  487.  
  488.      GETSECTR.LIB conducts I/O between a specific sector on the disk
  489.           
  490.           and a buffer variable declared by you.  You specify [R]ead
  491.           
  492.           or [W]rite and the side, sector, and track, and the buffer
  493.           
  494.           variable is either read from or written to the disk.  As
  495.           
  496.           usual, a one-byte error code is returned.  On the advice of
  497.           
  498.           the DOS Manual, GetSector makes three tries at reading the
  499.           
  500.           sector before it gives up and returns an error code.
  501.           
  502.                The buffer variable must be 512 bytes, but you can
  503.           
  504.           choose to arrange these bytes in convenient ways.  For
  505.           
  506.           example, in the application LABEL.PAS, the buffer is an
  507.           
  508.           array[1..16] of type directory_entry, and reading a direc-
  509.           
  510.           tory sector gives you instant access to its 16 entries.
  511.           
  512.           NOTE that, unlike most of the procedures on this disk,
  513.           
  514.           GETSECTR does not have a driver with the same name.  The
  515.           
  516.           sample programs that use GETSECTR are LABEL and DISKMOD.
  517.           
  518.  
  519.           
  520.      LABEL.PAS uses DISKTYP.LIB, GETSECTR.LIB, and several other files
  521.           
  522.           to read and write the volume label.  It first seeks an
  523.           
  524.           existing label in the directory (NOTE:  the volume label is
  525.           
  526.           just a special kind of directory entry.)  If found, you may
  527.           
  528.           change it.  If not found, the first directory slot that is
  529.           
  530.           either never-used or erased is converted to a label of your
  531.           
  532.           choice.  The current date and time are properly included
  533.           
  534.           with your volume label, but the bit-manipulation that does
  535.           
  536.           that is horrifying!
  537.           
  538.  
  539.           
  540.      DISKMOD.PAS is a working Disk Sector Viewing and Modifying
  541.           
  542.           program, based on DISKMODF.BAS by John VanderGrift.  You
  543.           
  544.           select a sector and get it displayed both in (filtered)
  545.           
  546.           ASCII and hex.  You can modify the displayed sector by
  547.           
  548.           simply typing in new values, but you must specifically ask
  549.           
  550.           to record the modifications.  Pressing PgDn and PgUp move to
  551.           
  552.           the next or previous sectors--the procedures "increment" and
  553.           
  554.           "decrement" embody the DOS sector numbering scheme.
  555.           
  556.  
  557.           
  558. *** VIDEO DISPLAY PROCEDURES ***
  559.           
  560.  
  561.           
  562.      CURSOR.LIB contains the procedure Cursor_Control.  You set the
  563.           
  564.           top and bottom "scan lines" for the cursor.  You'll want to
  565.           
  566.           $INCLUDE the file MONITOR.LIB and ask to CheckColor before
  567.           
  568.           you change the cursor around, because the Monochrome cursor
  569.           
  570.           has 14 scan lines (numbered 0 at the top to 13 at the
  571.           
  572.           bottom) while the Color cursor is only 7 high (0 to 6).  The
  573.           
  574.           normal cursor is 12,13 in Mono and 6,7 in color.  In
  575.           
  576.           Monochrome, you can get a two-part cursor by setting the top
  577.           
  578.           line below the bottom.  NOTE that you can "kill" the cursor
  579.           
  580.           by setting the top line to 48, bottom to 0.
  581.           
  582.  
  583.           
  584.      MONITOR.LIB sets the values of the variables COLOR (boolean) and
  585.           
  586.           ScreenSeg (integer) for use by other procedures.  Besides
  587.           
  588.           $INCLUDEing it, you must invoke CheckColor at the beginning
  589.           
  590.           of your program.
  591.           
  592.  
  593.           
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.                                                 TURBO WHEELS   page 6
  606.  
  607.      SCREEN.LIB contains procedures to read and write the character
  608.           
  609.           and screen attribute (i.e., COLOR) at any location on the
  610.           
  611.           screen IN TEXT MODE.  The driver, SCREEN.PAS, is a little
  612.           
  613.           video game showing how handy these procedures can be.
  614.           
  615.  
  616.           
  617.      POPSCREN.LIB is a slightly frivolous use of the SCREEN data type,
  618.           
  619.           declared in SCREENS.TYP.  Several SCREEN variables are
  620.           
  621.           created and rapidly switched to the display.  A pop-up menu
  622.           
  623.           example is included.
  624.           
  625.  
  626.           
  627.      POPSCREN.DAT is a screen file used by POPSCREN.LIB
  628.           
  629.  
  630.           
  631.      GRFXTABL.LIB defines a table of ROMEntries "on top" of the ROM
  632.           
  633.           graphics table, giving us (read-only) access to the dot
  634.           
  635.           patterns used to create the monochrome characters.
  636.           
  637.  
  638.           
  639.      TITLES.LIB contains the procedure MakeTitle.  Given a title up to
  640.           
  641.           ten characters and a starting row, it makes a big title on
  642.           
  643.           the screen by using the character patterns from GRFXTABL.
  644.           
  645.  
  646.           
  647.      WINDOWS.LIB offers another approach to using windows.  The
  648.           
  649.           variable type "corners" is declared to be an array[1..4] of
  650.           
  651.           byte.  Windows that your program will use are set at the
  652.           
  653.           beginning of the program by declaring CONSTants of type
  654.           
  655.           "corners".  The procedures DoWindow and DoFrame operate on
  656.           
  657.           input of type "corners".  If, later in the development of
  658.           
  659.           your program, you want to move the windows around, you just
  660.           
  661.           change the CONSTant declaration at the top.
  662.           
  663.  
  664.           
  665. *** kEYBOARD PROCEDURES ***
  666.           
  667.  
  668.           
  669.      GETKEYS.LIB is one of my favorites.  The line "GetKeys(C,D)"
  670.           
  671.           causes your program to wait for a keystroke and, if it is an
  672.           
  673.           "ordinary" keystroke, returns the character in C and chr(0)
  674.           
  675.           in D.  If, however, it was a "special" keystroke (arrow key,
  676.           
  677.           function key), it returns chr(27) in C and a code character
  678.           
  679.           in D.  The file KEYCHART.DAT tabulates these special codes.
  680.           
  681.  
  682.           
  683.      KEYBOARD.LIB is another approach to trapping keystrokes.  It uses
  684.           
  685.           the keyboard BIOS interrupt $16 to get the scan code and
  686.           
  687.           ASCII code of any key pressed.  The file SCANCODE.DAT is a
  688.           
  689.           chart of keyboard codes, along with a table of "extended"
  690.           
  691.           scan codes.
  692.           
  693.  
  694.           
  695.      FANCYKEY.LIB goes KEYBOARD one better.  It returns a phrase
  696.           
  697.           describing the key pressed, such as "Alt-A", "Shift-F1",
  698.           
  699.           "Back Tab", etc.
  700.           
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.                                                 TURBO WHEELS   page 7
  719.  
  720.           
  721.      NEWINT9.LIB is an ambitious procedure.  The keyboard's output is
  722.           
  723.           generally handled by Interrupt $9, which is called BY THE
  724.           
  725.           KEYBOARD whenever a key is struck.  This interrupt checks
  726.           
  727.           for shift states, filters out key release codes, and
  728.           
  729.           produces the "typematic" effect, whereby a key held down
  730.           
  731.           repeats.  Certain applications might be better off WITHOUT
  732.           
  733.           the typematic and WITH access to the key release codes -- my
  734.           
  735.           own PIANO MAN program comes to mind.  I required a note to
  736.           
  737.           sound ONCE when a key was pressed and stop when that key was
  738.           
  739.           released.  Games might requires this feature.  If you do use
  740.           
  741.           it, your program should:
  742.           
  743.                1) invoke procedure SetUpInt, which creates the new
  744.           
  745.                interrupt.
  746.           
  747.                2) invoke NewInt, which saves the normal interrupt
  748.           
  749.                vector and replaces it with directions to the new one.
  750.           
  751.                3) MOST IMPORTANT, before the program ends, invoke
  752.           
  753.                OldInt to restore the normal interrupt.  If you don't
  754.           
  755.                do this, or if your program crashes before it can do
  756.           
  757.                it, you cannot communicate through your keyboard, and
  758.           
  759.                you have to turn the PC off and on again.
  760.           
  761.                Used with care, NEWINT9 can satisfy a real need.
  762.           
  763.  
  764.           
  765. *** GRAPHICS ***
  766.           
  767.      (Let me note that I myself do not have a Color/Graphics adapter,
  768.           
  769.      so I haven't had much opportunity to write for one.  However, the
  770.           
  771.      mighty BORLAND has a Graphics tool set for their usual price of
  772.           
  773.      $50.)
  774.           
  775.  
  776.           
  777.      CIRCLE.LIB draws a circle on your screen.  You specify six
  778.           
  779.           parameters: H, K and R are the X and Y coordinates of the
  780.           
  781.           circle's center and its radius.  "Res" is the resolution --
  782.           
  783.           the number of dots used to draw the circle is proportional
  784.           
  785.           to Res, as is the time required to draw it.  "Aspect" is a
  786.           
  787.           real value that describes the circle's "roundness" -- adjust
  788.           
  789.           to a perfect circle, or change it to get an ellipse.
  790.           
  791.           Finally,  "color" can be 1, 2, or 3 if you are in the
  792.           
  793.           Graphics mode that supports four colors.  (See the descrip-
  794.           
  795.           tion of graphics modes in the TURBO 2.0 manual).
  796.           
  797.  
  798.           
  799.      RECTANGL.LIB naturally draws a rectangle on the screen.  You tell
  800.           
  801.           it the X and Y coordinates of the upper left and lower right
  802.           
  803.           corners, the color (1, 2, or 3 if appropriate), and 1 for a
  804.           
  805.           filled rectangle, 0 for hollow.
  806.           
  807.  
  808.           
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.                                                 TURBO WHEELS   page 8
  830.  
  831.           
  832. *** MISCELLANEOUS ROUTINES ***
  833.           
  834.  
  835.           
  836.      EQUIPMNT.LIB uses Interrupt $11 to check the equipment attached
  837.           
  838.           to your PC.  It reports on number of printers, RS232 ports,
  839.           
  840.           game ports, and diskette drives, the initial video mode, or
  841.           
  842.           the amount of RAM on the motherboard.
  843.           
  844.  
  845.           
  846.      GETINTGR.LIB is intended to save you the embarrassment of having
  847.           
  848.           your program crash because someone made an invalid entry for
  849.           
  850.           an integer.  At the same time, it makes sure that the entry
  851.           
  852.           is within a ranges you specify.  Non-numeric keystrokes are
  853.           
  854.           ignored, BackSpace works, and the function does not give up
  855.           
  856.           until a valid integer is entered.
  857.           
  858.  
  859.           
  860.      GETFREE.LIB is another face-saver.  It gets the amount of free
  861.           
  862.           space on the current disk.  That way, your programs can
  863.           
  864.           check for space and give alternatives if there's not enough,
  865.           
  866.           rather than ignominiously crashing.
  867.           
  868.  
  869.           
  870.      HEXFUNCT.LIB contains the procedure HEX which receives an integer
  871.           
  872.           and returns a 5-character hex string (e.g., $BF00).  The hex
  873.           
  874.           string always refers to a positive number -- TURBO's integer
  875.           
  876.           variable type uses its highest bit to indicate sign, thus
  877.           
  878.           restricting the integer range to -32,768 to +32,767.  Hex
  879.           
  880.           equivalents are calculated by considering negative integers
  881.           
  882.           as offsets down from $10000 (decimal 65,536).  Thus, HEX(-1)
  883.           
  884.           = $FFFF.  (NOTE:  the TURBO manual says that the integer
  885.           
  886.           range is as stated above, but in my experience, it is not
  887.           
  888.           possible to enter -32,768. )
  889.           
  890.  
  891.           
  892.      KAVAIL.LIB returns the number of KiloBytes of memory available.
  893.           
  894.           It takes into account the MemAvail function's quirk of
  895.           
  896.           reporting amounts greater than 32,767 as negative numbers.
  897.           
  898.  
  899.           
  900.      NOSOUND.PAS does nothing but shut off the sound, if one of your
  901.           
  902.           programs crashes with sound on.  When you need it, you NEED
  903.           
  904.           it!
  905.           
  906.  
  907.           
  908.      PARAMETR.LIB contains the function GetParameter, which returns a
  909.           
  910.           string of up to 80 characters consisting of whatever was
  911.           
  912.           entered on the command line after the name of the program.
  913.           
  914.           This O N L Y works in COMPILED programs.
  915.           
  916.  
  917.           
  918.      QUEUE.LIB is a generic Queue data structure.  One of Pascal's
  919.           
  920.           great advantages over BASIC is its implementation of
  921.           
  922.           Pointer^ variables and dynamic lists.  By keeping your data
  923.           
  924.           in a linked list instead of an array, you can dedicate only
  925.           
  926.           as much memory as you need, up to all the memory the system
  927.           
  928.           has.  If you test for memory available with KAVAIL before
  929.           
  930.           you add each item to the list, you can safely expand to the
  931.           
  932.           maximum memory of different systems without crashing for
  933.           
  934.           lack of memory.
  935.           
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.                                                 TURBO WHEELS   page 9
  949.  
  950.           
  951.      REBOOT.LIB does just what it says.  The "warm" reboot produced by
  952.           
  953.           Interrupt $19 does NOT clear the RAM, so, for example,
  954.           
  955.           SIDEKICK will stay resident.  The programs LESSRAM and
  956.           
  957.           NUMDISKS use REBOOT to cause the PC to act as if its
  958.           
  959.           internal DIP switches had been reset to indicate a different
  960.           
  961.           number of disk drives or different amount of RAM.  One note
  962.           
  963.           of caution -- There seems to be some interference in this
  964.           
  965.           reboot process from certain device drivers in the CONFIG.SYS
  966.           
  967.           file.  The symptom is that the driver (e.g., your hard disk
  968.           
  969.           driver, or a RAMdisk) installs itself and then the A: drive
  970.           
  971.           spins . . . and spins . . . and that's it.  To avoid this
  972.           
  973.           problem, you could always rename CONFIG.SYS to something
  974.           
  975.           else temporarily.  IF you can figure out why this happens
  976.           
  977.           and how to get around it, PLEASE let me know!
  978.           
  979.  
  980.           
  981.      LESSRAM.COM is handy if you always write your programs on your
  982.           
  983.           souped-up 640K SuperPC and want to test whether it will
  984.           
  985.           actually run on a lesser machine with, say 96K.  You COULD
  986.           
  987.           open the box and change the switches, but it's a lot easier
  988.           
  989.           just to go back to DOS and type LESSRAM 96.
  990.           
  991.  
  992.           
  993.      NUMDISKS's raison d'etre is the current confusion of method among
  994.          RAMdisks.  Some require that the internal switches be set to
  995.           
  996.           the total number of physical drives and RAMdisks, while
  997.           
  998.           others insist that the switches show physical drives only.
  999.           
  1000.           If you need to switch around, you can enter NUMDISKS
  1001.           
  1002.           <number>.  If you put NUMDISKS in a batch file, be sure to
  1003.           
  1004.           add an "n" (or "N") to the number so the program won't pause
  1005.           
  1006.           for a keypress before rebooting.
  1007.           
  1008.  
  1009.           
  1010.      SAFEWRIT.LIB is one way to get around the fact that you cannot
  1011.           
  1012.           WRITE certain characters to the screen -- they get inter-
  1013.           
  1014.           preted as Control Characters and warp your display.
  1015.           
  1016.           Procedure SafeWrite catches these characters and replaces
  1017.           
  1018.           them with a related character in Low Video.  Note that
  1019.           
  1020.           another approach would be to use the procedures in
  1021.           
  1022.           SCREEN.LIB to send characters directly to the screen
  1023.           
  1024.           memory.  Using this latter method, you can put ANY character
  1025.           
  1026.           on the screen.
  1027.           
  1028.  
  1029.           
  1030.