home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TOTDOC.ZIP / CHAPT2.TXT < prev    next >
Encoding:
Text File  |  1991-02-11  |  26.8 KB  |  535 lines

  1.                                                                  Getting Started
  2.  
  3.  
  4.  
  5.  
  6.  
  7.          "It is common sense to take a method and try it. If it fails, admit it
  8.          frankly and try another. But above all, try something."
  9.  
  10.                                                            Franklin D. Roosevelt
  11.  
  12.  
  13.  
  14.  
  15.  
  16. Installing the Toolkit
  17.  
  18.          The Toolkit is available in a variety of disk densities and sizes. This
  19.          section assumes that you are installing the software from a two disk
  20.          set. If you are using a single disk set, simply assume that all the
  21.          files are contained on a single disk and ignore the instructions for
  22.          inserting the second disk.
  23.  
  24.          The program disk includes an installation program INSTALL.EXE. This
  25.          program can be used to automatically install the software onto your
  26.          hard disk. It will prompt you to enter the appropriate source and tar-
  27.          get directories, and will not modify your CONFIG.SYS and AUTOEXEC.BAT
  28.          files. Alternatively, you may install the Toolkit manually. Please note
  29.          that the files are stored on disk in compressed form, and must be
  30.          uncompressed (decompressed?) before they can be used.
  31.  
  32.  
  33.  
  34. Using INSTALL.EXE
  35.  
  36.          The Install program will transfer the Toolkit files from the diskettes
  37.          to a specified hard drive. To run the install program, insert the
  38.          Source Disk in drive A (or another floppy drive) and then:
  39.  
  40.          q    Type the command: A:INSTALL [KEYCAP].
  41.  
  42.          q    Press [KEYCAP] at the installation screen.
  43.  
  44.          q    Follow the prompts.
  45.  
  46.          It is recommended that you install the source files in a sub-directory
  47.          TOT beneath the main Turbo Pascal directory. Similarly, the demo files
  48.          should be installed in a TOTDEM subdirectory.
  49.  
  50.          During the installation process, files will be copied from the Toolkit
  51.          disks to your hard drive. The files will then be compressed. Once the
  52.          files have been installed, the Installation program will ask if you
  53.          want to view the README file. This file contains last-minute details
  54.          about the Toolkit. A following section describes how to view the README
  55.          file after installation.
  56.  
  57.          If the installation is not successful, follow the manual installation
  58.          method described in the next section.
  59.  
  60.  
  61. 2-2                                                                 User's Guide
  62.  
  63. --------------------------------------------------------------------------------
  64.  
  65. Manual Installation
  66.  
  67.          The disks contain the following files:
  68.  
  69.          INSTALL.EXE     the Toolkit Installation program
  70.  
  71.          SOURCE.EXE      a self-extracting file which contains the .PAS source
  72.                          files for the Toolkit units
  73.  
  74.          DEMO.EXE        a self-extracting file which contains the .PAS demon-
  75.                          stration files, which illustrate how to use the Toolkit
  76.  
  77.          DOCS.EXE        a self-extracting file containing all this documenta-
  78.                          tion in ASCII form
  79.  
  80.          README.COM      a self-displaying text file which lists all the last-
  81.                          minute changes and enhancements
  82.  
  83.          REGISTER.EXE    a self-extracting file which contains all the ShareWare
  84.                          information and instructions
  85.  
  86.  
  87.  
  88.          We recommend that the source files are installed in a separate sub-
  89.          directory "underneath" the compiler directory. For example, if your
  90.          compiler is stored in the directory C:\TP, then create a directory
  91.          C:\TP\TOT. You can insert the source disk in the A drive and install
  92.          the source files as follows:
  93.  
  94.                   C: [KEYCAP]
  95.                   MD\TP\TOT [KEYCAP]
  96.                   CD\TP\TOT [KEYCAP]
  97.                   A:SOURCE [KEYCAP]
  98.  
  99.  
  100.  
  101.          The SOURCE.EXE program will then place all the source code files in the
  102.          newly created directory. The README.COM file should also be copied to
  103.          the TOT sub-directory.
  104.  
  105.                   COPY A:README.COM [KEYCAP]
  106.  
  107.  
  108.  
  109.          Although not essential, the demonstration files are referred to
  110.          throughout the documentation and it is recommended that you do install
  111.          them. Furthermore, it is recommended that you install them in a sepa-
  112.          rate subdirectory as follows:
  113.  
  114.                   C: [KEYCAP]
  115.                   MD\TP\TOTDEMO [KEYCAP]
  116.                   CD\TP\TOTDEMO [KEYCAP]
  117.                   A:DEMO [KEYCAP]
  118.  
  119.  
  120.  
  121.  
  122. Getting Started                                                              2-3
  123.  
  124. --------------------------------------------------------------------------------
  125.  
  126.          You do not need to install the DOCS.EXE and REGISTER.EXE files, since
  127.          you are a registered user and you are reading the documentation. These
  128.          files are included so that you may give an evaluation copy of the
  129.          Toolkit to a colleague who may try the software. Refer to the License
  130.          Agreement for further information.
  131.  
  132. The Toolkit Files
  133.  
  134.          Listed below are the source files that have been installed on your hard
  135.          disk:
  136.  
  137.          TOTFLAGS.INC    contains global compiler directives
  138.  
  139.          TOTLOOK.PAS     controls the overall look and feel of your programs
  140.  
  141.          TOTREAL.PAS     provides numeric co-processor support and supports
  142.                          extended reals
  143.  
  144.          TOTSYS.PAS      contains objects for ascertaining hardware and operat-
  145.                          ing system configurations
  146.  
  147.          TOTINPUT.PAS    provides mouse and keyboard support
  148.  
  149.          TOTFAST.PAS     supports writing to physical and virtual screens
  150.  
  151.          TOTWIN.PAS      contains a variety of window objects
  152.  
  153.          TOTMSG.PAS      provides objects for displaying messages and prompts in
  154.                          Pop-up windows
  155.  
  156.          TOTLINK.PAS     includes a variety of objects for managing linked lists
  157.  
  158.          TOTLIST.PAS     provides objects for displaying string arrays or linked
  159.                          lists in a window
  160.  
  161.          TOTDIR.PAS      includes a directory display object
  162.  
  163.          TOTIO1,2,3.PAS  three units for building full screen input
  164.  
  165.          TOTMENU.PAS     includes routines for building pop-up and pull-down
  166.                          menus
  167.  
  168.          TOTSTR.PAS      contains a host of string manipulation functions
  169.  
  170.          TOTDATE.PAS     includes a set of functions for managing Julian and
  171.                          Gregorian dates
  172.  
  173.          TOTMISC.PAS     provides a potpourri of procedures and functions
  174.  
  175.          TOTBUILD.PAS    used to re-build all the TOT TPUs
  176.  
  177.  
  178.  
  179.          In addition to the source code files, there are a host of demonstration
  180.          files. All the demonstration filenames begin with DEM. The files which
  181.          demonstrate how to extend the Toolkit begin with EXT. The major demon-
  182.  
  183. 2-4                                                                 User's Guide
  184.  
  185. --------------------------------------------------------------------------------
  186.  
  187.          stration file is DEMTOT.PAS. All the other files are designed to be
  188.          small and concise illustrations of how to get the most from the
  189.          Toolkit.
  190.  
  191.  
  192.  
  193. The README File
  194.  
  195.          The file README.COM is actually a self-displaying text file which con-
  196.          tains any last-minute changes or additions to the documentation. To
  197.          view the contents of the README file, simply change the default
  198.          directory to the TOT source and execute README, e.g.
  199.  
  200.                   CD\TP\TOT [KEYCAP]
  201.                   README [KEYCAP]
  202.  
  203.  
  204.  
  205. Configuring Turbo Pascal
  206.  
  207.          Having installed the Toolkit, you must configure Turbo Pascal so the
  208.          compiler knows where to locate the Toolkit files. Configure the inte-
  209.          grated environment as follows:
  210.  
  211.          q    Execute the IDE by changing the default directory to the main
  212.               Turbo Pascal directory, and enter TURBO.
  213.  
  214.          q    Select the Directories item from the Options menu. The Directories
  215.               dialog box will then be displayed. Fig 2.1 illustrates the Pascal
  216.               6.0 dialog box.
  217.  
  218.          q    You must now add the C:\TURBO\TOT directory (or whichever direc-
  219.               tory you have chosen for the Toolkit) to the Unit, Include and
  220.               Object input fields. If an entry already exists in the field,
  221.               press the right cursor and add a semi-colon before entering the
  222.               Toolkit directory. Note: do not have more than one directory in
  223.               the EXE/TPU input field - this must be a single directory identi-
  224.               fying where the compiler should locate compiled files.
  225.  
  226.          q    Save the options by selecting Save from the Options menu.
  227.  
  228.  
  229.  
  230. Figure 2.1                                                              [SCREEN]
  231. Configuring the IDE
  232.  
  233.  
  234.  
  235.          If you are using the command line version of the compiler, i.e. TPC.EXE
  236.          or TPCX.EXE, then you must add the Toolkit directory to the Unit,
  237.          Include and Source parameters in the TPC(X).CFG file. Listed below is
  238.          an example of a TPC.CFG file:
  239.  
  240.  
  241.  
  242. Getting Started                                                              2-5
  243.  
  244. --------------------------------------------------------------------------------
  245.  
  246.                /L
  247.                /M
  248.                /IC:\TURBO\TOT;C:\TURBO\MISC
  249.                /UC:\TURBO\TOT
  250.                /OC:\TURBO\TOT
  251.                /EC:\TURBO\MYPROGS
  252.  
  253.  
  254.          Turbo Pascal 5.5 users can use the TPCONFIG.EXE program to create a
  255.          TPC.CFG file from the IDE settings, and vice verse.
  256.  
  257.          For further configuration information refer to the Turbo Pascal User's
  258.          Guide.
  259.  
  260.  
  261.  
  262. Unit Summary
  263.  
  264.          Listed below is a description of the features in each of the major
  265.          units:
  266.  
  267.  
  268.  
  269.          totLOOK    This unit is designed to help you control the look and feel
  270.                     of large programs. A global object, LOOKTOT, defines the
  271.                     default colors to be used when displaying windows, menus and
  272.                     lists.
  273.  
  274.          totREAL    This small unit controls the REAL type. Unless the compiler
  275.                     directive FLOAT is specified (in the TOTFLAGS.INC file -
  276.                     discussed later), the types SINGLE, DOUBLE, EXTENDED and
  277.                     COMP are type cast to the base type REAL.
  278.  
  279.          totSYS     This unit provides four objects which can be used to deter-
  280.                     mine the hardware and operating system configurations of the
  281.                     PC on which your programs are running. The DisplayOBJ object
  282.                     provides information about the display: whether it is color
  283.                     or monochrome, what is the width and depth of the screen,
  284.                     and the object includes methods for setting the screen into
  285.                     and out of condensed mode, i.e. 43 or 50 line mode. The
  286.                     EquipOBJ object provides information about the PC peripheral
  287.                     devices, e.g. how many serial and parallel ports there are,
  288.                     if a math chip is present, how many floppy drives, etc. The
  289.                     MemOBJ object provides information about base memory, as
  290.                     well as extended and expanded memory. The OSOBJ provides
  291.                     information about the operating system, e.g. the DOS version
  292.                     number, the country configuration, and the characters used
  293.                     for currency, date and time separators.
  294.  
  295.  
  296.  
  297. 2-6                                                                 User's Guide
  298.  
  299. --------------------------------------------------------------------------------
  300.  
  301.          totINPUT   The two main objects in this unit, MouseOBJ and KeyOBJ, are
  302.                     used to detect and control mouse and keyboard activity. The
  303.                     MouseOBJ detects if a mouse is present and includes a
  304.                     variety of methods for controlling the mouse shape and
  305.                     location. The KeyOBJ is the primary input object and detects
  306.                     both keyboard and mouse button activity. There are methods
  307.                     to get and set the status of the Caps Lock, Num Lock and
  308.                     Scroll Lock keys, as well as routines to stuff or erase
  309.                     characters with a special keyboard type-ahead buffer.
  310.  
  311.          totFAST    The totFAST unit provides the main screen writing primi-
  312.                     tives, and contains four main objects: WriteOBJ, ScreenOBJ,
  313.                     ScrollOBJ and ShadowOBJ. The WriteOBJ object controls the
  314.                     screen writing techniques used throughout the Toolkit. If
  315.                     you do not want to use the Toolkit screen writing algo-
  316.                     rithms, you can create a descendent object and substitute
  317.                     any of the WriteOBJ methods. The ScreenOBJ object contains
  318.                     all the methods for writing formatted data to the screen.
  319.                     There are routines to write text to any location on the
  320.                     screen with right, left or center justification. As well as
  321.                     routines for drawing boxes and lines which automatically use
  322.                     line joining characters if they cross over another line.
  323.                     ScreenOBJ also supports virtual screens which can be slid or
  324.                     popped onto the visible screen at any time. Virtual screens
  325.                     can either be copied from the visible screen or created from
  326.                     scratch. The ScrollOBJ object controls the look and feel of
  327.                     the scroll bars used throughout the Toolkit. The ShadowOBJ
  328.                     controls the look and feel of the shadows used throughout
  329.                     the system. Shadows may be set up or down, right or left,
  330.                     and the depth and color of the shadow can be defined.
  331.  
  332.          totWIN     This unit provides a variety of window objects for writing
  333.                     text in a window. The primary object is WinOBJ, which
  334.                     provides the methods for popping a window onto the display.
  335.                     You can specify the window attributes such as display
  336.                     colors, size and title. When a window is activated, the
  337.                     Toolkit automatically restricts screen writing to within the
  338.                     window area. When the window is removed, the original screen
  339.                     contents are restored and the cursor is repositioned in its
  340.                     original position. The MoveWinOBJ offers all the features of
  341.                     the WinOBJ, but the user can drag or move the window around
  342.                     the screen. The ScrollWinOBJ is a moveable window object
  343.                     that optionally supports horizontal and vertical scroll
  344.                     bars. Finally, the StretchWinOBJ is a moveable, scrollable
  345.                     window that allows the user to stretch the window into
  346.                     different shapes by dragging the lower-right window corner.
  347.  
  348.          totMSG     The totMSG unit provides a suite of objects for displaying
  349.                     pop-up messages to the user. In the next section, this unit
  350.                     forms part of a demonstration on how to use the Toolkit.
  351.  
  352.  
  353. Getting Started                                                              2-7
  354.  
  355. --------------------------------------------------------------------------------
  356.  
  357.          totLINK    One of the least understood elements of contemporary pro-
  358.                     gramming techniques is the creation and maintenance of
  359.                     linked lists. This unit provides a number of objects for
  360.                     building doubly-linked lists. Linked lists allow you to
  361.                     create lists of variable size, unlike arrays where you have
  362.                     to specify the total size of the array at compile time.
  363.                     Linked lists are ideal for reading directories, text files
  364.                     or database records. The linked list engine provides rou-
  365.                     tines for adding, deleting and moving entries in the list,
  366.                     as well as automatic sorting.
  367.  
  368.          totLIST    This unit provides the ListOBJ for displaying arrays or
  369.                     linked lists in a stretchable window. List objects can be
  370.                     used to display text files, data base records, or any list
  371.                     in a window. Lists can be displayed in multiple columns, and
  372.                     the user may optionally select one or more items from the
  373.                     list.
  374.  
  375.          totDIR     Most programs require the user to select a filename. The
  376.                     DirOBJ provides a very quick and convenient way of display-
  377.                     ing a dialog box from which the user can choose a file, or
  378.                     enter a new filename.
  379.  
  380.          totIO1     The most used element of TechnoJock's Turbo Toolkit was the
  381.                     screen IO, i.e. the full screen input routines. The Object
  382.                     Toolkit dedicates three units to full screen input objects.
  383.                     The totIO1 unit provides objects for defining hotkeys,
  384.                     buttons, 3D buttons, check boxes and radio buttons, as well
  385.                     as the IO event manager ActionOBJ.
  386.  
  387.          totIO2     totIO2 provides objects for string input (including lateral
  388.                     scrolling), integer/real/date/hex input with automatic input
  389.                     and range validation, formatted string input for telephone
  390.                     number input and the like, and a list unit for displaying a
  391.                     scrollable list as an input field.
  392.  
  393.          totIO3     totIO3 provides objects for creating memo fields, i.e.
  394.                     multi-line fields that provide full word wrapping. Either a
  395.                     linked list or an array can be assigned to the memo field.
  396.  
  397.          totMENU    The totMENU unit provides objects for displaying full-screen
  398.                     menus, as well as multilevel pull-down menus.
  399.  
  400.          totSTR     The totSTR unit provides a wealth of routines for formatting
  401.                     and converting strings. There are routines to convert inte-
  402.                     gers, reals and HEX to string and vice verse. There are also
  403.                     routines to truncate and extend strings, delete characters
  404.                     from strings, count words, adjust case, etc.
  405.  
  406.  
  407.  
  408. 2-8                                                                 User's Guide
  409.  
  410. --------------------------------------------------------------------------------
  411.  
  412.          totDATE    Date manipulation is a snap with the totDATE unit. This unit
  413.                     provides a set of functions for converting to and from
  414.                     Julian dates. The unit supports eight (count 'em) different
  415.                     date formats for national and international use.
  416.  
  417.          totMISC    This unit contains a potpourri of procedures and functions
  418.                     that didn't fit anywhere else in the Toolkit. There are
  419.                     routines for validating filenames, checking the status of
  420.                     the printer, copying files, range checking integers, and
  421.                     more.
  422.  
  423.  
  424.  
  425. Compiling the Demo Programs - A Quick Start
  426.  
  427.          Enough is enough. You must want to try it by now. If you have not yet
  428.          installed the Toolkit or configured Turbo Pascal, do so now. Full
  429.          instructions were provided earlier in this chapter.
  430.  
  431.          Start the IDE and use the File Change Dir option to change the working
  432.          directory to C:\TURBO\TOTDEMO (or wherever you installed the demo
  433.          files). Choose File Open and load the file DEMMS1.PAS. This filename is
  434.          an abbreviation of DEMO-MESSAGE-ONE, the first demo of the totMSG unit.
  435.  
  436.          Listed below are the file contents:
  437.  
  438.  
  439.  
  440.          program DemoMessage1;
  441.          {demms1}
  442.  
  443.          Uses DOS, CRT,
  444.               totFAST, totMSG;
  445.  
  446.          Var  MsgWin : MessageOBJ;
  447.  
  448.          begin
  449.             Screen.Clear(white,'░'); {paint the screen}
  450.             with MsgWin do
  451.             begin
  452.                Init(1,' Message ');
  453.                AddLine('');
  454.                AddLine('The message unit provides a');
  455.                AddLine('very easy way of displaying');
  456.                AddLine('pop-up messages in a move-');
  457.                AddLine('able window.');
  458.                AddLine('');
  459.                Show;
  460.                Done;
  461.             end;
  462.          end.
  463.  
  464.  
  465.  
  466. Getting Started                                                              2-9
  467.  
  468. --------------------------------------------------------------------------------
  469.  
  470.          The demo program uses methods from the totFAST and totMSG units, so
  471.          they are included in the Uses statement. The VAR statement declares an
  472.          object variable called MsgWin which is of type MessageOBJ. This is the
  473.          main object used for displaying messages.
  474.  
  475.          The first statement of the program:
  476.  
  477.                   Screen.Clear(white,'░');
  478.  
  479.          calls the Clear method (or procedure in the old terminology) from the
  480.          Screen object. Screen is a globally declared object in the totFAST unit
  481.          and controls the writing to the screen. The Clear method is used to
  482.          clear the screen, and the two parameters identify the display color and
  483.          the character used to fill the screen.
  484.  
  485.          The remaining statements all affect the MsgWin object, so to abbreviate
  486.          the code, the "with var do" shortcut is used. Every Toolkit object must
  487.          be initialized before the object methods can be called, and this is
  488.          always achieved with the INIT statement. In the case of MessageOBJ
  489.          objects, INIT must be passed two parameters: the first indicates the
  490.          window border style (1 for a single line box), and the second the
  491.          window title. The AddLine method is called multiple times to add the
  492.          message text. The Show method is then called to instruct the Toolkit to
  493.          display the message. Finally, when the user has removed the message,
  494.          the WinOBJ is disposed of by calling the DONE method (known as a
  495.          destructor). That's all there is to it.
  496.  
  497.          Select Run Run (or press [KEYCAP]) to execute the demo program. Fig 2.2
  498.          illustrates the screen that should be displayed. (If the program did
  499.          not run successfully, refer to the next section for the probable
  500.          cause.)
  501.  
  502.          The message window can be dragged around the screen using the Mouse by
  503.          moving the mouse cursor to the top of the window, and holding down the
  504.          left mouse button. While the button remains depressed the window can be
  505.          dragged around the screen. Using the keyboard, the window can be moved
  506.          by pressing the [KEYCAP] key and then using the cursor keys. The move
  507.          is terminated when [KEYCAP] is pressed.
  508.  
  509.          The message can be removed by clicking the left mouse button on the
  510.          close icon [■] at the top left of the window, by clicking the left
  511.          mouse button on the OK hot spot, or by pressing [KEYCAP] or [KEYCAP].
  512.  
  513.  
  514.  
  515. Figure 2.2                                                              [SCREEN]
  516. The Message Demo
  517. Program
  518.  
  519.  
  520.  
  521. 2-10                                                                User's Guide
  522.  
  523. --------------------------------------------------------------------------------
  524.  
  525. Common Problems
  526.  
  527.          Listed below are a few of the common problems that occur when you first
  528.          try to run the demo programs, together with some quick remedies.
  529.  
  530.  
  531.  
  532.  
  533.          Error 15: File not found (TOTFAST.TPU)
  534.  
  535.          This error is generated when the compiler cannot find the TPU file or
  536.          the associated PAS file. The most likely cause is that you have not
  537.          correctly entered the Toolkit path in the Options Directories Unit
  538.          Directories dialog box. Correct the path and try again.
  539.  
  540.  
  541.          Error 15: File not found (TOTFLAGS.INC)
  542.  
  543.          Make sure that you have correctly added the Toolkit directory to the
  544.          Options Directories Include Files dialog box.
  545.  
  546.  
  547.          Error 15: File not found (TOTFAST.OBJ)
  548.  
  549.          Make sure that you have correctly added the Toolkit directory to the
  550.          Options Directories Object Files dialog box.
  551.  
  552.  
  553.          Error 1: Out of memory
  554.  
  555.          Turbo Pascal lacks sufficient room to compile, link, and execute your
  556.          program. The first obvious step is to remove any unnecessary memory
  557.          resident programs, not forgetting items in CONFIG.SYS like BUFFERS and
  558.          ANSI.SYS. A number of IDE settings influence the amount of memory
  559.          required to run a program. The following actions will minimize the
  560.          memory consumed:
  561.  
  562.          q     Set the Compile Destination to disk.
  563.  
  564.          q     Set the Options Linker to disk.
  565.  
  566.          q     Set the Options Linker mapfile to off.
  567.  
  568.          q     Set the Options Debugger so that both stand-alone and integrated
  569.                options are not selected.
  570.  
  571.          q     Edit the TOTFLAGS.INC file and enable the FINAL directive (dis-
  572.                cussed in the next chapter).
  573.  
  574.          q     If the file you are editing is large, switch to a smaller file,
  575.                and specify the program filename in the Compiler Primary file
  576.                field.
  577.  
  578.          q     If you are using Turbo Pascal version 6, there are a number of
  579.                other ways to save memory, particularly if you have expanded
  580.                memory. Refer to page 147 of the 6.0 User's Guide for further
  581.                information.
  582.  
  583.  
  584. Getting Started                                                             2-11
  585.  
  586. --------------------------------------------------------------------------------
  587.  
  588.          If there is still insufficient memory, remove any unnecessary memory
  589.          resident programs from memory and try again. If you can compile the
  590.          program, but not run it, drop to DOS and execute the program from the
  591.          command line. If all else fails, use the command line version of Turbo
  592.          (TPC or TPCX) to compile the program. Note that all the demo programs
  593.          included in the Toolkit will run from the integrated environment on a
  594.          640k machine when compiled in the FINAL state.
  595.  
  596.  
  597.  
  598.  
  599.          Error 72: Unit file format error (...)
  600.  
  601.          This problem usually occurs when you switch from one version of Turbo
  602.          Pascal to another - TPUs created with one version of Pascal cannot be
  603.          used by another version. The solution is to select Compile Build and
  604.          force the compiler to recreate the TPU files.
  605.