home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TPDB21.ZIP / TPDB.DOC < prev    next >
Encoding:
Text File  |  1989-02-22  |  29.9 KB  |  1,538 lines

  1.  
  2.                 (***********************************)
  3.                 (*             TPDB            *)
  4.                 (*  Turbo Pascal Tools for dBASE    *)
  5.                 (*                            *)
  6.                 (*      Turbo Pascal 5.0 Unit        *)
  7.                 (*     for Accessing dBASE III        *)
  8.                 (*            files.            *)
  9.                 (*                            *)
  10.                 (*         Copyright 1989        *)
  11.                 (*          Brian Corll            *)
  12.                 (*    and Ten B.C. Micro Systems    *)
  13.                 (*        All Rights Reserved        *)
  14.                 (*    dBASE, dBASE III, and dBASE    *)
  15.                 (*    III Plus are registered        *)
  16.                 (* trademarks of Ashton-Tate Corp. *)
  17.                 (*                            *)
  18.                 (*  Turbo Pascal is a registered    *)
  19.                 (*  trademark of Borland Int. Corp.*)
  20.                 (*                            *)
  21.                 (* Version 2.0  February 22, 1989    *)
  22.                 (*                            *)
  23.                 (***********************************)
  24.                 (* Portions copyright 1984,1988 by *)
  25.                 (*     Borland International Corp.    *)
  26.                 (***********************************)
  27.  
  28.  
  29.         TPDB is a toolbox of  Turbo Pascal 5.0 units which allow
  30.         you to  access, index, search,  read and write  database
  31.         files  that were  created with  dBASE III  or III    Plus,
  32.         using 75  Turbo Pascal procedures  and functions written
  33.         specifically for these purposes. At present, it supports
  34.         only    a single    .DBF and    an associated    index (it's own
  35.         brand ofindexes, NOT indexes created by dBASE). You can,
  36.         however, successively  open any number of  .DBF and .NDX
  37.         files. Index keys  can be up to 254  characters, and can
  38.         be  composed  of  multiple  fields    or expressions which
  39.         evaluate  to a    string not  longer than    254 characters.
  40.         Future plans  include support for multiple  indexes , as
  41.         well as multiple .DBF files open concurrently.
  42.  
  43.         All  field types  are supported  except memo    fields.
  44.  
  45.         Questions/comments can  be left for me  on the InterLink
  46.         or  FidoNet Pascal  or dBASE  conferences. More complete
  47.         responses can be had by using InterLink for messages, as
  48.         I then don't have to read messages on line.
  49.  
  50.         This    program is  being distributed  under the Shareware
  51.         concept.
  52.  
  53.         If you like this program    and use it, a registration fee
  54.         of  $10  is  required  for  non-profit users. Commercial
  55.         users  MUST   register  for  a   one-time,  royalty-free
  56.         registration  fee  of  $15.  Registered    users  will  be
  57.         entitled  to upgrades  for a  fee of  $5 per upgrade, to
  58.         cover  shipping   and  handling  costs.     See  the  file
  59.         REGISTER.FRM.
  60.  
  61.  
  62.         NOTA BENE:
  63.         This registration  fee is intended to  cover my personal
  64.         time    and     expense    in  developing,   documenting,  and
  65.         distributing this  toolbox, and does  not constitute the
  66.         sale of the code contained therein.
  67.  
  68.  
  69.         Write to:
  70.  
  71.              Ten B.C. Micro Systems
  72.              Brian Corll
  73.              102 West Locust Street
  74.              Mechanicsburg,PA 17055
  75.              Home : 717-691-0286 Eves. and Weekends
  76.  
  77.         DISCLAIMER
  78.  
  79.         This program is provided "as is" without warranty of any
  80.         kind,  either  express  or  implied,  included  but  not
  81.         limited to  the implied warranty  of merchantability and
  82.         fitness for  a specific purpose.  The entire risk    as to
  83.         the quality and performance of this program is with you.
  84.  
  85.         In no  event will the  author be liable    to you for  any
  86.         damages,  including any  lost profits,  lost savings  or
  87.         other incidental or consequential damages arising out of
  88.         the use of or inability to use this program.
  89.  
  90.         NOTE
  91.  
  92.         Source   code  is   included  as  TPDB.pas,TPDBDate.pas,
  93.         Flash.asm,  and TPDB.asm.  Source code  for TPDBIndx.tpu
  94.         will    not be  released at   any time  as it  consists of
  95.         custom  revisions  to  commercial  source which, despite
  96.         heavy rewriting  on my part, cannot  be released without
  97.         violating the rights of the copyright holder.
  98.  
  99.         CREDITS
  100.  
  101.         Some of the routines in this toolbox are based on public
  102.         domain Pascal and Assembler  code by Juan Vegarra, Brian
  103.         Foley, David Bennett, Scott Bussinger, and John Wood. My
  104.         thanks to them all for laying some of the foundations.
  105.  
  106.  
  107.  
  108.         (***************************************************)
  109.         (*    Globals            in            TPDB.tpu    *)
  110.         (***************************************************)
  111.  
  112.         The globals  in this TPU    use up only  860 bytes of  the
  113.         data segment !
  114.  
  115.  
  116.         Const
  117.  
  118.         CursorLeft = ^S;
  119.         CursorRight = ^D;
  120.         CursorDown = ^X;
  121.         CursorUp = ^E;
  122.         CursorHome =  ^A;
  123.         CursorEnd = ^F;
  124.         PageUp = ^R;
  125.         PageDown = ^C;
  126.         DelKey = ^G;
  127.         TabKey = #9;
  128.         Return = ^M;
  129.         Escape = ^[;
  130.         UpperCase : Boolean = False;
  131.  
  132.         NoDuplicates = 0;
  133.         Duplicates = 1;
  134.         MaxReal = 3.4E37;
  135.         MinReal = 1.5E-45;
  136.         MaxLong = 2147483647;
  137.         MinLong = -2147483647;
  138.  
  139.         The following are color constants to be used with Normal
  140.         and Reverse to set display  and edit colors, using Turbo
  141.         Pascal's constant folding capabilities.
  142.  
  143.         e.g. to display fields in white on a blue background you
  144.         would set Normal := White+BlueBG;  to edit in black on a
  145.         white background you set Reverse := Black+LightGrayBG.
  146.  
  147.         Black          = $00;        DarkGray       = $08;
  148.         Blue          = $01;        LightBlue    = $09;
  149.         Green          = $02;        LightGreen   = $0A;
  150.         Cyan          = $03;        LighBCyan    = $0B;
  151.         Red          = $04;        LightRed       = $0C;
  152.         Magenta      = $05;        LightMagenta = $0D;
  153.         Brown          = $06;        Yellow       = $0E;
  154.         LightGray      = $07;        White       = $0F;
  155.         Blink          = $80;
  156.  
  157.         BlackBG      = $00;
  158.         BlueBG      = $10;
  159.         GreenBG      = $20;
  160.         CyanBG      = $30;
  161.         RedBG          = $40;
  162.         MagentaBG      = $50;
  163.         BrownBG      = $60;
  164.         LightGrayBG  = $70;
  165.  
  166.  
  167.         Type
  168.  
  169.         Str2 = String[2];
  170.         Str4 = String[4];
  171.         Str5 = String[5];
  172.         Str6 = String[6];
  173.         Str8 = String[8];
  174.         Str10 = String[10];
  175.         Str15 = String[15];
  176.         Str20 = String[20];
  177.         Str30 = String[30];
  178.         Str60 = String[60];
  179.         Str80 = String[80];
  180.         Str132 = String[132];
  181.         CharSet = Set of Char;
  182.         ByteSet = Set of Byte;
  183.  
  184.         FileName = String[66];
  185.         DBRecPtr = ^DBType;
  186.         DBType   = Array[1..4000] of Char;
  187.         DBKey    = String[254];
  188.  
  189.         DBHeader = Record
  190.            DBType    : Byte;
  191.            Year       : Byte;
  192.            Month       : Byte;
  193.            Day       : Byte;
  194.            RecCount  : LongInt;
  195.            Location  : Integer;
  196.            RecordLen : Integer;
  197.            Reserved  : Array[1..20] of Byte;
  198.            Terminator : Char;
  199.            end;
  200.  
  201.         DBField = Record
  202.            FieldName     : Array[1..11] of Char;
  203.            FieldType     : Byte;
  204.            FieldAddress : LongInt;
  205.            FieldLen     : Byte;
  206.            FieldDec     : Byte;
  207.            Reserved     : Array[1..14] of Char;
  208.            end;
  209.  
  210.         HeadPtr = ^DBHeader;
  211.         PosPtr = ^DBEditArray;
  212.         FieldPtr = ^FieldArray;
  213.         DBEditArray = Array[1..2,1..128] of Integer;
  214.         FieldArray  = Array[1..128] of DBField;
  215.  
  216.  
  217.         Const
  218.  
  219.            Up   : CharSet = [CursorUp];
  220.            Down : CharSet = [CursorDown,Return];
  221.            Next : CharSet = [Escape];
  222.  
  223.  
  224.  
  225.         Var
  226.            Normal              : Byte;
  227.            Reverse          : Byte;
  228.            UCKey,IndOpen,
  229.                    DBFOpen  : Boolean;
  230.            DBFileName          : FileName;
  231.            DBFile,TempFile      : File;
  232.            Header              : HeadPtr;
  233.            Fields              : FieldPtr;
  234.            Message          : String[80];
  235.            Positions          : PosPtr;
  236.            DBRecord          : DBRecPtr;
  237.            NumFields,ErrCode  : Integer;
  238.            BC,Ch              : Char;
  239.            TotalRecs,DBRecNum,
  240.                           : LongInt;
  241.            Y,M,D,DW          : Word;
  242.            NumLen,Decimals,
  243.              LL,K          : Byte;
  244.            DBIndex          : IndexFile;
  245.            DBIndexName          : FileName;
  246.            Found              : Boolean;
  247.            Start,Stop          : Integer;
  248.  
  249.  
  250.     (************************************************************)
  251.     (*  Documentation for Procedures and Functions in TPDB.tpu    *)
  252.     (************************************************************)
  253.  
  254.         Add function
  255.  
  256.         Function
  257.  
  258.             Adds two numeric fields
  259.  
  260.         Declaration
  261.  
  262.             Add(Field1,Field2 : Byte):string;
  263.  
  264.         Remarks
  265.  
  266.             Field1  and Field2    are the  order numbers  of the
  267.             respective  fields    as  they    appear  in  the .DBF
  268.             structure.
  269.  
  270.         *************************
  271.  
  272.         AddDBKey procedure
  273.  
  274.         Function
  275.             Adds a key string to the index currently in use.
  276.  
  277.         Declaration
  278.             AddDBKey(KeyStr : DBKey);
  279.  
  280.         Remarks
  281.  
  282.              KeyStr  is   any  string  not   longer  than  254
  283.              characters. A field must be converted to a string
  284.              by using the FieldToStr function (q.v.).
  285.  
  286.         Restrictions
  287.  
  288.              Length(KeyStr)  must be  in the  range of  1..254
  289.              characters.  All  expression  must  evaluate to a
  290.              single  string not  more than  254 characters  in
  291.              length.
  292.  
  293.  
  294.         *************************
  295.  
  296.         AddDBRec procedure
  297.  
  298.         Function
  299.  
  300.             Adds a new record to the .DBF file in use.
  301.  
  302.         Declaration
  303.  
  304.             AddDBRec;
  305.  
  306.         Remarks
  307.  
  308.             A new record must first be created with a call to the
  309.             NewDBRec procedure.
  310.  
  311.         ************************
  312.  
  313.         BlockCursor procedure
  314.  
  315.         Function
  316.  
  317.             Turns on a block cursor.
  318.  
  319.         Declaration
  320.  
  321.             BlockCursor;
  322.  
  323.         ************************
  324.  
  325.         BOF function
  326.  
  327.         Function
  328.  
  329.             Returns beginning of file status of a .DBF file.
  330.  
  331.         Declaration
  332.  
  333.             BOF
  334.  
  335.         Result Type
  336.  
  337.             Boolean
  338.  
  339.  
  340.  
  341.         ************************
  342.  
  343.         BuildIndex procedure
  344.  
  345.              Due to  a change in the  indexing procedures from
  346.              version     1.3,  this   procedure    is    no  longer
  347.              implemented  in TPDB.tpu.  It may  be replaced as
  348.              follows:
  349.  
  350.              Var
  351.  
  352.                     J : LongInt;
  353.  
  354.              For J := 1 to TotalRecs do
  355.              begin
  356.  
  357.                     GetDBRec(J);
  358.                     AddDBKey(Key Expression);
  359.              end;
  360.  
  361.              "Key  Expression" is  any key string not  longer
  362.              than  254  characters.    For    example,    two fields
  363.              could be concatenated :
  364.  
  365.  
  366.         AddDBKey(RTrim(LTrim(Upper(FieldToStr(1))))+;
  367.                     RTrim(LTrim(Upper(FieldToStr(2)))));
  368.  
  369.         Here,  fields one  and two  are trimmed    of leading  and
  370.         trailing blanks and then    converted to upper case before
  371.         being concatenated  and passed to  the indexing routines
  372.         as  a  single  string.  See  documentation  for AddDBKey
  373.         procedure.
  374.  
  375.         ************************
  376.  
  377.         CalcDate function
  378.  
  379.         Function
  380.  
  381.             Add or subtract days,months, or years from two dates.
  382.  
  383.         Declaration
  384.  
  385.             CalcDate(InDate:DateStr;Days,Months,Years:
  386.             integer): DateStr;
  387.  
  388.         *************************
  389.  
  390.         CDOW function
  391.  
  392.         Function
  393.  
  394.             Returns    character    day   of   week      -     i.e.
  395.             'Monday','Tuesday',etc.
  396.  
  397.         Declaration
  398.  
  399.             CDOW(InDate : DateStr): DayStr;
  400.  
  401.         *************************
  402.  
  403.         CMonth function
  404.  
  405.         Function
  406.  
  407.             Returns character month - i.e. 'March'
  408.  
  409.         Declaration
  410.  
  411.             CMonth(InDate : DateStr) : Str9;
  412.  
  413.         *************************
  414.  
  415.         CheckScreen procedure
  416.  
  417.         Function
  418.  
  419.             Checks  the  current  field  being  edited against
  420.             minimum and maximum limits of fields displayed.
  421.  
  422.         Declaration
  423.  
  424.             CheckScreen(Var CurrPos:Byte;BC:Char;Up,Down:CharSet;
  425.                         Low,High:Byte);
  426.  
  427.         Remarks
  428.  
  429.             CurrPos is the number of the field currently being
  430.             edited in  the editing loop  (see DEMO.pas for  an
  431.             example).
  432.  
  433.             BC is the terminating character when field editing
  434.             has been completed.
  435.  
  436.             Up and  Down are the character  sets which contain
  437.             the terminating characters which allow you to move
  438.             from one    field to another,  up or down.  In TPDB,
  439.             they are declred as constants, as follows:
  440.  
  441.                 Up    : CharSet = [CursorUp];
  442.                 Down : CharSet = [CursorDown,Return];
  443.  
  444.             I first  saw this concept used  by Juan Vegarra in
  445.             his DER.pas data entry routines.
  446.  
  447.             Low and High  are the low and high  numbers of the
  448.             displayed fields.
  449.  
  450.         ************************
  451.  
  452.         CloseDBFile procedure
  453.  
  454.         Function
  455.  
  456.             Closes the currently open .DBF file.
  457.  
  458.         Declaration
  459.  
  460.             CloseDBFile;
  461.  
  462.         Remarks
  463.  
  464.             This procedure is error-checked.
  465.  
  466.         ************************
  467.  
  468.         CloseDBIndex procedure
  469.  
  470.         Function
  471.  
  472.             Closes the index currently in use.
  473.  
  474.         Declaration
  475.  
  476.             CloseDBIndex;
  477.  
  478.         Remarks
  479.  
  480.             This procedure is error-checked.
  481.  
  482.         ************************
  483.  
  484.         CompDates function
  485.  
  486.         Function
  487.  
  488.             Compares    two dates  and calculates  the number of
  489.             days between them.
  490.  
  491.         Declaration
  492.  
  493.             CompDates(Date1,Date2 : DateStr):Word;
  494.  
  495.         *************************
  496.  
  497.         CTOD function
  498.  
  499.         Function
  500.  
  501.             Converts a  .DBF compatible date  field to a  word
  502.             date type for date arithmetic.
  503.  
  504.         Declaration
  505.  
  506.             CTOD(InDate: DateStr) : DateType;
  507.  
  508.         *************************
  509.  
  510.         CursorOn and CursorOff procedures
  511.  
  512.         Function
  513.  
  514.             Turn cursor on and off
  515.  
  516.         Declaration
  517.  
  518.             CursorOn;
  519.             CursorOff;
  520.  
  521.             Externally declared in Flash.obj.
  522.  
  523.         *************************
  524.  
  525.         DBOpenFile procedure
  526.  
  527.         Function
  528.  
  529.             Opens a .DBF file.
  530.  
  531.         Declaration
  532.  
  533.             DBOpenFile(DBName : FileName);
  534.  
  535.         Remarks
  536.  
  537.             FileName    can    be  up  to  66  chars  long and can
  538.             contain the full path.
  539.  
  540.             This procedure is error-checked.
  541.  
  542.         ************************
  543.  
  544.         DBReset procedure
  545.  
  546.         Function
  547.  
  548.             Resets  a .DBF  file, moving    the file    pointer to
  549.             record 1.
  550.  
  551.         Declaration
  552.  
  553.             DBReset;
  554.  
  555.         Remarks
  556.  
  557.             This procedure is error-checked.
  558.  
  559.         ************************
  560.  
  561.         DelDBKey procedure
  562.  
  563.         Function
  564.  
  565.             Deletes a key string in the index currently in use.
  566.  
  567.         Declaration
  568.  
  569.             DelDBKey(KeyStr : DBKey);
  570.  
  571.         Remarks
  572.  
  573.              See documentation for AddDBKey procedure.
  574.  
  575.  
  576.  
  577.         *************************
  578.  
  579.  
  580.         Deleted function
  581.  
  582.         Function
  583.  
  584.             Returns True if the  curent record has been marked
  585.             for deletion, False if it has not been marked.
  586.  
  587.         Declaration
  588.  
  589.             Deleted : boolean;
  590.  
  591.  
  592.         ************************
  593.  
  594.         Display procedure
  595.  
  596.         Function
  597.  
  598.             Displays    the     current    record  in   a  partially
  599.             formatted manner.
  600.  
  601.         Declaration
  602.  
  603.             Display;
  604.  
  605.         Remarks
  606.  
  607.             Date fields are formatted as MM/DD/YY.
  608.  
  609.         *************************
  610.  
  611.         Divide function
  612.  
  613.         Function
  614.  
  615.             Divides field1 BY field2
  616.  
  617.         Declaration
  618.  
  619.             Divide(Field1,Field2 : Byte):string;
  620.  
  621.         Remarks
  622.  
  623.             Field1  and Field2    are the  order numbers  of the
  624.             respective  fields    as  they    appear  in  the .DBF
  625.             structure.
  626.  
  627.         *************************
  628.  
  629.         DTOC function
  630.  
  631.         Function
  632.  
  633.             Converts a  word date type to  a string compatible
  634.             with .DBF date fields.
  635.  
  636.         Declaration
  637.  
  638.             DTOC(Julian: DateType) : DateStr;
  639.  
  640.         *************************
  641.  
  642.         EOF function
  643.  
  644.         Function
  645.  
  646.             Returns end-of-file status of a .DBF file.
  647.  
  648.         Declaration
  649.  
  650.             EOF
  651.  
  652.         Return Type
  653.  
  654.             Boolean
  655.  
  656.         ************************
  657.  
  658.         FieldToStr function
  659.  
  660.         Functions
  661.  
  662.             Returns a string read from  a specified field in a
  663.             specified record in a .DBF file.
  664.  
  665.         Declaration
  666.  
  667.             FieldToStr(FieldNumber : Byte) : string;
  668.  
  669.         Remarks
  670.  
  671.             FieldNumber is the number of the field in the .DBF
  672.             file structure. Date fields are not formatted.
  673.  
  674.         ************************
  675.  
  676.         FillRecs procedure
  677.  
  678.         Function
  679.  
  680.             Appends a  specified number of blank  records to a
  681.             .DBF file.
  682.  
  683.         Declaration
  684.  
  685.             FillRecs(NumRecs : LongInt);
  686.  
  687.         ************************
  688.  
  689.         Find procedure
  690.  
  691.         Function
  692.  
  693.             Searches for a string in the currently open index.
  694.  
  695.         Declaration
  696.  
  697.             Find(SearchStr : String);
  698.  
  699.         Remarks
  700.  
  701.             If  the  string  is  found,  a  value  of  True is
  702.             returned in the global  boolean variable Found. If
  703.             the    string  is  not  found,    a  value of False is
  704.             returned in Found.
  705.  
  706.         ************************
  707.  
  708.         Flash procedure
  709.  
  710.         Function
  711.  
  712.             Writes  a string  at a  specified row  and column,
  713.             using  a    specified  attribute,  by  direct    video
  714.             access.
  715.  
  716.         Declaration
  717.  
  718.             Flash(Row,Col, Attr:byte; Str : String);
  719.  
  720.         Remarks
  721.  
  722.             When  setting attribute,  constant folding  can be
  723.             used. See color constants in globals section.
  724.  
  725.         ************************
  726.  
  727.         FlashC procedure
  728.  
  729.         Function
  730.  
  731.             Writes a centered string at a specified row, using
  732.             a specified attribute, by direct video access.
  733.  
  734.         Declaration
  735.  
  736.             FlashC(Row,Attr:Byte;Str : String);
  737.  
  738.         Remarks
  739.  
  740.             See remarks for Flash procedure.
  741.  
  742.         ************************
  743.  
  744.         FlashFill procedure
  745.  
  746.         Function
  747.  
  748.             Fills  a specified    screen block  with a specified
  749.             character and attribute.
  750.  
  751.         Declaration
  752.  
  753.             FlashFill(Row,Col,Rows,Cols,Attr    :   Byte;Ch   :
  754.             Char);
  755.  
  756.         Remarks
  757.  
  758.             See remarks for other Flash procedures.
  759.  
  760.         ************************
  761.  
  762.  
  763.         FlushDB procedure
  764.  
  765.         Function
  766.  
  767.             Flushes records currently in memory to disk file.
  768.  
  769.         Declaration
  770.  
  771.             FlushDB;
  772.  
  773.         Remarks
  774.  
  775.             This procedure is error-checked.
  776.  
  777.  
  778.         ************************
  779.  
  780.         FormDate function
  781.  
  782.         Function
  783.  
  784.             Formats a date string as  stored in a .DBF file in
  785.             the 'MM/DD/YY' format.
  786.  
  787.         Declaration
  788.  
  789.             FormDate(InDate:DateStr):String;
  790.  
  791.         *************************
  792.  
  793.         Get procedure
  794.  
  795.         Function
  796.  
  797.             Edits a specified field in the .DBF at a specified
  798.             row and column.
  799.  
  800.         Declaration
  801.  
  802.             Get(FieldNumber,Row,Col : Byte);
  803.  
  804.         Remarks
  805.  
  806.             The following editing keys are active:
  807.  
  808.             Left cursor
  809.             Right Cursor
  810.             Home
  811.             End
  812.             Ctrl-Y (Deletes the entire field.)
  813.  
  814.  
  815.         ************************
  816.  
  817.         GetDBRec procedure
  818.  
  819.         Function
  820.  
  821.             Locates  and reads    a specified  record in  a .DBF
  822.             file.
  823.  
  824.         Declaration
  825.  
  826.             GetDBRec(RecordNumber : LongInt);
  827.  
  828.         ************************
  829.  
  830.  
  831.         GetString procedure
  832.  
  833.         Function
  834.  
  835.             Allows screen    input of a  string, as in  a search
  836.             procedure.
  837.  
  838.         Declaration
  839.  
  840.             GetString(Var Parameter : String; Length, Row, Col
  841.             : Byte) : Char;
  842.  
  843.         ************************
  844.  
  845.         GoBottom procedure
  846.  
  847.         Function
  848.  
  849.             Set the file pointer at the end of file.
  850.  
  851.         Declaration
  852.  
  853.             GoBottom;
  854.  
  855.         ************************
  856.  
  857.         GoTop procedure
  858.  
  859.         Function
  860.  
  861.             Sets the file pointer at the beginning of file.
  862.  
  863.         Declaration
  864.  
  865.             GoTop;
  866.  
  867.         ************************
  868.  
  869.  
  870.         IIF function
  871.  
  872.         Function
  873.  
  874.             Evaluates a boolean variable    and returns a string
  875.             according to the value of the boolean.
  876.  
  877.         Declaration
  878.  
  879.             IIF(BoolVar  : Boolean;IfTrue,IfFalse  : String) :
  880.             String;
  881.  
  882.         ************************
  883.  
  884.  
  885.         JustL function
  886.  
  887.         Function
  888.  
  889.             Left justifies  a string within  a specified field
  890.             length.
  891.  
  892.         Declaration
  893.  
  894.             JustL(InString: String; FieldLen: Integer): String;
  895.  
  896.         ************************
  897.  
  898.         LTrim function
  899.  
  900.         Function
  901.  
  902.             Trims leading spaces from a string.
  903.  
  904.         Declaration
  905.  
  906.             LTrim(InStr: String): String;
  907.  
  908.         *************************
  909.  
  910.  
  911.         Lower function
  912.  
  913.         Function
  914.  
  915.             Converts a string to lower case.
  916.  
  917.         Declaration
  918.  
  919.             Lower(InStr: String): String;
  920.             Externally declared in Flash.obj.
  921.  
  922.         *************************
  923.  
  924.         MakeDBIndex procedure
  925.  
  926.         Function
  927.  
  928.             Creates a new index file but does not build it.
  929.  
  930.         Declaration
  931.  
  932.             MakeDBIndex(DBIndexName : FileName;KeyLen,Status :
  933.             Integer);
  934.  
  935.         Remarks
  936.  
  937.             DBIndexName can be a maximum of 66 chars in length
  938.             and is the full path and name of the index file to
  939.             be created. the key field.
  940.  
  941.             KeyLen is the length of    the key field. Number are
  942.             stored as  strings in .DBF files,    and can thus be
  943.             used as keys without conversion.
  944.  
  945.             Status  is  defined  as     one  of    two    constants:
  946.             NoDuplicates, or Duplicates,    according to whether
  947.             or  not  duplicate    keys  will  be  allowed in the
  948.             index.
  949.  
  950.  
  951.         ************************
  952.  
  953.         Mark procedure
  954.  
  955.         Function
  956.  
  957.             Marks the current record for deletion.
  958.  
  959.         Declaration
  960.  
  961.             Mark;
  962.  
  963.  
  964.         ************************
  965.  
  966.         Max function
  967.  
  968.         Function
  969.  
  970.             Determines the maximum of two integers
  971.  
  972.         Declaration
  973.  
  974.             Max(N1,N2 : Integer) : Integer;
  975.  
  976.         *************************
  977.  
  978.         Min function
  979.  
  980.         Function
  981.  
  982.             Determines the minimum of two integers
  983.  
  984.         Declaration
  985.  
  986.             Min(N1,N2 : Integer) : Integer;
  987.  
  988.         *************************
  989.  
  990.         Mon function
  991.  
  992.         Function
  993.  
  994.             Returns numeric value for the month in a date.
  995.  
  996.         Declaration
  997.  
  998.             Mon(InDate : DateStr) : Byte;
  999.  
  1000.         *************************
  1001.  
  1002.         Mul function
  1003.  
  1004.         Function
  1005.  
  1006.             Multiplies two numeric fields.
  1007.  
  1008.         Declaration
  1009.  
  1010.             Mul(Field1,Field2 : Byte):string;
  1011.  
  1012.         Remarks
  1013.  
  1014.             Field1  and Field2    are the  order numbers  of the
  1015.             respective  fields    as  they    appear  in  the .DBF
  1016.             structure.
  1017.  
  1018.         *************************
  1019.  
  1020.         NewDBRec procedure
  1021.  
  1022.         Function
  1023.  
  1024.             Creates a  new blank record  in memory, ready  for
  1025.             editing.
  1026.  
  1027.         Declaration
  1028.  
  1029.             NewDBRec;
  1030.  
  1031.         ************************
  1032.  
  1033.         NextDBKey procedure
  1034.  
  1035.         Function
  1036.  
  1037.             Moves  file record    pointer to  the record  number
  1038.             associated with the next key in an index.
  1039.  
  1040.         Declaration
  1041.  
  1042.             NextDBKey(KeyStr : DBKey);
  1043.  
  1044.         Remarks
  1045.  
  1046.              See documentation for AddDBKey procedure.
  1047.  
  1048.  
  1049.         ************************
  1050.  
  1051.         NextRec procedure
  1052.  
  1053.         Function
  1054.  
  1055.             Moves  the  file  pointer  to  the next sequential
  1056.             record in the file.
  1057.  
  1058.         Declaration
  1059.  
  1060.             NextRec;
  1061.  
  1062.         ************************
  1063.  
  1064.         OpenDBIndex procedure
  1065.  
  1066.         Function
  1067.  
  1068.             Opens an index for search and updating.
  1069.  
  1070.         Declaration
  1071.  
  1072.             OpenDBIndex(DBIndexName : FileName;KeyLen,Status :
  1073.             Integer);
  1074.  
  1075.         Remarks
  1076.  
  1077.             DBIndexName can be a maximum of 66 chars in length
  1078.             and is the full path and name of the index file to
  1079.             be created. the key field.
  1080.  
  1081.             KeyLen is the length of    the key field. Number are
  1082.             stored as  strings in .DBF files,    and can thus be
  1083.             used as keys without conversion.
  1084.  
  1085.             Status  is  defined  as     one  of    two    constants:
  1086.             NoDuplicates, or Duplicates,    according to whether
  1087.             or  not  duplicate    keys  will  be  allowed in the
  1088.             index.
  1089.  
  1090.  
  1091.         ************************
  1092.  
  1093.         Pack procedure
  1094.  
  1095.         Function
  1096.  
  1097.             Packs  a .DBF    files, removing  records marked for
  1098.             deletion.
  1099.  
  1100.         Declaration
  1101.  
  1102.             Pack;
  1103.  
  1104.         ************************
  1105.  
  1106.         PadL function
  1107.  
  1108.         Function
  1109.  
  1110.             Pads  a  string  with  spaces  on    the    left, to a
  1111.             specified field length.
  1112.  
  1113.         Declaration
  1114.  
  1115.             PadL(InStr: String; FieldLength: Integer): String;
  1116.  
  1117.         ************************
  1118.  
  1119.         PadR function
  1120.  
  1121.         Function
  1122.  
  1123.             Pads  a  string  with  spaces  on    the right, to a
  1124.             specified field length.
  1125.  
  1126.         Declaration
  1127.  
  1128.             PadR(InStr: String; FieldLength: Integer): String;
  1129.  
  1130.  
  1131.         ************************
  1132.  
  1133.         PrevDBKey procedure
  1134.  
  1135.         Function
  1136.  
  1137.             Moves   file    pointer    to    the     record  number
  1138.             corresponding to the previous key in an index.
  1139.  
  1140.         Declaration
  1141.  
  1142.             PrevDBKey(KeyStr : DBKey);
  1143.  
  1144.         Remarks
  1145.  
  1146.             See documentation for AddDBKey procedure.
  1147.  
  1148.  
  1149.         ************************
  1150.  
  1151.         PrevRec procedure
  1152.  
  1153.         Function
  1154.  
  1155.             Moves the file pointer  to the previous sequemtial
  1156.             record in the file.
  1157.  
  1158.         Declaration
  1159.  
  1160.             PrevRec;
  1161.  
  1162.         ************************
  1163.  
  1164.         Prompt procedure
  1165.  
  1166.         Function
  1167.  
  1168.             Displays    a prompt    string at  a specified  row an
  1169.             column, using direct video writes.
  1170.  
  1171.         Declaration
  1172.  
  1173.             Prompt(Row,Col : Byte;PromptStr : Str80);
  1174.  
  1175.         ************************
  1176.  
  1177.         PutDBRec procedure
  1178.  
  1179.         Function
  1180.  
  1181.             Writes the  current editing record  to a specified
  1182.             record number in the .DBF file.
  1183.  
  1184.         Declaration
  1185.  
  1186.             PutDBRec(RecordNumber : LongInt);
  1187.  
  1188.         Remarks
  1189.  
  1190.             Be sure  that the specified  record number is  the
  1191.             same as the one given in the call to GetDBRec.
  1192.  
  1193.         ************************
  1194.  
  1195.  
  1196.         ReadDBHeader procedure
  1197.  
  1198.         Function
  1199.  
  1200.             Reads  the  file  header  of    a  .DBF  file into a
  1201.             buffer.
  1202.  
  1203.         Declaration
  1204.  
  1205.             ReadDBHeader;
  1206.  
  1207.         ************************
  1208.  
  1209.         Recall procedure
  1210.  
  1211.         Function
  1212.  
  1213.             Unmarks a record previously marked for deletion.
  1214.  
  1215.         Declaration
  1216.  
  1217.             Recall;
  1218.  
  1219.         ************************
  1220.  
  1221.         Repl procedure
  1222.  
  1223.         Function
  1224.  
  1225.             Replaces    a specified  field    in  a record  with a
  1226.             specified string.
  1227.  
  1228.         Declaration
  1229.  
  1230.             Repl(FieldNumber : Byte;ReplStr : string);
  1231.  
  1232.         Remarks
  1233.  
  1234.             FieldNumber is the number of the field in the .DBF
  1235.             file structure.  ReplStr is the  string with which
  1236.             the field  is to be replaced.  When replacing date
  1237.             fields, remember  that the date string    must be in
  1238.             the form "19890214".
  1239.  
  1240.         ************************
  1241.  
  1242.         ReplEach procedure
  1243.  
  1244.         Function
  1245.  
  1246.             Replaces    a specified  field in  each record  in a
  1247.             .DBF file with a specified string.
  1248.  
  1249.         Declaration
  1250.  
  1251.             ReplEach(FieldNumber : Byte;ReplStr : String);
  1252.  
  1253.         Remarks
  1254.  
  1255.             FieldNumber is the number of the field in the .DBF
  1256.             file structure.  ReplStr is the  string with which
  1257.             the field  is to be replaced.  When replacing date
  1258.             fields, remember  that the date string    must be in
  1259.             the form "19890214".
  1260.  
  1261.         ************************
  1262.  
  1263.         Replicate function
  1264.  
  1265.         Function
  1266.  
  1267.             Fills  a    string  with  a  specified  number  of a
  1268.             specified character.
  1269.  
  1270.         Declaration
  1271.  
  1272.             Replicate(Ch : Char;Count : word) : String;
  1273.             Externally declared in Flash.obj.
  1274.  
  1275.         ************************
  1276.  
  1277.         RTrim function
  1278.  
  1279.         Function
  1280.  
  1281.             Trims trailing blanks from a string.
  1282.  
  1283.         Declaration
  1284.  
  1285.             RTrim(InStr: String): String;
  1286.  
  1287.         ************************
  1288.  
  1289.         Say procedure
  1290.  
  1291.         Function
  1292.  
  1293.             Displays a particular field at a specified row and
  1294.             column.
  1295.  
  1296.         Declaration
  1297.  
  1298.             Say(FieldNumber,Row,Col : Byte);
  1299.  
  1300.         Remarks
  1301.  
  1302.             FieldNumber is  the position of  the field in  the
  1303.             .DBF file structure.
  1304.  
  1305.         ************************
  1306.  
  1307.         SetColor
  1308.  
  1309.         Function
  1310.  
  1311.             Sets foreground and background color before a call
  1312.             to ClrScr.
  1313.  
  1314.         Declaration
  1315.  
  1316.             SetColor(FG,BG : Byte);
  1317.  
  1318.         ************************
  1319.  
  1320.         ShowStatus procedure
  1321.  
  1322.         Function
  1323.  
  1324.             Displays    status of  .DBF  file,  after a  call to
  1325.             ReadDBHeader.
  1326.  
  1327.         Declaration
  1328.  
  1329.             ShowStatus;
  1330.  
  1331.         ************************
  1332.  
  1333.         Sub function
  1334.  
  1335.         Function
  1336.  
  1337.             Subtracts   two   numeric   fields   -    field2  is
  1338.             subtracted FROM field1.
  1339.  
  1340.         Declaration
  1341.  
  1342.             Sub(Field1,Field2 : Byte) : string;
  1343.  
  1344.         Remarks
  1345.  
  1346.             Field1  and Field2    are the  order numbers  of the
  1347.             respective  fields    as  they    appear  in  the .DBF
  1348.             structure.
  1349.  
  1350.         *************************
  1351.  
  1352.         Sum function
  1353.  
  1354.         Function
  1355.  
  1356.             Sums  a numeric  field in  all records    in a  .DBF
  1357.             file.
  1358.  
  1359.         Declaration
  1360.  
  1361.             Sum(FNo : Byte) : Real;
  1362.  
  1363.  
  1364.  
  1365.         ************************
  1366.  
  1367.         TimeNow function
  1368.  
  1369.         Function
  1370.  
  1371.             Returns current time in formatted string.
  1372.  
  1373.         Declaration
  1374.  
  1375.             TimeNow : TimeStr;
  1376.  
  1377.         *************************
  1378.  
  1379.         Today function
  1380.  
  1381.         Function
  1382.  
  1383.             Returns current date in .DBF date field compatible
  1384.             format.
  1385.  
  1386.         Declaration
  1387.  
  1388.             Today : DateStr;
  1389.  
  1390.         *************************
  1391.  
  1392.         Upper function
  1393.  
  1394.         Function
  1395.  
  1396.             Converts a string to upper case.
  1397.  
  1398.         Declaration
  1399.  
  1400.             Upper(InStr: String): String;
  1401.             Externall declared in Flash.obj.
  1402.  
  1403.         ************************
  1404.  
  1405.         ValidDate function
  1406.  
  1407.             Checks whether  a date is valid,  and returns True
  1408.             or False.
  1409.  
  1410.         Declaration
  1411.  
  1412.             ValidDate(InDate : DateStr): boolean;
  1413.  
  1414.         *************************
  1415.  
  1416.         Wait procedure
  1417.  
  1418.         Function
  1419.  
  1420.             Displays a prompt, 'Press any key to continue...',
  1421.             and waits for a key press.
  1422.  
  1423.         Declaration
  1424.  
  1425.             Wait;
  1426.  
  1427.         ************************
  1428.  
  1429.         WriteDBHeader procedure
  1430.  
  1431.         Function
  1432.  
  1433.             Updates a .DBF file header.
  1434.  
  1435.         Declaration
  1436.  
  1437.             WriteDBHeader;
  1438.  
  1439.  
  1440.         ************************
  1441.  
  1442.         Zap procedure
  1443.  
  1444.         Function
  1445.  
  1446.             Deletes all records in a .DBF file.
  1447.  
  1448.         Declaration
  1449.  
  1450.             Zap;
  1451.  
  1452.         Remarks
  1453.  
  1454.             CAREFUL  ! This  procedure really    does remove all
  1455.             records, completely rewriting the file.
  1456.  
  1457.         ************************
  1458.  
  1459.         (**** Revision History ****)
  1460.  
  1461.         2/7/89 - Version 1.0 released
  1462.  
  1463.         2/8/89 - Version  1.1 - fixed bug in  numeric input that
  1464.         caused  truncation  of  integers.  Also,  recompiled  in
  1465.         $N-,$E+ state  to allow for  8087 emulation on  non-8087
  1466.         machines. Fixed range error in array indexing.
  1467.  
  1468.         Renamed  unit  TPDB10.tpu  to    TPDB.tpu. Future versions
  1469.         will retain this name.
  1470.  
  1471.         2/10/89 -    Version 1.2 -    Modified indexing routines  to
  1472.         allow for index keys up to 254 characters.
  1473.  
  1474.         Added boolean variable, UCKey,  which allows indexes to
  1475.         be created on upper case form of keys.
  1476.  
  1477.         Added procedures Prompt and Upper.
  1478.  
  1479.         Added procedures Flash, FlashC, and FlashFill.
  1480.  
  1481.         Added CheckScreen procedure.
  1482.  
  1483.         Expanded documentation and added demo files.
  1484.  
  1485.         Temporarily  removed  source    code  from  this doc file
  1486.         pending further additions and  decision on which source
  1487.         to include.
  1488.  
  1489.         2/14/89 - Version 2.0 - Added TPDB error handler.
  1490.  
  1491.         Improved documentation.
  1492.  
  1493.         Fixed bug in Display procedure.
  1494.  
  1495.         Added Sum  and FieldToStr functions,  NextRec and
  1496.              PrevRec procedures.
  1497.  
  1498.         Added BOF and EOF functions.
  1499.  
  1500.         Added PrevDBKey and NextDBKey procedures.
  1501.  
  1502.         Added Repl and ReplEach procedures.
  1503.  
  1504.         Added FillRecs procedure.
  1505.  
  1506.  
  1507.         2/22/89 -    Version 2.0 -    Modified indexing routines  to
  1508.         allow key    expressions which evaluate to  a string to be
  1509.         passed to the indexing routines.
  1510.  
  1511.         Improved documentation.
  1512.  
  1513.         Added   new   assembler    string   and    video  handling
  1514.         procedures.
  1515.  
  1516.         Added source for TPDB.tpu.
  1517.  
  1518.         Added  TPDBDate.tpu    -   date    handling    routines,  with
  1519.         source.
  1520.  
  1521.         Added   TPDBMath.tpu  -    mathematical  functions,  with
  1522.         source.
  1523.  
  1524.         Because  of significant  revisions and  additions to the
  1525.         original source, released this version as version 2.0.
  1526.  
  1527.         ********************************************************
  1528.                End of Documentation - TPDB Version 2.0
  1529.                    Copyright 1989  Brian Corll
  1530.                             and
  1531.                      Ten B.C. Micro Systems
  1532.         ********************************************************
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.