home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / menu / overdriv / topascii.doc < prev    next >
Encoding:
Text File  |  1988-04-24  |  75.1 KB  |  1,864 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.                                       TOP
  17.                             Turbo Overdrive Package
  18.  
  19.                         A Collection of Turbo Pascal 4.0
  20.                             Procedures and Functions
  21.  
  22.                                   Version 1.0
  23.  
  24.                    (C) Copyright 1988 by Nescatunga Software
  25.                               All Rights Reserved
  26.  
  27.  
  28.  
  29.  
  30.  
  31.                             TURBO OVERDRIVE PACKAGE
  32.                                TABLE OF CONTENTS
  33.  
  34.           Introduction
  35.             What is TOP..............................................4
  36.             License and Registration.................................5
  37.             Registration Fee.........................................6
  38.             What's on the TOP Disk...................................6
  39.             How to use TOP Units.....................................7
  40.           Unit IOSTUFF
  41.             MoveToScreen.............................................9
  42.             MoveFromScreen...........................................9
  43.             SaveScreen..............................................11
  44.             RestoreScreen...........................................11
  45.             SavePartScreen..........................................13
  46.             RestorePartScreen.......................................13
  47.             SetColor................................................15
  48.             WriteSt.................................................17
  49.             WriteCh.................................................18
  50.             WriteManyCh.............................................19
  51.             FillScr.................................................20
  52.             ReadFromScr.............................................21
  53.             GetCh...................................................22
  54.             Border..................................................23
  55.             SBorder.................................................23
  56.             Beep....................................................23
  57.             LineCursor..............................................24
  58.             BigCursor...............................................24
  59.             HideCursor..............................................25
  60.             ShowCursor..............................................25
  61.           Unit DIR
  62.             ShowDir.................................................26
  63.             ChangePath..............................................27
  64.             PickFile................................................28
  65.           Unit GETCOLOR
  66.             ChooseColor.............................................29
  67.             SetChooseColor..........................................29
  68.           Unit POPASCII
  69.             ChooseASCII.............................................30
  70.             SetChooseASCII..........................................30
  71.           Unit GETLINE
  72.             GetStr..................................................31
  73.           Unit DRAWBOX
  74.             Box.....................................................33
  75.           Unit MENUBOX
  76.             SetMenuBox..............................................34
  77.             PickMenuBox.............................................36
  78.             ResetBox................................................38
  79.  
  80.                             TURBO OVERDRIVE PACKAGE
  81.                          TABLE OF CONTENTS (Continued)
  82.  
  83.           Unit MENU123
  84.             SetMenu123..............................................39
  85.             PickMenu123.............................................40
  86.             Reset123................................................42
  87.           Unit MENUPULL
  88.             SetMain.................................................43
  89.             SetSub..................................................43
  90.             PickMain................................................46
  91.             PickSub.................................................46
  92.             RestoreWorkScreen.......................................48
  93.             SaveWorkScreen..........................................48
  94.             WriteMain...............................................50
  95.             WritSub.................................................50
  96.  
  97.  
  98.  
  99.           ============================================================
  100.           TURBO OVERDRIVE PACKAGE - INTRODUCTION               Page 4
  101.           ============================================================
  102.  
  103.           WHAT IS TOP
  104.  
  105.           The Turbo Overdrive Package (TOP) is a collection of over 40
  106.           procedures and functions that you can incorporate in your
  107.           own Turbo Pascal 4.0 programs for the IBM and IBM-Compatible
  108.           PC.  With the TOP routines you can:
  109.  
  110.               Pop-up a color selection smorgasbord
  111.               Pop-up an ASCII character selector
  112.               Save and restore screens
  113.               Hide the cursor and change its shape
  114.               Edit and read a string from the screen
  115.               Draw boxes with the arrow keys
  116.               Install Pop-up box menus
  117.               Generate Lotus-123 style menus
  118.               Use sophisticated two-level pull-down menus
  119.  
  120.           In addition to these unique functions TOP also brings a
  121.           different philosophy.  TOP is written almost exclusively in
  122.           standard Turbo Pascal with as little inline machine code as
  123.           is possible.  And TOP is modular so that you don't have to
  124.           use the entire package if you only like one piece.
  125.  
  126.           Many other Turbo Pascal subroutine packages suffer from two
  127.           shortcomings.  First, much or all of the code of these
  128.           packages is written in assembler and translated to Turbo
  129.           Pascal inline machine code.  The big problem with inline
  130.           code is that if you're not an expert on the Intel
  131.           microprocessor architecture then there are parts of your
  132.           program you don't understand.  This puts you in the awkward
  133.           position of not being able to change or update your program
  134.           when you need to.  For example when Borland brought out
  135.           version 4.0 of Turbo Pascal, many inline routines written
  136.           for 3.0 wouldn't work.
  137.  
  138.           Of course there is a place for machine code because it is
  139.           fast and allows you to go beyond the limits of Turbo Pascal.
  140.           However with release 4.0 Borland has remedied the slow
  141.           screen IO and most of the other weak areas in the compiler
  142.           so that only a few functions now absolutely require inline
  143.           code.
  144.  
  145.           To reduce the inline-code-problem, the Turbo Overdrive
  146.           Package contains only two short inline routines (which move
  147.           chunks of data to and from the screen without generating
  148.           snow on the CGA).  A few of the low level routines in
  149.           IOSTUFF take advantage of the services provided in the
  150.           computer's BIOS.  But all other code is standard Turbo
  151.           Pascal, generously commented and written as simply and
  152.           ============================================================
  153.           TURBO OVERDRIVE PACKAGE - INTRODUCTION               Page 5
  154.           ============================================================
  155.  
  156.           directly as possible so that you can understand it and
  157.           change it.
  158.  
  159.           The second problem with some other Pascal packages is that
  160.           the higher order functions are so interrelated with the low
  161.           order functions that they force you to include a bunch of
  162.           code you don't necessarily want to use.  I call this the
  163.           all-or-nothing effect.  To use these packages it seems you
  164.           have to subordinate your own way of doing things to theirs.
  165.  
  166.           TOP's answer to the all-or-nothing problem is to make each
  167.           unit as self contained as possible.  There's no complex
  168.           interrelationship between the various Units.  So, for
  169.           example, if you decide you want to use the pull-down menus
  170.           in TOP you need only two Units: MENUPULL and IOSTUFF.  Unit
  171.           IOSTUFF, which is small, contains the input/output routines
  172.           used by all other TOP Units.
  173.  
  174.           LICENSE AND REGISTRATION
  175.  
  176.           The programs in the Turbo Overdrive Package are not public
  177.           domain.  Rather they are being distributed under the User
  178.           Supported Software concept.  TOP has been copyrighted by the
  179.           author who reserves all rights.  You are granted a limited
  180.           license to use and copy the program according to the terms
  181.           below.
  182.  
  183.           As an individual you may freely copy the TOP disk for your
  184.           evaluation and the evaluation of others so long as no price
  185.           or other consideration is charged.
  186.  
  187.           Shareware distribution organizations may copy the TOP
  188.           diskette and share it with their members so long as no price
  189.           is charged other than a reasonable distribution fee not to
  190.           exceed the cost of a diskette and handling.
  191.  
  192.           The TOP Units, associated demonstration files and
  193.           documentation must always be distributed together.  The
  194.           contents of the TOP disk including the documentation may not
  195.           be modified.  You may not reproduce the program manual in
  196.           any way.
  197.  
  198.           If you are a registered user, you may include the TOP
  199.           routines in any programs you write.  If TOP source code is
  200.           included in any program you sell or distribute please credit
  201.           the Turbo Overdrive Package and Nescatunga Software.
  202.  
  203.           Schools are granted permission by the author to copy TOP as
  204.           many times as needed and use TOP routines freely so long as
  205.           the registration fee has been paid for each building the
  206.           ============================================================
  207.           TURBO OVERDRIVE PACKAGE - INTRODUCTION               Page 6
  208.           ============================================================
  209.  
  210.           program will be used in.
  211.  
  212.           REGISTRATION FEE
  213.  
  214.           If you find the TOP routines useful we ask that you register
  215.           as a user by sending $20.00 to:
  216.               
  217.               Nescatunga Software
  218.               Box 5942
  219.               Katy, TX 77450
  220.  
  221.           For registering you will receive a printed copy of the TOP
  222.           documentation and a disk with the latest TOP version.  The
  223.           TOP version available from Nescatunga will generally be at
  224.           least one level more current than the version available from
  225.           shareware distributors and bulletin boards.
  226.  
  227.           TOP represents many hours of work.  We can continue to
  228.           enhance TOP and develop other shareware products ONLY if you
  229.           support the product and the shareware concept.
  230.  
  231.           WHAT'S ON THE TOP DISK
  232.  
  233.           The TOP disk contains 20 files organized into three
  234.           categories:
  235.  
  236.               The Turbo Overdrive Package Units
  237.  
  238.                   IOSTUFF.PAS    General IO, screen and cursor
  239.                   GETCOLOR.PAS    Pop-up color selection
  240.                   POPASCII.PAS    Pop-up ASCII char. selection
  241.                   GETLINE.PAS    Edited string input
  242.                   DRAWBOX.PAS    Draw boxes with cursor keys
  243.                   MENUBOX.PAS    Pop-up menus
  244.                   MENU123.PAS    Lotus-123 menus
  245.                   MENUPULL.PAS    Two tiered pull-down menus
  246.  
  247.               Demonstration Programs
  248.  
  249.                   IOSTUFF.DEM    Demonstrates Unit IOStuff
  250.                   GETCOLOR.DEM    Demonstrates Unit GetColor
  251.                   POPASCII.DEM    Demonstrates Unit PopASCII
  252.                   GETLINE.DEM    Demonstrates Unit GetLine
  253.                   DRAWBOX.DEM    Demonstrates Unit DrawBox
  254.                   MENUBOX.DEM    Demonstrates Unit MenuBox
  255.                   MENU123.DEM    Demonstrates Unit Menu123
  256.                   MENUPULL.DEM    Demonstrates Unit MenuPull
  257.                   BIGDEMO.DEM    Demonstrates all Units
  258.  
  259.           ============================================================
  260.           TURBO OVERDRIVE PACKAGE - INTRODUCTION               Page 7
  261.           ============================================================
  262.  
  263.               TOP Documentation files
  264.  
  265.                   TOPEPSON.DOC    Epson FX format
  266.                   TOPASCII.DOC    ASCII Format
  267.                   READ.ME        Late breaking news
  268.  
  269.           HOW TO USE TOP UNITS
  270.  
  271.           To utilize a TOP Unit in one of your programs simply include
  272.           a reference to the Unit in the USES clause at the top of
  273.           your program.  For example if in your program MY_PROJECT you
  274.           elect to utilize pop-up menus from TOP's Unit MenuBox then
  275.           include the following statements:
  276.  
  277.               PROGRAM MY_PROJECT;
  278.  
  279.               USES MenuBox;  {you also will likely use unit CRT}
  280.  
  281.               BEGIN
  282.                   { Calls to MenuBox }
  283.                   ...
  284.               END.
  285.  
  286.           Compile and run your program just as you always do.  When
  287.           Turbo Pascal compiles your program it will look for the file
  288.           MenuBox.Pas in order to include its code in your program.
  289.           To make sure Turbo Pascal can find the TOP Units, copy all
  290.           the TOP Unit (*.PAS) files to the same floppy disk or hard
  291.           disk directory as your program. To copy all the TOP Units to
  292.           directory \PAS on drive C:
  293.  
  294.               C:>COPY A:*.PAS C:\PAS
  295.  
  296.           If you don't want to take up unneeded space by copying all
  297.           the TOP *.PAS files then you may selectively copy only the
  298.           Units you need.  If your computer has a hard disk then
  299.           simply put the TOP disk in the A: drive and copy the file(s)
  300.           containing the unit(s) you want to use into the same
  301.           directory or onto the same disk as your Turbo Pascal
  302.           program.
  303.  
  304.           For example if you are working on a program called
  305.           PROJECT.PAS in directory \PAS on drive C: and you want to
  306.           incorporate pop-up menus from TOP's Unit MenuBox then simply
  307.           put the TOP disk in drive A: and copy two files to C:\PAS as
  308.           shown below:
  309.  
  310.                   C:>Copy A:MENUBOX.PAS C:\PAS
  311.                   C:>Copy A:IOSTUFF.PAS C:\PAS
  312.           ============================================================
  313.           TURBO OVERDRIVE PACKAGE - INTRODUCTION               Page 8
  314.           ============================================================
  315.  
  316.  
  317.           If your computer only has floppy disks and you are working
  318.           on a program called PROJECT.PAS thats in the B: drive and
  319.           you want to use the TOP MenuBox Unit then put the TOP disk
  320.           in drive A: and copy the files to the B: drive as shown
  321.           below:
  322.  
  323.                   B:>Copy A:MENUBOX.PAS B:
  324.                   B:>Copy A:IOSTUFF.PAS B:
  325.  
  326.           You must always include file IOSTUFF.PAS even if you are not
  327.           using any of the input/output routines directly because all
  328.           of the other seven TOP Units reference Unit IOSTUFF.  Unit
  329.           DIR also uses Unit GETLINE.
  330.  
  331.  
  332.           ============================================================
  333.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 9
  334.           ============================================================
  335.  
  336.           Unit IOSTUFF contains the low level screen, input/output and
  337.           cursor procedures and functions used by the other main
  338.           units.  Some of these procedures are similar to procedures
  339.           found in other packages but I think you will find these less
  340.           cumbersome to use.
  341.  
  342.           MoveToScreen   -- Move data to CGA video buffer
  343.           MoveFromScreen -- Move data from CGA video buffer
  344.  
  345.           These two procedures move large chunks of data to and from
  346.           the CGA video buffer directly without causing snow.  The
  347.           procedures accomplish this feat by moving the characters
  348.           only while the CRT is in video retrace.
  349.  
  350.           Turbo Pascal 4.0's Write and Writeln procedures have been
  351.           rewritten to use direct video buffer addressing rather than
  352.           BIOS calls.  Turbo Pascal's procedures are now so fast that
  353.           the programmer no longer needs his own direct video buffer
  354.           addressing routines to write on the screen.  There remains a
  355.           need, however, for fast, snow-free moves of portions of or
  356.           all of a screen in order to store or restore the screen's
  357.           contents.
  358.  
  359.           It should be noted that MoveToScreen and MoveFromScreen are
  360.           not string writing routines.  The data moved must be in the
  361.           format used by the video buffer, i.e. pairs of
  362.           character/attribute bytes.  The Type declarations for Unit
  363.           IOSTUFF provide Types Map and Screen to define variables for
  364.           storing video buffer contents.  Variable CS (for Color
  365.           Screen) in IOSTUFF resides at the absolute address of the
  366.           color video buffer ($B800) and thus may be used in any
  367.           program that USES IOSTUFF to refer to the color screen as it
  368.           is in the example below.  Similarly variable MS (for
  369.           Monochrome Screen) resides at the absolute address ($B000)
  370.           of the monochrome video buffer.
  371.  
  372.           CALLING SEQUENCE:
  373.  
  374.           PROCEDURE MoveToScreen(Var Source,Dest; Len: Integer);
  375.           PROCEDURE MoveFromScreen(Var Source,Dest; Len: Integer);
  376.  
  377.           Source : Data which will be moved.
  378.           Dest   : Target location to move data.
  379.           Len    : Length in bytes to be moved.
  380.  
  381.           In MoveFromScreen Source will be the actual color video
  382.           buffer (see variable CS described below).  Conversely, in
  383.           MoveToScreen Dest is the actual color video buffer.
  384.           Remember in setting Len that there are two bytes for each
  385.           character.  So for an entire screen Len would be 4000.
  386.           ============================================================
  387.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 10
  388.           ============================================================
  389.  
  390.  
  391.           EXAMPLES:
  392.  
  393.           To save an entire screen in variable Screenhold and then
  394.           restore the screen:
  395.  
  396.               VAR  ScreenHold : Screen; { See IOSTUFF for Screen }
  397.  
  398.               MoveFromScreen(CS,ScreenHold,4000);
  399.               .
  400.               .
  401.               MoveToScreen(ScreenHold,CS,4000);
  402.  
  403.  
  404.           To save and restore just row 5 of the screen in variable
  405.           OneLine:
  406.  
  407.  
  408.               VAR OneLine : Array[1..80] of Map; {See IOSTUFF for
  409.           Map}
  410.  
  411.               MoveFromScreen(CS[5,1],OneLine,160);
  412.               .
  413.               .
  414.               MoveToScreen(OneLine,CS[5,1],160);
  415.  
  416.           ============================================================
  417.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 11
  418.           ============================================================
  419.  
  420.           SaveScreen   -- Save the current screen image
  421.           RestoreScreen -- Restore a previously saved screen image
  422.  
  423.           These two procedures save and restore screen images.
  424.           SaveScreen will make a copy of the screen just the way it
  425.           looks when SaveScreen is called.  And RestoreScreen will
  426.           bring that saved screen back to the display.
  427.  
  428.           CALLING SEQUENCE:
  429.  
  430.           PROCEDURE SaveScreen(NS:Integer);
  431.           PROCEDURE RestoreScreen(NS:Integer);
  432.  
  433.           NS : Screen number (0 - 5) of saved screen.
  434.  
  435.           Each time SaveScreen is called NS must be supplied to
  436.           identify the screen for later restoration.  As the
  437.           procedures are currently written NS must be in the range 0
  438.           to 5.  With minor modifications however, this limitation
  439.           could easily be increased or decreased.
  440.  
  441.           Screen Number 0 is reserved for use by the SavePartScreen
  442.           and RestorePartScreen procedures described below.  So don't
  443.           use the statement SaveScreen(0); unless you are purposely
  444.           saving a screen image for use by the RestorePartScreen
  445.           procedure described later.
  446.  
  447.           SaveScreen and RestoreScreen have no code to ensure the NS
  448.           you provide is in range.  If your program contains the
  449.           statement SaveScreen(S); and S := 6 the effect will be
  450.           equivalent to an elephant tromping through a flower garden.
  451.           So if your use of the SaveScreen routine is dynamic (you
  452.           don't know how many screens will be saved) SaveScreen and
  453.           RestoreScreen are not the right way to go.
  454.  
  455.           As written, SaveScreen saves the six 4000 byte screen images
  456.           in array ScreenHold in Turbo Pascal's data area.  If your
  457.           program needs all the data area it can get, these screen
  458.           images could easily be stored on the heap using procedures
  459.           New or GetMem (which, incidentally, is also the right way to
  460.           handle the dynamic number of screens problem described
  461.           above).  However, if you can spare the data space and will
  462.           be saving a predetermined number of screens, I think it is
  463.           cleaner and more straightforward to store the screens right
  464.           in the data space as these procedures do.
  465.  
  466.           EXAMPLES:
  467.  
  468.           In this example the programmer saves the screen's contents
  469.           in bucket 2, writes a message and then restore the screen:
  470.           ============================================================
  471.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 12
  472.           ============================================================
  473.  
  474.  
  475.               SaveScreen(2);
  476.               WriteSt('====================================',5,5);
  477.               WriteSt('  Write some stuff over the screen  ',5,6)
  478.               WriteSt('====================================',5,7);
  479.               .
  480.               .
  481.               RestoreScreen(2);
  482.  
  483.           ============================================================
  484.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 13
  485.           ============================================================
  486.  
  487.           SavePartScreen   -- Save a portion of the screen
  488.           RestorePartScreen -- Restore a portion of the screen
  489.  
  490.           Anything that can be accomplished with SavePartScreen and
  491.           RestorePartScreen can generally be accomplished more
  492.           directly with SaveScreen and RestoreScreen.  But, because
  493.           the later procedures save and restore the entire screen they
  494.           may be a touch too slow for some applications (like pull-
  495.           down menus for example).  A rough rule of thumb is that if
  496.           you need to save and restore less than a quarter of the
  497.           screen it is better to do it with the SavePartScreen and
  498.           RestorePartScreen procedures.  If you need to restore
  499.           anything larger than a quarter of the screen use SaveScreen
  500.           and RestoreScreen.
  501.  
  502.           As mentioned in the documentation for SaveScreen, Screen
  503.           Number 0 is reserved for use by the RestorePartScreen
  504.           Procedure.  You can take advantage of this relationship by
  505.           saving an entire screen with SaveScreen(0) and restoring
  506.           various parts of it later using RestorePartScreen.  This
  507.           approach is an alternate to using matched pairs of
  508.           SavePartScreen and RestorePartScreen.  See example 2 below
  509.           for this useful technique.
  510.  
  511.           CALLING SEQUENCE:
  512.  
  513.           PROCEDURE SavePartScreen(X1,Y1,X2,Y2:Integer);
  514.           PROCEDURE RestorePartScreen(X1,Y1,X2,Y2:Integer);
  515.  
  516.           X1,Y1,X2,Y2 : Coordinates of the area to be saved
  517.  
  518.           X1,Y1 are the coordinates of the upper left hand corner of
  519.           the block and X2,Y2 are the coordinates of the lower right
  520.           hand corner of the block.
  521.  
  522.           EXAMPLES:
  523.  
  524.           Example 1 below saves the portion of the screen from column
  525.           5, row 2 to column 10, row 6 and later restores the same
  526.           area:
  527.  
  528.               SavePartScreen(5,2,10,6);
  529.               .
  530.               .
  531.               RestorePartScreen(5,2,10,6);
  532.               
  533.           In Example 2 below the programmer takes advantage of the
  534.           relationship of SaveScreen(0) with RestorePartScreen.  First
  535.           the entire screen is saved then portions of it are later
  536.           restored:
  537.           ============================================================
  538.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 14
  539.           ============================================================
  540.  
  541.  
  542.               SaveScreen(0);
  543.               
  544.               WriteSt('==========',1,1);
  545.               WriteSt('Some Stuff',1,2);
  546.               WriteSt('==========',1,3);
  547.               .
  548.               .
  549.               RestorePartScreen(1,1,10,3);
  550.                 
  551.               WriteSt('==========',5,5);
  552.               WriteSt('More Stuff',5,6);
  553.               WriteSt('==========',5,7);
  554.               .
  555.               .
  556.                 RestorePartScreen(5,5,15,7);
  557.  
  558.           ============================================================
  559.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 15
  560.           ============================================================
  561.  
  562.           SetColor -- Set foreground and background colors
  563.  
  564.           This procedure sets the foreground and background color
  565.           attributes so that any subsequent writes will be in the
  566.           colors indicated.  The statement
  567.  
  568.                   SetColor(Cyan,Black);
  569.  
  570.           is roughly equivalent to the two statements
  571.  
  572.                   TextColor(Cyan);
  573.                   TextBackground(Black);
  574.  
  575.           The only difference is the way SetColor handles blink.  If
  576.           the background color is set to any of the intense colors
  577.           greater than 7 (White, Yellow, LightCyan, etc.) SetColor
  578.           will cause the foreground to blink.  This approach
  579.           duplicates the way the actual color attributes work and
  580.           simplifies the awkward handling of the blink bit in Turbo
  581.           Pascal.
  582.  
  583.           SetColor uses the Turbo Pascal variable TextAttr, which is
  584.           defined in CRT.  TextAttr is the attribute used for Turbo
  585.           Pascal writes.
  586.  
  587.           CALLING SEQUENCE:
  588.  
  589.           PROCEDURE SetColor(F,B:integer);
  590.  
  591.           F : Foreground color
  592.           B : Background color
  593.  
  594.           For the colors you may use numbers between 0 and 15 or the
  595.           color constants listed below from Unit CRT.  If you call
  596.           SetColor with a background color greater than 7 (one of the
  597.           intense colors such as white or yellow) the foreground will
  598.           blink.
  599.  
  600.                   Number Color            Number Color
  601.  
  602.                   0   Black        8   DarkGray
  603.                   1   Blue        9   LightBlue
  604.                   2   Green        10  LightGreen
  605.                   3   Cyan        11  LightCyan
  606.                   4   Red            12  LightRed
  607.                   5   Magenta        13  LightMagenta
  608.                   6   Brown        14  Yellow
  609.                   7   LightGray        15  White
  610.  
  611.           ============================================================
  612.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 16
  613.           ============================================================
  614.  
  615.           EXAMPLES:
  616.  
  617.           To set the foreground color to red and the background color
  618.           to black:
  619.  
  620.               SetColor(Red,Black); {or SetColor(4,0);}
  621.  
  622.           To Set the foreground color to blinking red and the
  623.           background to black:
  624.  
  625.               SetColor(Red,DarkGray); {or SetColor(4,8);}
  626.  
  627.           ============================================================
  628.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 17
  629.           ============================================================
  630.  
  631.           WriteSt -- Write a string
  632.  
  633.           This procedure writes a string starting at column X, Row Y
  634.           on the screen.  WriteSt is nothing more than a GoToXY and a
  635.           Write, but it saves bushels of GoToXY statements.
  636.  
  637.           In previous versions of the Turbo Overdrive Package, WriteSt
  638.           was a direct video write using inline machine code
  639.           statements.  Because Turbo Pascal 4.0 now uses fast direct
  640.           video writes, our inline WriteSt procedure is no longer
  641.           needed and has been repaced by this simple procedure.
  642.  
  643.           CALLING SEQUENCE:
  644.  
  645.           PROCEDURE WriteSt(St:AnyStr;X,Y:Integer);
  646.  
  647.           St  : String to be written
  648.           X,Y : Coordinates of first character
  649.  
  650.           EXAMPLE:
  651.  
  652.           To write an error message on line 25:
  653.  
  654.               WriteSt('Error message 1000',1,25);
  655.  
  656.           ============================================================
  657.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 18
  658.           ============================================================
  659.  
  660.           WriteCh -- Write one character
  661.  
  662.           This Procedure writes a character at column X, row Y on the
  663.           screen.  The procedure uses service 9 of interrupt 10 to
  664.           write the character.  This approach circumvents the usual
  665.           problems with writing some of the low order ASCII characters
  666.           which cause beeps, backspaces and linefeeds.
  667.  
  668.           CALLING SEQUENCE:
  669.  
  670.           PROCEDURE WriteCh(Ch:Char;X,Y:Integer);
  671.  
  672.  
  673.           Ch  : Character to be written
  674.           X,Y : Coordinates of character
  675.  
  676.           EXAMPLE:
  677.  
  678.           To write character 7 (which normally will produce a beep) at
  679.           column 1, row 5:
  680.  
  681.               WriteCh(Chr(07),1,5);
  682.  
  683.           ============================================================
  684.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 19
  685.           ============================================================
  686.  
  687.           WriteManyCh -- Write the same character multiple times
  688.  
  689.           This procedure is like WriteCh described above except that
  690.           the character is repeated Num times.  The procedure is
  691.           useful for writing the top and bottom borders of boxes.
  692.  
  693.           CALLING SEQUENCE:
  694.  
  695.           PROCEDURE WriteManyCh(Ch:Char;X,Y,Num:Integer);
  696.  
  697.           Ch  : Character to be written
  698.           X,Y : Coordinates of first character
  699.           Num : Number of times to repeat the character
  700.  
  701.           EXAMPLE:
  702.  
  703.           To write 20 copies of character # starting at column 1, row
  704.           5:
  705.  
  706.               WriteManyCh('#',1,5,20);
  707.  
  708.           ============================================================
  709.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 20
  710.           ============================================================
  711.  
  712.           FillScr -- Fills the screen with a single character
  713.  
  714.           This procedure fills the screen with the chosen character.
  715.           It is useful for filling the screen with backgrounds.
  716.  
  717.           CALLING SEQUENCE:
  718.  
  719.           PROCEDURE FillScr(Ch:Char);
  720.  
  721.           Ch : character to fill the screen.
  722.  
  723.           EXAMPLE:
  724.  
  725.           To fill the screen with a plus signs:
  726.  
  727.               FillScr('+');
  728.  
  729.           ============================================================
  730.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 21
  731.           ============================================================
  732.  
  733.           ReadFromScr -- Read a string from the screen
  734.  
  735.           This function uses service 8 of Interrupt 10 to read a
  736.           string from the screen.  To prevent a flicker effect, the
  737.           cursor is turned off during the read.  Trailing blanks are
  738.           truncated and the returned string's length is set to the
  739.           last non-blank character.
  740.  
  741.           CALLING SEQUENCE:
  742.  
  743.           FUNCTION ReadFromScr(X,Y,Len:Integer):AnyStr;
  744.  
  745.           X,Y : coordinates of the beginning of the string to be read.
  746.           Len : length of the field to be read.
  747.  
  748.           EXAMPLE:
  749.  
  750.           To read a string at location column 4, row 6, 10 characters
  751.           long:
  752.  
  753.               VAR TempStr : AnyStr;
  754.  
  755.               TempStr := ReadFromScr(4,6,10);
  756.  
  757.           ============================================================
  758.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 22
  759.           ============================================================
  760.  
  761.           GetCh -- Reads a character from the screen
  762.  
  763.           GetCh returns a single character from the screen at location
  764.           X,Y.
  765.  
  766.           CALLING SEQUENCE:
  767.  
  768.           FUNCTION  GetCh(X,Y:Integer):Char;
  769.  
  770.           X,Y : coordinates of character to be read
  771.  
  772.           EXAMPLE:
  773.  
  774.           To read the character at column 6, row 10:
  775.  
  776.               Ch := GetCh(6,10);
  777.  
  778.           ============================================================
  779.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 23
  780.           ============================================================
  781.  
  782.           Border  -- Draw a double-line box
  783.           SBorder -- Draw a single-line box
  784.  
  785.           These two procedures draw boxes on the screen with an
  786.           optional title centered at the top.  Border draws a double-
  787.           line box and SBorder draws a single-line box.
  788.  
  789.           CALLING SEQUENCE:
  790.  
  791.           PROCEDURE Border(X1,Y1,X2,Y2: Integer; Header:AnyStr);
  792.           PROCEDURE SBorder(X1,Y1,X2,Y2: Integer; Header:AnyStr);
  793.  
  794.           X1,Y1  : Coordinates of upper left hand corner of box.
  795.           X2,Y2  : Coordinates of lower right hand corner of box.
  796.           Header : Title for the box.
  797.  
  798.           If no title is desired use the null string ('');
  799.  
  800.           To draw a double-line box from column 5, row 6 to column 30,
  801.           row 20 with title 'Menu Choices':
  802.  
  803.               Border(5,6,30,20,'Menu Choices');
  804.  
  805.  
  806.           PROCEDURE Beep;
  807.  
  808.           Beep, as its name implies produces a beep on the speaker.
  809.  
  810.           EXAMPLE:
  811.  
  812.               If Ch in ['y','Y'] then beep;
  813.  
  814.           ============================================================
  815.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 24
  816.           ============================================================
  817.  
  818.           Linecursor -- Make the cursor shape a line
  819.           BigCursor  -- Make the cursor shape a block
  820.  
  821.           These two procedures change the shape of the cursor.
  822.           LineCursor produces a normal two-line cursor.  BigCursor
  823.           produces a large block cursor.  The cursor on the monochrome
  824.           adapter has more scan lines than the cursor on the color
  825.           adapter.  The procedures recognize the differences in
  826.           adapters and compensates with the right number of scan lines
  827.           in both the line and big cursors.
  828.  
  829.           CALLING SEQUENCE:
  830.  
  831.           PROCEDURE Linecursor;
  832.           PROCEDURE BigCursor;
  833.  
  834.           EXAMPLES:
  835.  
  836.           To produce a block cursor:
  837.  
  838.               BigCursor;
  839.  
  840.           To restore the block cursor to the normal line shape:
  841.  
  842.               LineCursor;
  843.  
  844.           ============================================================
  845.           TURBO OVERDRIVE PACKAGE - UNIT IOSTUFF               Page 25
  846.           ============================================================
  847.  
  848.           HideCursor -- Hide the cursor
  849.           ShowCursor -- Show the cursor
  850.  
  851.           HideCursor makes the cursor invisible by flipping bit 5 of
  852.           the top scan line on.  ShowCursor reverses the process to
  853.           make the cursor visible again.
  854.  
  855.           CALLING SEQUENCE:
  856.  
  857.           PROCEDURE HideCursor;
  858.           PROCEDURE ShowCursor;
  859.  
  860.           EXAMPLES:
  861.  
  862.           To make the cursor invisible:
  863.  
  864.               HideCursor;
  865.  
  866.           To restore the cursor and make it visible:
  867.  
  868.               ShowCursor;
  869.  
  870.  
  871.  
  872.           ============================================================
  873.           TURBO OVERDRIVE PACKAGE - UNIT DIR                  Page 26
  874.           ============================================================
  875.  
  876.           The main function in Unit DIR is PickFile.  This function
  877.           pops up a list of files on the current path and allows the
  878.           user to select the file he wants with a point and shoot
  879.           cursor.  ShowDir and ChangPath are two procedures used by
  880.           PickFile that are also pretty handy on their own.
  881.  
  882.           ShowDir -- Display a directory of files
  883.  
  884.           ShowDir prints a directory of files from the current logged
  885.           path.  Files are displayed 6 to a line in a horizontal
  886.           format.  The maximum number of files that can be displayed
  887.           is 120.
  888.  
  889.           CALLING SEQUENCE:
  890.  
  891.           PROCEDURE ShowDir;
  892.  
  893.           EXAMPLE:
  894.  
  895.           To display the files from the current path:
  896.  
  897.               ShowDir;
  898.  
  899.           ============================================================
  900.           TURBO OVERDRIVE PACKAGE - UNIT DIR                  Page 27
  901.           ============================================================
  902.  
  903.           ChangePath -- Change the drive and directory
  904.  
  905.           ChangePath allows the user to change the current path by
  906.           entering a new drive/directory.  ChangePath does not display
  907.           a directory of files so use ShowDir to display the files in
  908.           the changed directory.
  909.  
  910.           CALLING SEQUENCE:
  911.  
  912.           PROCEDURE ChangePath:
  913.  
  914.           EXAMPLE:
  915.  
  916.           To display the current directory, allow the user to change
  917.           paths and then display the directory of the new path:
  918.  
  919.               ShowDir;
  920.               ChangePath;
  921.               ShowDir;
  922.  
  923.           ============================================================
  924.           TURBO OVERDRIVE PACKAGE - UNIT DIR                  Page 28
  925.           ============================================================
  926.  
  927.           PickFile -- Point-and-shoot file selector
  928.  
  929.           PickFile returns a user-selected file name.  The function
  930.           displays a directory of the current logged drive and allows
  931.           the user to pick the file using a point-and-shoot reverse-
  932.           video cursor.  The user may change paths during the
  933.           selection by hitting the F2 key.  If he does change paths, a
  934.           directory of the new path is displayed.
  935.  
  936.           CALLING SEQUENCE:
  937.  
  938.           FUNCTION  PickFile:AnyStr;
  939.  
  940.           EXAMPLE:
  941.  
  942.           To select a file and open it:
  943.  
  944.               VAR FileName : Text;
  945.               .
  946.               .
  947.               Assign(FileName,PickFile);
  948.               ReWrite(FileName);
  949.               .
  950.               .
  951.               Close(FileName);
  952.  
  953.  
  954.           ============================================================
  955.           TURBO OVERDRIVE PACKAGE - UNIT GETCOLOR              Page 29
  956.           ============================================================
  957.  
  958.           ChooseColor    -- Pop-up color selector smorgasbord
  959.           SetChooseColor -- Set location of color selector
  960.  
  961.           ChooseColor is a pop-up color smorgasbord that allows the
  962.           user to choose his foreground and background colors from the
  963.           smorgasbord.  A sample of the current chosen colors is
  964.           displayed to the right of the smorgasbord to show the user
  965.           how the combination will look.  The smorgasbord also allows
  966.           the user to select blinking text.
  967.  
  968.           ChooseColor does not change the colors, it only allows the
  969.           user to select them.  To set the chosen colors follow the
  970.           ChooseColor call with a call to SetColor.
  971.  
  972.           SetChooseColor is an optional procedure to change the
  973.           location of the pop-up color selection smorgasbord.  The
  974.           default position for the smorgasbord if SetChooseColor is
  975.           not called is column 20, row 5.  The smorgasbord (including
  976.           the color sample) is 30 characters wide and 8 characters
  977.           tall.
  978.  
  979.           CALLING SEQUENCE:
  980.  
  981.           PROCEDURE ChooseColor(VAR Fore,Back : Integer);
  982.  
  983.           Fore : Foreground color chosen by the user
  984.           Back : Background color chosen by the user
  985.  
  986.           Before calling ChooseColor set Fore and Back to the default
  987.           colors so that when the smorgasbord is displayed it will
  988.           show the correct current colors.
  989.  
  990.           PROCEDURE SetChooseColor(X,Y : Integer);
  991.  
  992.           X,Y : coordinates of the top left corner of the smorgasbord.
  993.  
  994.           EXAMPLE:
  995.  
  996.           To pop-up the color selector at column 20, row 3, allow the
  997.           user to select colors and set the colors:
  998.  
  999.               VAR Fore,Back : Integer;
  1000.  
  1001.               Fore := Cyan; Back := Black;
  1002.               SetChooseColor(20,3);
  1003.               ChooseColor(Fore,Back);
  1004.               SetColor(Fore,Back);
  1005.  
  1006.  
  1007.           ============================================================
  1008.           TURBO OVERDRIVE PACKAGE - UNIT POPASCII              Page 30
  1009.           ============================================================
  1010.  
  1011.           ChooseASCII    -- Pop-up ASCII character selector
  1012.           SetChooseASCII -- Set location of ASCII character selector
  1013.  
  1014.           ChooseASCII pops up an ASCII character selector and returns
  1015.           the character chosen by the user.  When the selector first
  1016.           pops up, the first 64 ASCII characters are displayed.  The
  1017.           user may scroll down one line at a time or page down to
  1018.           display all 256 ASCII characters 64 at a time.  The user
  1019.           selects the ASCII character by moving a selector box around
  1020.           the screen with the arrow keys and hitting enter when the
  1021.           selector box surrounds the chosen character.  If the user
  1022.           hits the escape key during the selection process the ASCII
  1023.           character #0 is returned.
  1024.  
  1025.           SetChooseASCII is an optional procedure that changes the
  1026.           location of the pop-up ASCII character selector in
  1027.           ChooseASCII to column X, row Y.  The default position for
  1028.           the ASCII selector if SetChooseASCII is not called is column
  1029.           20, row 5.  The selector box is 18 characters wide and 18
  1030.           characters tall.
  1031.  
  1032.           CALLING SEQUENCE:
  1033.  
  1034.           FUNCTION ChooseASCII:Char;
  1035.           PROCEDURE SetChooseASCII(X,Y:Integer);
  1036.  
  1037.           X,Y : coordinates of top left corner of selector box.
  1038.  
  1039.           EXAMPLE:
  1040.  
  1041.           To position the ASCII character selector box at column 3,
  1042.           row 4 and select an ASCII character:
  1043.  
  1044.               VAR Ch : Char;
  1045.  
  1046.               SetChooseASCII(3,4);
  1047.               Ch := ChooseASCII;
  1048.  
  1049.  
  1050.           ============================================================
  1051.           TURBO OVERDRIVE PACKAGE - UNIT GETLINE               Page 31
  1052.           ============================================================
  1053.  
  1054.           GetStr -- input a user-edited string
  1055.  
  1056.           This function allows the user to enter and edit a string on
  1057.           the screen.  When he is through, the function reads the
  1058.           string off the screen and returns it to be processed
  1059.           further.
  1060.  
  1061.           The functionality of GetStr that takes it beyond a Pascal
  1062.           Read statement is that all of the normal editing keys are
  1063.           functional including the left and right arrow, backspace,
  1064.           insert and delete keys.  Ctrl-backspace erases the string
  1065.           and positions the cursor at the start of the string.  The
  1066.           insert key toggles on an insert mode whereby all characters
  1067.           to the right of the cursor are pushed to the right when
  1068.           characters are entered.
  1069.  
  1070.           The programmer may provide a default string to the function.
  1071.           The default string will be displayed on the screen with the
  1072.           cursor positioned after the last character in the default
  1073.           string.  If the user hits any editing key first (backspace,
  1074.           left arrow, etc.) the function assumes that the user wants
  1075.           to edit the default string.  If, on the other hand, the user
  1076.           enters a character as the first keystroke, the function
  1077.           assumes that the user doesn't want to use the default string
  1078.           but rather wants to type in an entire new string from
  1079.           scratch.  In this case the function erases the default
  1080.           string.  This set of assumptions follows the current trend
  1081.           exemplified by most commercial programs including Turbo
  1082.           Pascal.  The assumptions may be easily removed or modified
  1083.           if they are bothersome.
  1084.  
  1085.           The string that is returned from function GetStr will be
  1086.           truncated.  All trailing blanks will be lopped off and the
  1087.           string's length will be shortened accordingly.
  1088.  
  1089.           CALLING SEQUENCE:
  1090.  
  1091.           FUNCTION GetStr(XF,YF,Len:Integer;Default:AnyStr) : AnyStr;
  1092.  
  1093.           X,Y     : Coordinates of beginning of string to be read
  1094.           Len     : Maximum length of string (field size)
  1095.           Default : Default string to be written in field
  1096.  
  1097.           It may be convenient to think X and Y as the field location
  1098.           and Len as the field size.
  1099.  
  1100.           EXAMPLE:
  1101.  
  1102.           To allow the user to edit and enter a 12 character string at
  1103.           location column 4, row 5 with default "Noname.doc":
  1104.           ============================================================
  1105.           TURBO OVERDRIVE PACKAGE - UNIT GETLINE               Page 32
  1106.           ============================================================
  1107.  
  1108.  
  1109.               VAR Filename : AnyStr;
  1110.  
  1111.               Filename := GetStr(4,5,12,'Noname.Doc');
  1112.  
  1113.  
  1114.           ============================================================
  1115.           TURBO OVERDRIVE PACKAGE - UNIT DRAWBOX               Page 33
  1116.           ============================================================
  1117.  
  1118.           Box -- Box drawing
  1119.  
  1120.           The Box procedure enables the user to draw double-line boxes
  1121.           and lines on the screen with the arrow keys.  If Box were to
  1122.           be incorporated in an editor or word processor, the
  1123.           programmer would, no doubt, add similar procedures for
  1124.           drawing single-line and combination-single-and-double-line
  1125.           boxes.  Box does show one box-drawing technique which can
  1126.           easily be expanded to other styles of box-drawing.
  1127.  
  1128.           CALLING SEQUENCE:
  1129.  
  1130.           PROCEDURE Box(VAR X,Y:Integer);
  1131.  
  1132.           X,Y : Beginning cursor location.
  1133.  
  1134.           Box drawing will start at the initial column and row passed
  1135.           to the procedure.  The location of the cursor when drawing
  1136.           was terminated is returned through variables X and Y.
  1137.  
  1138.           EXAMPLE:
  1139.  
  1140.           To allow the user to draw a box on the screen starting at
  1141.           column 5, row 2:
  1142.  
  1143.               Box(5,2);
  1144.  
  1145.  
  1146.           ============================================================
  1147.           TURBO OVERDRIVE PACKAGE - UNIT MENUBOX               Page 34
  1148.           ============================================================
  1149.  
  1150.           SetMenuBox -- initialize menu choices for box menu
  1151.  
  1152.           SetMenuBox is the initialization procedure for PickMenuBox,
  1153.           a pop-up menu procedure.  SetMenuBox locates the menu on the
  1154.           screen, initializes the menu choices to be displayed and
  1155.           writes the menu on the screen.  The menu will pop-up on the
  1156.           screen at the location you pick.  If you want to restore the
  1157.           screen to its pre-menu appearance be sure to save the screen
  1158.           image with SaveScreen or SavePartScreen before you call
  1159.           SetMenuBox.
  1160.  
  1161.           CALLING SEQUENCE:
  1162.  
  1163.           PROCEDURE SetMenuBox(X,Y:Integer;MenuStr:AnyStr);
  1164.  
  1165.           X,Y   : coordinates of upper left hand corner of menu box.
  1166.           MenuStr : string which contains the menu choices.
  1167.  
  1168.           In building MenuStr the rules are that each seperate menu
  1169.           choice must begin with an unique capital letter and be
  1170.           terminated by a slash (/) delimiter.  For example the string
  1171.           'Walk/Run/Fly/' would set up three menu choices:
  1172.  
  1173.                   | Walk |
  1174.                   | Run  |
  1175.                   | Fly  |
  1176.  
  1177.           An unique first capital letter in each menu choice is
  1178.           important because that letter will become the shortcut
  1179.           keystroke for choosing the menu item directly.  So be sure
  1180.           you don't have two menu choices beginning with the same
  1181.           letter.  The slash delimiter is used by the parsing routine
  1182.           in SetMenuBox to break apart the substrings within the
  1183.           string.  If you forget the last slash get ready to use your
  1184.           computer's big red switch because the parsing logic gets
  1185.           lost and wanders in circles.  True, I could have put in a
  1186.           check for this condition, but once you get your menus
  1187.           working the check would become meaningless overhead.
  1188.  
  1189.           In positioning the menu on the screen with X and Y remember
  1190.           that the box will be two lines longer than the number of
  1191.           menu choices and four characters wider than the longest menu
  1192.           choice.
  1193.  
  1194.           EXAMPLE:
  1195.  
  1196.           To initialize a box menu with the Choices:
  1197.  
  1198.                   | Load |
  1199.           ============================================================
  1200.           TURBO OVERDRIVE PACKAGE - UNIT MENUBOX               Page 35
  1201.           ============================================================
  1202.  
  1203.                   | Save |
  1204.                   | Edit |
  1205.                   | Quit |
  1206.  
  1207.           at location column 5, row 4 on the screen:
  1208.  
  1209.               SetMenuBox(5,4,'Load/Save/Edit/Quit/');
  1210.  
  1211.           ============================================================
  1212.           TURBO OVERDRIVE PACKAGE - UNIT MENUBOX               Page 36
  1213.           ============================================================
  1214.  
  1215.           PickMenuBox -- returns user's choice from a box menu
  1216.  
  1217.           The function PickMenuBox allows the user to play with a menu
  1218.           that was initialized with SetMenuBox.  When the user makes
  1219.           his pick and hits enter, PickMenuBox returns a unique
  1220.           character to the calling routine so that it can branch to
  1221.           the processing logic which performs the user's menu pick.
  1222.           PickMenuBox will highlight the current menu pick with a
  1223.           Lotus-123 reverse-video bar cursor.  The user may move the
  1224.           cursor up and down to various menu picks with the up and
  1225.           down arrow keys.  The user may select a choice on the menu
  1226.           by hitting the enter key or by hitting the key that is the
  1227.           first letter of his choice.  So if the menu choices were
  1228.  
  1229.                   | Walk |
  1230.                   | Run  |
  1231.                   | Fly  |
  1232.  
  1233.           the user could choose Run in one of two ways; 1) placing the
  1234.           cursor on Run and hitting enter or 2) simply hitting R, the
  1235.           first letter in Run.
  1236.  
  1237.           The character returned from the function is the first letter
  1238.           (always capitalized) of the chosen menu item.  For example
  1239.           if the user chooses Run from the menu example above,
  1240.           PickMenuBox will return the character R.  If the user hits
  1241.           the escape key during operation of the menu the character #0
  1242.           will be returned.  It is good practice to test for this
  1243.           character and provide escape logic if it is returned.
  1244.  
  1245.           PickMenuBox was designed to be conveniently used in a case
  1246.           statement that parallels the logic of the menu as shown in
  1247.           the examples below.  However it certainly could be used in
  1248.           other constructs.
  1249.  
  1250.           CALLING SEQUENCE:
  1251.  
  1252.           FUNCTION PickMenuBox : Char;
  1253.  
  1254.           EXAMPLES:
  1255.  
  1256.           To allow the user to pick his choice from a menu which
  1257.           includes:
  1258.  
  1259.                   | Load |
  1260.                   | Save |
  1261.                   | Edit |
  1262.                   | Quit |
  1263.  
  1264.           ============================================================
  1265.           TURBO OVERDRIVE PACKAGE - UNIT MENUBOX               Page 37
  1266.           ============================================================
  1267.  
  1268.           include the following statements:
  1269.  
  1270.               SetMenuBox(5,4,'Load/Save/Edit/Quit/');
  1271.               Case PickMenuBox of
  1272.                   'L': Begin
  1273.                          {Load logic here}
  1274.                        End;
  1275.                   'S': Begin
  1276.                          {Save logic here}
  1277.                        End;
  1278.                   'E': Begin
  1279.                          {Edit logic here}
  1280.                        End;
  1281.                    #0,'Q': Begin
  1282.                          {Quit and abort logic here}
  1283.                        End;
  1284.               End; {Case PickMenuBox}
  1285.  
  1286.           The example above will execute the menu one time and then
  1287.           fall through to other processing.  This may or may not be
  1288.           what you want.  If you want to trap the user in the menu
  1289.           until he indicates he wants to quit by selecting Quit or
  1290.           hitting escape you should use the Repeat Case construct to
  1291.           achieve the desired result as shown below.  Note how the
  1292.           boolean variable ExitMenu is used as a trap release when the
  1293.           user decides to Quit.
  1294.  
  1295.               VAR ExitMenu : Boolean;
  1296.  
  1297.               SetMenuBox(5,4,'Load/Save/Edit/Quit/');
  1298.               ExitMenu := false;
  1299.  
  1300.               Repeat Case PickMenuBox of
  1301.                   'L': Begin
  1302.                          {Load logic here}
  1303.                        End;
  1304.                   'S': Begin
  1305.                          {Save logic here}
  1306.                        End;
  1307.                   'E': Begin
  1308.                          {Edit logic here}
  1309.                        End;
  1310.                    'Q',#0: Begin
  1311.                              ExitMenu := true;
  1312.                            End;
  1313.                   End; {Case PickMenuBox}
  1314.               
  1315.               Until ExitMenu;
  1316.  
  1317.           ============================================================
  1318.           TURBO OVERDRIVE PACKAGE - UNIT MENUBOX               Page 38
  1319.           ============================================================
  1320.  
  1321.           ResetBox -- rewrites box menu
  1322.  
  1323.           ResetBox simply rewrites the menu text that was established
  1324.           with the last call to SetMenuBox.  Think of ResetBox as a
  1325.           repair kit to use whenever you have cleared the screen or
  1326.           written over the menu during the processing of your program.
  1327.  
  1328.           CALLING SEQUENCE:
  1329.  
  1330.           Procedure ResetBox;
  1331.  
  1332.           EXAMPLE:
  1333.  
  1334.           The example below shows how to use ResetBox to rewrite the
  1335.           menu after the screen has been cleared:
  1336.  
  1337.               SetMenuBox(5,4,'Clear Screen/Junk/More Junk/');
  1338.               Case PickMenuBox of
  1339.                   'C': Begin
  1340.                         ClrScr;
  1341.                         ResetBox;
  1342.                        End;
  1343.                   'J': Begin
  1344.                          {Junk logic here}
  1345.                        End;
  1346.                   'M': Begin
  1347.                          {More Junk logic here}
  1348.                        End;
  1349.                 End; {Case PickMenuBox}
  1350.  
  1351.  
  1352.           ============================================================
  1353.           TURBO OVERDRIVE PACKAGE - UNIT MENU123               Page 39
  1354.           ============================================================
  1355.  
  1356.           SetMenu123 -- Initialize menu choices for 123 menu
  1357.  
  1358.           SetMenu123 is the initialization procedure for PickMenu123,
  1359.           a Lotus 123 style horizontal, reverse-video-bar-cursor menu
  1360.           procedure.  SetMenu123 locates the menu on the screen,
  1361.           initializes the menu choices to be displayed and writes the
  1362.           menu on the screen.  The menu will be displayed horizontally
  1363.           on the line you pick.
  1364.  
  1365.           CALLING SEQUENCE:
  1366.  
  1367.           PROCEDURE SetMenu123(X,Y:Integer;MenuStr:AnyStr);
  1368.  
  1369.           X,Y   : Coordinates of the menu location
  1370.           MenuStr : String which contains the menu choices
  1371.  
  1372.           In building MenuStr remember that each menu choice must
  1373.           begin with an unique capital letter and be terminated by a
  1374.           slash (/) delimiter.  For example the string 'Walk/Run/Fly/'
  1375.           would set up three menu choices:
  1376.  
  1377.                   [ Walk  Run  Fly ]
  1378.  
  1379.           The first capital letter in each menu choice is important
  1380.           because that letter will become the shortcut keystroke for
  1381.           choosing the menu item directly.  So be sure you don't have
  1382.           two menu choices beginning with the same letter.  The slash
  1383.           delimiter is important to the parsing routine in SetMenu123.
  1384.           Just as with the SetMenuBox strings described above, if you
  1385.           forget the last slash get ready to use the big red switch.
  1386.  
  1387.           EXAMPLES:
  1388.  
  1389.           To initialize a 123 menu with the Choices:
  1390.  
  1391.                   [ Load  Save  Edit  Quit ]
  1392.  
  1393.           at location column 5, row 1 on the screen:
  1394.  
  1395.               SetMenu123(5,1,'Load/Save/Edit/Quit/');
  1396.  
  1397.           ============================================================
  1398.           TURBO OVERDRIVE PACKAGE - UNIT MENU123               Page 40
  1399.           ============================================================
  1400.  
  1401.           PickMenu123 -- returns user's choice from a 123 menu
  1402.  
  1403.           The function PickMenu123 allows the user to play with a menu
  1404.           initialized previously with SetMenu123 and returns the
  1405.           user's menu pick in the form of a unique character.
  1406.           PickMenu123 will highlight the current menu pick with a
  1407.           Lotus-123 reverse-video bar cursor.  The user may move the
  1408.           cursor left and right to various menu picks with the left
  1409.           and right arrow keys.  The user may select a choice on the
  1410.           menu by placing the cursor on a choice and hitting the enter
  1411.           key or by hitting the key that is the first letter of his
  1412.           choice.  So for the menu choices
  1413.  
  1414.                   [ Walk  Run  Fly ]
  1415.  
  1416.           the user could choose Run by placing the cursor on Run and
  1417.           hitting enter or he could simply hit the letter R.
  1418.  
  1419.           The character returned from the function is the first letter
  1420.           (always capitalized) of the chosen menu item.  For example
  1421.           if the user chooses Run from the menu example above,
  1422.           PickMenu123 will return the character R.  If the user hits
  1423.           escape key during operation of the menu the character #0
  1424.           will be returned.  Always test for this character and
  1425.           provide processing logic if it is returned.  PickMenu123 is
  1426.           designed to be conveniently used in a case statement as
  1427.           shown in the examples below.
  1428.  
  1429.           CALLING SEQUENCE:
  1430.  
  1431.           FUNCTION PickMenu123 : Char;
  1432.  
  1433.           EXAMPLE:
  1434.  
  1435.           To allow the user to pick his choice from a menu of:
  1436.  
  1437.                   [ Load  Save  Edit  Quit ]
  1438.  
  1439.           include the following statements:
  1440.  
  1441.               SetMenu123(5,1,'Load/Save/Edit/Quit/');
  1442.               Case PickMenu123 of
  1443.                   'L': Begin
  1444.                          {Load logic here}
  1445.                        End;
  1446.                   'S': Begin
  1447.                          {Save logic here}
  1448.                        End;
  1449.                   'E': Begin
  1450.           ============================================================
  1451.           TURBO OVERDRIVE PACKAGE - UNIT MENU123               Page 41
  1452.           ============================================================
  1453.  
  1454.                          {Edit logic here}
  1455.                        End;
  1456.                    #0,'Q': Begin
  1457.                          {Quit logic here}
  1458.                        End;
  1459.               End; {Case PickMenu123}
  1460.  
  1461.           The example above will execute the menu one time and then
  1462.           fall through to other processing which is not normally what
  1463.           you want.  Most commercial menus trap the user in the menu
  1464.           until he indicates he wants to quit by selecting Quit or
  1465.           hitting escape.  To achieve this effect use the Repeat Case
  1466.           construct as shown in the example below.  Note how the
  1467.           variable ExitMenu traps the user in the Repeat loop until he
  1468.           selects Quit:
  1469.  
  1470.               VAR ExitMenu : Boolean;
  1471.  
  1472.               SetMenu123(5,1,'Load/Save/Edit/Quit/');
  1473.               ExitMenu := false;
  1474.  
  1475.               Repeat Case PickMenu123 of
  1476.                   'L': Begin
  1477.                          {Load logic here}
  1478.                        End;
  1479.                   'S': Begin
  1480.                          {Save logic here}
  1481.                        End;
  1482.                   'E': Begin
  1483.                          {Edit logic here}
  1484.                        End;
  1485.                    'Q',#0: Begin
  1486.                              ExitMenu := true;
  1487.                            End;
  1488.                   End; {Case PickMenu123}
  1489.               
  1490.               Until ExitMenu;
  1491.  
  1492.           ============================================================
  1493.           TURBO OVERDRIVE PACKAGE - UNIT MENU123               Page 42
  1494.           ============================================================
  1495.  
  1496.           Reset123 -- Rewrites 123 menu
  1497.  
  1498.           Reset123 simply rewrites the menu text that was established
  1499.           with the last call to SetMenu123.  Think of Reset123 as a
  1500.           repair kit to use whenever you have cleared the screen or
  1501.           written over the menu during the processing of your program.
  1502.  
  1503.           CALLING SEQUENCE:
  1504.  
  1505.           Procedure Reset123;
  1506.  
  1507.           EXAMPLE:
  1508.  
  1509.           The example below shows how to use Reset123 to rewrite the
  1510.           menu after the screen has been cleared:
  1511.  
  1512.               SetMenu123(5,4,'Clear Screen/Junk/More Junk/');
  1513.               Case PickMenu123 of
  1514.                   'C': Begin
  1515.                         ClrScr;
  1516.                         Reset123;
  1517.                        End;
  1518.                   'J': Begin
  1519.                          {Junk logic here}
  1520.                        End;
  1521.                   'M': Begin
  1522.                          {More Junk logic here}
  1523.                        End;
  1524.                 End; {Case PickMenu123}
  1525.  
  1526.  
  1527.           ============================================================
  1528.           TURBO OVERDRIVE PACKAGE - UNIT MENUPULL              Page 43
  1529.           ============================================================
  1530.  
  1531.           Unit MenuPull is a comprehensive set of pull-down menu
  1532.           routines.  The pull-down menus have two components that work
  1533.           separately but with each other.  The main menu component is
  1534.           a horizontal bar menu that operates on the top line of the
  1535.           screen.  The sub-menu components are little box menus that
  1536.           pop-up under the main menu choices as the user browses the
  1537.           main choices.  While the user is browsing the main menu the
  1538.           secondary menus are displayed but are inactive.  If the user
  1539.           makes a choice from the main menu then the sub-menu becomes
  1540.           active and the user may make a choice from that menu.
  1541.  
  1542.           The operation of pull-down menus is complex and does require
  1543.           careful attention to detail in the calling program so that
  1544.           processing is transferred from the main menu to the sub-
  1545.           menus at the right time.  Don't be intimidated however.
  1546.           These routines are as powerful and as easy to use as any
  1547.           menuing routines you will find.
  1548.  
  1549.           SetMain -- Intialize main menu choices
  1550.           SetSub  -- Initialize sub-menu choices
  1551.  
  1552.           SetMain and SetSub are the initialization procedures for
  1553.           PickMain and PickSub, a two-level pull-down menu interface
  1554.           that works much like the interface for Turbo Pascal 4.0.  As
  1555.           the user browses the main menu, which is a horizontal menu
  1556.           of choices on the top line of the screen, sub-menus are
  1557.           displayed under each of the main menu picks.  If the user
  1558.           hits enter to select a main menu choice, the reverse-video
  1559.           cursor jumps down into the sub-menu to allow him to make a
  1560.           choice there.  SetMain initializes the main menu choices to
  1561.           be displayed and SetSub initializes the sub-menu choices
  1562.           under each main menu choice.  SetSub must be called several
  1563.           times, once for each main menu choice that has sub-menu
  1564.           choices.  The sub-menu choices are associated with the main
  1565.           menu choices through the variable Sub.
  1566.  
  1567.           CALLING SEQUENCE:
  1568.  
  1569.           PROCEDURE SetMain(MenuStr:AnyStr);
  1570.           PROCEDURE SetSub(Sub:Integer;SubStr:AnyStr);
  1571.  
  1572.           MenuStr : String containing main menu choices
  1573.           SubStr  : String containing sub-menu choices
  1574.           Sub     : Sub-menu to main menu association number
  1575.  
  1576.           The format of MenuStr and SubStr are identical and follow
  1577.           the same format established in MenuBox and Menu123
  1578.           procedures.  Each menu choice given in the string must begin
  1579.           with a capital letter and be terminated by the delimiter
  1580.           ============================================================
  1581.           TURBO OVERDRIVE PACKAGE - UNIT MENUPULL              Page 44
  1582.           ============================================================
  1583.  
  1584.           slash (/).  For example if MenuStr were given the value
  1585.           'Save/Load/Quit/' SetMain would set up three main menu
  1586.           choices:
  1587.  
  1588.                   [ Save  Load  Quit ]
  1589.  
  1590.           The first capital letter in each menu choice is important
  1591.           because that letter will become the shortcut keystroke for
  1592.           choosing the menu item directly.  So don't begin two menu
  1593.           choices with the same letter.  The slash delimiter is used
  1594.           by the parsing routine in SetMain and SetSub.  A final
  1595.           reminder; don't forget the last slash in the string.
  1596.  
  1597.           The variable Sub, which is an argument passed to SetSub,
  1598.           provides the association of sub-menus to main menu choices.
  1599.           For example the statement:
  1600.  
  1601.                    SetSub(2,'Compile/Link/Run/Quit/');
  1602.  
  1603.           associates the sub-menu with main menu pick number 2.
  1604.  
  1605.           EXAMPLES:
  1606.  
  1607.           To initialize a main menu and sub-menus that looks something
  1608.           like this:
  1609.  
  1610.                   [ Fish  Birds  Mammals  Quit ];
  1611.                    | Trout   |
  1612.                    | Bass    |
  1613.                    | Walleye |
  1614.                    | Catfish |
  1615.  
  1616.           include the following statements in your program:
  1617.  
  1618.               SetMain('Fish/Birds/Mammals/Quit/');
  1619.  
  1620.               SetSub(1,'Trout/Bass/Walleye/Catfish/');
  1621.               SetSub(2,'Robin/Sparrow/Hawk/');
  1622.               SetSub(3,'Fox/Cow/Armadillo/Mouse/');
  1623.  
  1624.           Note that there is one SetSub call for each main menu choice
  1625.           that has a sub-menu.
  1626.  
  1627.           The above example included the menu setup string right in
  1628.           the call statement.  In many instances it may be more
  1629.           convenient to assign the strings to variables and pass the
  1630.           string through the variable.  Also you may wish to make your
  1631.           code more readable by staggering sub-strings on different
  1632.           lines joined with a + as in the example below:
  1633.           ============================================================
  1634.           TURBO OVERDRIVE PACKAGE - UNIT MENUPULL              Page 45
  1635.           ============================================================
  1636.  
  1637.  
  1638.               VAR Menu3 : String[80];
  1639.  
  1640.               Menu3 := 'Fox/'+
  1641.                    'Cow/'+
  1642.                    'Armadillo/'+
  1643.                    'Mouse/';
  1644.  
  1645.               SetSub(3,Menu3);
  1646.  
  1647.           ============================================================
  1648.           TURBO OVERDRIVE PACKAGE - UNIT MENUPULL              Page 46
  1649.           ============================================================
  1650.  
  1651.           PickMain -- Returns user's choice from main menu
  1652.           PickSub  -- Returns user's choice from sub menu
  1653.  
  1654.           PickMain and PickSub are the functions that allow the user
  1655.           to play with the menus and make his choice.  When the user
  1656.           makes a menu choice by hitting the enter key or hitting the
  1657.           first letter of a pick, the functions will terminate and
  1658.           return to the calling program the first letter (always
  1659.           capitalized) of the chosen menu item.  For example if the
  1660.           user picks Fox from a sub-menu made up of
  1661.  
  1662.                   | Fox       |
  1663.                   | Cow       |
  1664.                   | Armadillo |
  1665.                   | Mouse     |
  1666.  
  1667.           PickSub would return the character F.  PickMain and PickSub
  1668.           will return the character #0 if the user hits escape during
  1669.           operation of the menu.  It is a good idea to processing for
  1670.           #0 in the case statements.
  1671.  
  1672.           CALLING SEQUENCE:
  1673.  
  1674.           FUNCTION  PickMain : Char;
  1675.           FUNCTION  PickSub(Sub:Integer) : Char;
  1676.  
  1677.           EXAMPLE:
  1678.  
  1679.           PickMain and PickSub are intended to be used in a nested
  1680.           case structure that looks like this:
  1681.  
  1682.               ExitMenu := false;
  1683.               
  1684.               Repeat Case PickMain of
  1685.  
  1686.                   'A': Case PickSub(1) of
  1687.                       'P': ...
  1688.                       'Q': ...
  1689.                   'B': Repeat Case PickSub(2) of
  1690.                       'R': ...
  1691.                       'S': ...
  1692.                   'C': Case PickSub(3) of
  1693.                       'T': ...
  1694.                       'U': ...
  1695.  
  1696.               Until MenuExit;
  1697.  
  1698.           The idea here is that each of the sub-menu cases is
  1699.           contained within a large main menu case.  If the menus are
  1700.           ============================================================
  1701.           TURBO OVERDRIVE PACKAGE - UNIT MENUPULL              Page 47
  1702.           ============================================================
  1703.  
  1704.           used in this way they will interact correctly (with a little
  1705.           help from the programmer).  You may wish to use the Repeat
  1706.           Case construct shown in the example and discussed with the
  1707.           MenuBox and Menu123 procedures to trap the user inside a
  1708.           sub-menu or main menu until he signals his intention to quit
  1709.           by hitting escape or selecting Quit from the menu.  Most
  1710.           commercial products use this trapped-user approach.
  1711.  
  1712.           If you want more detailed examples for reference, see
  1713.           programs BigDemo.Dem and MenuPull.Dem on the TOP disk.
  1714.  
  1715.           ============================================================
  1716.           TURBO OVERDRIVE PACKAGE - UNIT MENUPULL              Page 48
  1717.           ============================================================
  1718.  
  1719.           RestoreWorkScreen -- Restore screen to pre-menu appearance
  1720.           SaveWorkScreen -- Save current screen and rewrite menus
  1721.  
  1722.           These two procedures come into play if you clear the screen
  1723.           or write over the menus during normal processing.  The
  1724.           WorkScreen is the screen image the way it looks before any
  1725.           menus are written on it.  An original snapshot of WorkScreen
  1726.           is taken in procedure SetMain.  So whatever the screen looks
  1727.           like when you call SetMain is important.  You may restore
  1728.           the screen to its original look at any time during
  1729.           processing by calling RestoreWorkScreen.
  1730.  
  1731.           SaveWorkScreen takes a new snapshot of the screen.  So if
  1732.           your program's logic is fiddling with the screen's contents
  1733.           you will undoubtedly want to save your screen fiddling
  1734.           progress by calling SaveWorkScreen periodically.  Remember
  1735.           not to call SaveWorkScreen with the menus on the screen.  To
  1736.           prevent messing up your snapshot, first do a
  1737.           RestoreWorkScreen (to erase the menus), write on the screen
  1738.           then finish with a SaveWorkScreen before returning to the
  1739.           control of the menus.  SaveWorkScreen sets a flag in the
  1740.           menu routines so that the routines will know to reconstruct
  1741.           all the menus on the new screen.
  1742.  
  1743.           All this sounds complicated but there are only two simple
  1744.           rules to remember:
  1745.  
  1746.           1. SetMain will take a snapshot of the screen the way it
  1747.           looks when it is called.  Any time you call
  1748.           RestoreWorkScreen, the screen will be restored to this
  1749.           original snapshot.
  1750.  
  1751.           2. If you have updated the screen and want to replace the
  1752.           original snapshot with a new snapshot first get the screen
  1753.           like you want it and then call SaveWorkScreen.
  1754.  
  1755.           CALLING SEQUENCE:
  1756.  
  1757.           PROCEDURE RestoreWorkScreen;
  1758.           PROCEDURE SaveWorkScreen;
  1759.  
  1760.           EXAMPLE:
  1761.  
  1762.           In this example the use has picked "Edit" from sub-menu 1
  1763.           under main menu pick "File".  To restore the work screen,
  1764.           allow the user to edit the screen and return to the control
  1765.           of the menus include the following statements:
  1766.  
  1767.               Repeat Case PickMain of
  1768.           ============================================================
  1769.           TURBO OVERDRIVE PACKAGE - UNIT MENUPULL              Page 49
  1770.           ============================================================
  1771.  
  1772.  
  1773.                   'F': Case PickSub(1) of
  1774.                       'E': Begin
  1775.                              RestoreWorkScreen;
  1776.                              ... { Do user edit stuff }
  1777.                              SaveWorkScreen;
  1778.                            End;
  1779.                       'Q': ...
  1780.  
  1781.                   'B': ...
  1782.  
  1783.           See BIGDEMO.DEM on the TOP disk for other examples of proper
  1784.           SaveWorkScreen and RestoreWorkScreen usage.
  1785.  
  1786.           ============================================================
  1787.           TURBO OVERDRIVE PACKAGE - UNIT MENUPULL              Page 50
  1788.           ============================================================
  1789.  
  1790.           PROCEDURE WriteMain;
  1791.           PROCEDURE WriteSub(Sub:Integer);
  1792.  
  1793.           WriteMain and WriteSub are procedures that do nothing more
  1794.           than rewrite the menus on the screen.  WriteMain writes the
  1795.           main menu established by SetMainMenu and WriteSub writes the
  1796.           sub-menu established by SetSubMenu.  Unlike the
  1797.           SaveWorkScreen and RestoreWorkScreen procedures described
  1798.           above which allow for complicated screen management, these
  1799.           two procedures are simple repair kits for rewriting the
  1800.           menus on the screen whenever needed.  PickSub and PickMain
  1801.           do a good job of figuring out when to write on and restore
  1802.           parts of the screen so WriteMain and WriteSub are not
  1803.           normally needed.
  1804.  
  1805.           CALLING SEQUENCE:
  1806.  
  1807.           PROCEDURE WriteMain;
  1808.           PROCEDURE WriteSub(Sub:Integer);
  1809.  
  1810.           EXAMPLE:
  1811.  
  1812.           In this example the programmer wants to clear the screen and
  1813.           write the menu texts on the cleared screen.  However he
  1814.           doesn't want to officially save the new screen image (with
  1815.           SaveWorkScreen):
  1816.  
  1817.               Repeat Case PickMain of
  1818.  
  1819.                   'F': Case PickSub(1) of
  1820.                       'E': Begin
  1821.                              ClrScr;
  1822.                              ... { Do more stuff to screen }
  1823.                              WriteMain;
  1824.                              WriteSub;
  1825.                            End;
  1826.                       'Q': ...
  1827.  
  1828.                   'B': ...
  1829.  
  1830.          ----------------end-of-author's-documentation---------------
  1831.  
  1832.                         Software Library Information:
  1833.  
  1834.                    This disk copy provided as a service of
  1835.  
  1836.                         The Public (Software) Library
  1837.  
  1838.          We are not the authors of this program, nor are we associated
  1839.          with the author in any way other than as a distributor of the
  1840.          program in accordance with the author's terms of distribution.
  1841.  
  1842.          Please direct shareware payments and specific questions about
  1843.          this program to the author of the program, whose name appears
  1844.          elsewhere in  this documentation. If you have trouble getting
  1845.          in touch with the author,  we will do whatever we can to help
  1846.          you with your questions. All programs have been tested and do
  1847.          run.  To report problems,  please use the form that is in the
  1848.          file PROBLEM.DOC on many of our disks or in other written for-
  1849.          mat with screen printouts, if possible.  The P(s)L cannot de-
  1850.          bug programs over the telephone.
  1851.  
  1852.          Disks in the P(s)L are updated monthly, so if you did not get
  1853.          this disk  directly from the P(s)L,  you should be aware that
  1854.          the files in this set may no  longer be the current versions.
  1855.  
  1856.          For a copy of the latest monthly software library newsletter
  1857.          and a list of the 1,000+ disks in the library, call or write
  1858.  
  1859.                         The Public (Software) Library
  1860.                               P.O.Box 35705 - F
  1861.                            Houston, TX 77235-5705
  1862.                       (713) 721-6104 or (713) 721-5205
  1863.  
  1864.