home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Pascal / Samples / TBASE601.ARJ / TBASE.DOC < prev    next >
Encoding:
Text File  |  1992-12-20  |  53.0 KB  |  2,155 lines

  1. *********************************************************************
  2.                 Unit Tbase.TPU
  3. *********************************************************************
  4.  
  5. Introduction
  6.  
  7.   This is the main unit of my goal- Defining Objects to handle Dbase III
  8.   and FOXPRO compatible files.
  9.  
  10.   The old existing Programs did not provide satisfactory performance
  11.   to me. Tbase provides facilities to Create Dbase files, Manipulation
  12.   on FIeld Structure and Manipulations on Data.
  13.  
  14.   Tbase allows you to supply Fieldname as argument ( string ) in methods.
  15.   For example, FieldData( 'Cust_No' ) will give you the data of CUST_NO
  16.   in the current record ( if such a field exists.. )
  17.  
  18.   For those who are familiar with using Field numbers in the older
  19.   programs, Tbase provide Methods that accepts field numbers too.
  20.  
  21.   The consistency in these procedures are: any method that accepts
  22.   a field name string as an argument has its counterpart with the same
  23.   structure but with Field number in place of Field Name.
  24.   The name of the method adds a MY in its identifier.
  25.   For example, FieldData accepts Field name string while MYFieldData accept
  26.   Field Number as Argument.
  27.  
  28.   Validity Checks are performed in many methods. If the check fails
  29.   anywhere, the error variable DbError is set to an error number and
  30.   a Bleep sound occurs. No Screen Display is reported nor does the
  31.   program abort. The only case the program is aborted is when
  32.   initializing ( Opening ) a Dbase Object.
  33.  
  34.   The reason for this non-screen report is to avoid the disturbance
  35.   when using graphical environment.
  36.  
  37.  
  38.   Whenever the Dberror is set to a nonzero value ( due to an error )
  39.   any other succeeding calls to any method will be ignored causing
  40.   non-Update of your data or even loose.
  41.  
  42.   So, if your program does make a bleep anywhere, debug it and correct the
  43.   problem. To refer the error and to know causing factor, Refer to the
  44.   table below for meaning of the DbError values. A call to LastDbError
  45.   will return the error value and Clears the DbError.
  46.  
  47.   Dberror is internal to Object. Hence an error in one Dbase object does
  48.   not affect the other Dbase objects method call.
  49.  
  50.       DbError        Error description
  51.  
  52.     0            No Error.
  53.     1            Header Description corrupted.
  54.     2            Disk read Error.
  55.     3            Dbase File Not Found.
  56.     4            Not Enough Memory to allocate.
  57.     5            File Access Denied or could not open file.
  58.     6            Could not Write to disk.( Sector problem? Disk full?)
  59.     7            Field Type is not Numeric.
  60.     9            Field name does not exits or Field Number out of range.
  61.     8            Not valid date.
  62.        10            Data does not match with Field Type.
  63.        11            --
  64.        12            --
  65.        13            Could not Create file.
  66.        14            Dbase file Not Empty.
  67.        15            Invalid Field Type.
  68.        16            Field limit exceeds. Only 255 fields are allowed.
  69.        17            Divisor Field is zero.
  70.  
  71.   When I encounter more error situations, I will add more error values.
  72.   If you find anything.. report them to me..please.
  73.  
  74. *********************************************************************
  75.        Tbase unit Procedures and Functions
  76. *********************************************************************
  77.  
  78.  
  79. Add,  MyAdd
  80.  
  81. Description
  82.      Adds two numeric fields and returns real result.
  83.  
  84. Syntax     
  85.      Function   Add( Field1, Field2 : String) : Real;
  86.      Function MyAdd( Fno1  , Fno2   : Byte  ) : Real;
  87.  
  88. Remarks    
  89.      Field1 and Field2 are the names of the fields.
  90.      Exits with Bleep if  Fields are not numeric and the result
  91.      is set to zero.
  92.  
  93.  
  94. See Also   
  95.      Increment, Decrement, Multiply, Mul, Divide  and their MYs
  96. ----------------------------------------------------------
  97.  
  98. AddBlankRecs
  99.  
  100. Description
  101.      Appends a number of Blank records to the Dbase file.
  102.  
  103. Syntax     
  104.      Procedure AddBlankRecs( NumRecs : LongInt);
  105.  
  106.  
  107.  
  108. See Also   
  109.      AppendBlank , PutDbRec, ClearMemRec
  110. ----------------------------------------------------------
  111.  
  112. AddDbRec
  113.  
  114. Description
  115.      Appends the Memory record to Dbase file.
  116.  
  117. Syntax     
  118.      Procedure AddDbRec;
  119.  
  120. Remarks    
  121.      The difference between AppendBlank and AddDbRec is that
  122.      AddDbrec Dumps the memory record to file while AppendBlank
  123.      Will clear the memory and writes to disk
  124.  
  125. Warning    
  126.      If the memory record is marked for deletion,the added record
  127.      is also written as marked. Undelete before writing.
  128.  
  129. See Also   
  130.      AppendBlank, AddBlankRecs
  131. ----------------------------------------------------------
  132.  
  133. AppendBlank
  134.  
  135. Description
  136.      Adds a Blank Record to Dbase file
  137.  
  138. Syntax     
  139.      Procedure AppendBlank;
  140.  
  141.  
  142. Warning    
  143.      Memory Record will be lost.
  144.  
  145. See Also   
  146.      AddBlankRecs
  147. ----------------------------------------------------------
  148.  
  149. Average , MyAverage
  150.  
  151. Description
  152.      Calculates the Average of a numeric field
  153.  
  154. Syntax     
  155.      Function Average(Field1 : String) : Real;
  156.  
  157. Remarks    
  158.      Checks for Numeric type and for Number of records is > 0.
  159.      If check fails Average is reset to 0.0 and bleeps
  160.  
  161.  
  162. See Also   
  163.      Sum , MySum
  164. ----------------------------------------------------------
  165.  
  166. ChangeField , MyChangeField
  167.  
  168. Description
  169.      Changes the Description of a Field Structure on an EMPTY
  170.      Dbase File.
  171.  
  172. Syntax     
  173.      Procedure ChangeFIeld( Field1, Fname: String; Ftype: Char;
  174.      Flen, Fdec : Byte );
  175.  
  176. Remarks    
  177.      Memory record size is adjusted if needed. Checks for valid
  178.      type Character. C,N,F,D,L are supported. Field length is
  179.      automatic for D and L type. Ignores any length in this case
  180.  
  181. Warning    
  182.      Maximum Field Length is 254. Though 255 is accepted, Foxpro
  183.      and other Dbase KITs do not identify it as a Dbase File.
  184.  
  185. See Also   
  186.      AddField, DeleteField, FieldName, FieldNo, FieldType
  187. ----------------------------------------------------------
  188.  
  189. CopyStructureTo
  190.  
  191. Description
  192.      Creates another Empty Dbase File with the specified name
  193.      copying the current file Structure.
  194.  
  195. Syntax     
  196.      Procedure CopyStructureTo(Fname: String);
  197.  
  198. Remarks    
  199.      Only the Header is copied. Not the Data of the Dbase file.
  200.      The new Empty Dbase file must be explicitly opened for any
  201.      addition of Data.
  202.  
  203.  
  204. See Also   
  205.      CreateDbaseFile, DeleteDbaseFile
  206. ----------------------------------------------------------
  207.  
  208. ClearMemRec
  209.  
  210. Description
  211.      Clears the memory record by Space Characters.
  212.  
  213. Syntax     
  214.      Procedure ClearMemRec;
  215.  
  216. Remarks    
  217.      The old Memory record is written to the current record if
  218.      Autosave is TRUE
  219.  
  220.  
  221. See Also   
  222.      AppendBlank
  223. ----------------------------------------------------------
  224.  
  225. DbBof
  226.  
  227. Description
  228.      Return True if the current Record is the first or nil (in
  229.      case of no record are found).
  230.  
  231. Syntax     
  232.      Function DbBof : Boolean;
  233.  
  234.  
  235.  
  236. See Also   
  237.      DbEof
  238. ----------------------------------------------------------
  239.  
  240. DbDelete
  241.  
  242. Description
  243.      Marks the record as Deleted.
  244.  
  245. Syntax     
  246.      Procedure DbDelete;
  247.  
  248. Remarks    
  249.      Mark not written to file immediately. Autosave will do that.
  250.      If Autosave is OFF, manually update the record to disk.
  251.  
  252.  
  253. See Also   
  254.      Recall , Pack, Zap
  255. ----------------------------------------------------------
  256.  
  257. DbEof
  258.  
  259. Description
  260.      Returns TRUE if the current record is the last record
  261.  
  262. Syntax     
  263.      Function DbEof : Boolean;
  264.  
  265.  
  266.  
  267. See Also   
  268.      DbBof
  269. ----------------------------------------------------------
  270.  
  271. DbfName
  272.  
  273. Description
  274.      Returns the Dbase filename opened in the object.
  275.  
  276. Syntax     
  277.      Function DnfName : String;
  278.  
  279. Remarks    
  280.      Only the name with extension is returned. not the path.
  281.  
  282.  
  283. See Also   
  284.      DbfDir
  285. ----------------------------------------------------------
  286.  
  287. DbfDir
  288.  
  289. Description
  290.      Returns the Path of the Dbase file.
  291.  
  292. Syntax     
  293.      Function DbfDir : String;
  294.  
  295. Remarks    
  296.      Only the path that you have given when initializing the
  297.      object is returned.
  298.  
  299.  
  300. See Also   
  301.      DbfName
  302. ----------------------------------------------------------
  303.  
  304. Dbreset
  305.  
  306. Description
  307.      Resets the Dbase file as newly initialized.
  308.  
  309. Syntax     
  310.      Procedure DbReset;
  311.  
  312. Remarks    
  313.      Current record is set to 1 or 0 (if no data)
  314.  
  315. Warning    
  316.      Memory record is lost if not written to file.
  317.  
  318. See Also   
  319.      Init
  320. ----------------------------------------------------------
  321.  
  322. Decrement , MyDecrement
  323.  
  324. Description
  325.      Subtracts a real value from a specified field and returns
  326.      real result.
  327.  
  328. Syntax     
  329.      Function Decrement( Field1: String; by : real ): Real ;
  330.      Function MyDecrement(Fno: Byte; by : Real ) : Real ;
  331.  
  332. Remarks    
  333.      Checks for Numeric fields and bleeps for warning.
  334.      Negative values in 'by' will ( ofcourse ) be added.
  335.  
  336. Warning    
  337.      Does not check for overflow.
  338.  
  339. See Also   
  340.      Increment , add, Sub and their MY counterparts.
  341. ----------------------------------------------------------
  342.  
  343. Deleted
  344.  
  345. Description
  346.      Returns True if the current record is marked for deletion
  347.  
  348. Syntax     
  349.      Function Deleted : Boolean;
  350.  
  351.  
  352.  
  353. See Also   
  354.      DbDelete, Recall , Pack, Zap
  355. ----------------------------------------------------------
  356.  
  357. DeleteField, MyDeleteField
  358.  
  359. Description
  360.      Removes a field from the structure of an EMPTY Dbase file.
  361.  
  362. Syntax     
  363.      Procedure DeleteField( Field1 : String );
  364.      Procedure MyDeleteField( FNo  : Byte );
  365.  
  366. Remarks    
  367.      Field Numbering is reassigned bringing the later fields one
  368.      step closer. Memory record size is adjusted. If field1 is
  369.      not found Dberror is set to 9 ( Fieldno out of range )
  370.  
  371.  
  372. See Also   
  373.      AddField, ChangeField, CopyStructureTo, CreateDbaseFile
  374. ----------------------------------------------------------
  375.  
  376. AddField, MyAddField
  377.  
  378. Description
  379.      Adds a new Field Description to the Dbase Structure.
  380.  
  381. Syntax     
  382.      Procedure AddField(Fname:String; Ftype:Char;Flen,Fdec:Byte);
  383.      Procedure MyAddfield(Fno:Byte;Ftype:Char; Flen,Fdec : Byte);
  384.  
  385. Remarks    
  386.      Memory Record size is Adjusted. Checks for valid Fieldtype.
  387.      Flen and Fdec are length and decimal sizes. Flen and Fdec
  388.      are ignored for D,L type. Fdec is ignored for non-numeric.
  389.  
  390. Warning    
  391.      Allowed number of Fields are 255. For Foxpro compatibility,
  392.      keep the total record size not exceed 4000bytes.
  393.  
  394. See Also   
  395.      ChangeField , DeleteField and their MY counterparts.
  396. ----------------------------------------------------------
  397.  
  398. Divide, MyDivide
  399.  
  400. Description
  401.      Divides the first Numeric Field value by the second and
  402.      returns real.
  403.  
  404. Syntax     
  405.      Function Divide( Field1,Field2 : String) : Real ;
  406.      Function MyDivide( Fno1, Fno2  : Byte  ) : Real ;
  407.  
  408. Remarks    
  409.      Checks whether the second field data is zero. If so, the
  410.      result is set to 0.0. Checks also for numeric Data in both
  411.      fields. Call LastDberror for error value.
  412.  
  413.  
  414. See Also   
  415.      Multiply, add, Sub and their MY variations
  416. ----------------------------------------------------------
  417.  
  418. Done
  419.  
  420. Description
  421.      Closes the Dbase File and its Object.
  422.  
  423. Syntax     
  424.      Destructor Done;
  425.  
  426. Remarks    
  427.      Frees all the associated memory. Use it with dispose.
  428.      Eg.  Dispose( MyDbf , Done ) ;
  429.  
  430. Warning    
  431.      If not used with Dispose, memories are not freed and the
  432.      Dbase file is NOT closed causing loss of Data.
  433.  
  434. See Also   
  435.      Init
  436. ----------------------------------------------------------
  437.  
  438. FieldCount
  439.  
  440. Description
  441.      Returns the Number of Fields in the Dbase file.
  442.  
  443. Syntax     
  444.      Function FieldCount : Byte;
  445.  
  446.  
  447.  
  448. See Also   
  449.      FieldName, FieldNo, FieldSize, FieldType
  450. ----------------------------------------------------------
  451.  
  452. FieldData, MyFieldData
  453.  
  454. Description
  455.      Returns the Data of the Specified field of current record.
  456.  
  457. Syntax     
  458.      Function FieldData( Field1 : String ) : String ;
  459.      Function MyFieldData(Fno   : Byte   ) : String ;
  460.  
  461. Remarks    
  462.      If  FIeld1  not found Dberror 9 is returned.   Data  is  NOT
  463.      Trimmed. Use Trim, Ltrim or Rtrim in DBStr which trims
  464.      the trailing and leading spaces and nulls.
  465.  
  466. Warning    
  467.      For Date field, the date is formatted according to the
  468.      current format setting.
  469.  
  470. See Also   
  471.      Replace , MyReplace
  472. ----------------------------------------------------------
  473.  
  474. FieldName
  475.  
  476. Description
  477.      Returns the Name of the specified field number.
  478.  
  479. Syntax     
  480.      Function FieldName(Fno : Byte ) : String;
  481.  
  482. Remarks    
  483.      Checks for Fno range (1..FieldCount).
  484.      FieldName Returned is Trimmed ( Unlike FIeldData ).
  485.      Null String Returned if any failure to validity check.
  486.  
  487. Warning    
  488.      Returned name is Upper cased. Eg.  CUST_NO
  489.  
  490. See Also   
  491.      FieldNo, FieldSize, FieldType, FieldCount
  492. ----------------------------------------------------------
  493.  
  494. FieldNo
  495.  
  496. Description
  497.      Returns the Ordinal number of the Specified field name.
  498.  
  499. Syntax     
  500.      Function FieldNo ( Field1: String ) : Byte ;
  501.  
  502. Remarks    
  503.      Field1 can be of any case having trailing and leading spaces
  504.      or nulls. The same theory applies to ALL methods having
  505.      field name string as argument. eg. '  cUst_NO ' is valid.
  506.  
  507. Warning    
  508.      0 is returned if the name is not valid or not found in the
  509.      structure.
  510.  
  511. See Also   
  512.      FIeldName, FIeldSize, FieldType, FIeldCount
  513. ----------------------------------------------------------
  514.  
  515. FieldSize, MyFieldSize
  516.  
  517. Description
  518.      Returns the Field length of an specified field name.
  519.  
  520. Syntax     
  521.      Function FieldSize ( Field1 : String ) : Byte ;
  522.      Function MyFIeldSize( Fno   : Byte   ) : Byte ;
  523.  
  524.  
  525. Warning    
  526.      0 is returned if Field name or number is invalid.
  527.  
  528. See Also   
  529.      FieldName, FieldType, FieldNo, FieldCount, FieldDec
  530. ----------------------------------------------------------
  531.  
  532. FieldType, MyFieldType
  533.  
  534. Description
  535.      Returns the Type of the specified field Name or Number.
  536.  
  537. Syntax     
  538.      Function FieldType( Field1 : String ) : Char ;
  539.      Function MyFieldType(Fno   : String ) : Char ;
  540.  
  541. Remarks    
  542.      Returned Characters are : C - Character; N - Numeric
  543.      F - Floating; D - Date; L - Logical; M - Memo.
  544.  
  545. Warning    
  546.      Although 'M' is identified, no support is provided in this
  547.      version.
  548.  
  549. See Also   
  550.      FiledName, FieldSize, FieldNo, FieldCount, FieldDec
  551. ----------------------------------------------------------
  552.  
  553. FlushDb
  554.  
  555. Description
  556.      Saves the Memory record to the current record.
  557.  
  558. Syntax     
  559.      Procedure FlushDb;
  560.  
  561. Remarks    
  562.      No need to use this if autosave is ON ( TRUE ).
  563.  
  564. Warning    
  565.      Record in the current record is overwritten. (Who Cares !!)
  566.  
  567. See Also   
  568.      PutDbRec, GetDbRec, SetAutoSave
  569. ----------------------------------------------------------
  570.  
  571. GetDbRec
  572.  
  573. Description
  574.      Loads the specified recordNumber into memory record.
  575.  
  576. Syntax     
  577.      Procedure GetDbRec( RecordNumber : LongInt) ;
  578.  
  579. Remarks    
  580.      RecordNumber becomes current record. If AutoSave is ON,
  581.      the previous memory is Flushed to its position if modified.
  582.      Checks for Valid RecordNumber ( 1..RecCount )
  583.  
  584. Warning    
  585.      Exception: Memory record is not updated when loading the
  586.      same record.Eg. GetDbRec(RecNO) will cancel any last update.
  587.  
  588. See Also   
  589.      FlushDb, PutDbRec, SetAutoSave
  590. ----------------------------------------------------------
  591.  
  592. GetFieldHeaders ( Internal )
  593.  
  594. Description
  595.      Reads the Field header to memory ( not to Memory record )
  596.  
  597. Syntax     
  598.      Procedure GetFieldHeaders;
  599.  
  600. Remarks    
  601.      Use this if you feel the Field methods give improper results
  602.      This will not happen anyway.. But just to be on safe side.
  603.      I use this internally.
  604.  
  605.  
  606. See Also   
  607.      ReadHeader, WriteHeader, WriteFields ( all internal )
  608. ----------------------------------------------------------
  609.  
  610. GoBottom
  611.  
  612. Description
  613.      Moves to the last record of the Dbase file and loads it into
  614.      memory record.
  615.  
  616. Syntax     
  617.      Procedure GoBottom;
  618.  
  619. Remarks    
  620.      Ignores if No record found.Previous memory record is flushed
  621.      if Autosave is ON.
  622.  
  623. Warning    
  624.      If AutoSave is OFF, the prevoius memory is lost. Manually
  625.      Flush the memory record if so.
  626.  
  627. See Also   
  628.      GoTop, NextRec, PrecRec, Skip, Locate
  629. ----------------------------------------------------------
  630.  
  631. GoTop
  632.  
  633. Description
  634.      Positions to the First record of the Dbase file and loads
  635.      it into memory record.
  636.  
  637. Syntax     
  638.      Procedure GoTop;
  639.  
  640. Remarks    
  641.      Ignores if no record is found. Prevoius memory record is
  642.      flushed if AutoSave is ON.
  643.  
  644. Warning    
  645.      If Autosave is OFF, the prevoius memory record is lost.
  646.      Manually Flush the memory record if so.
  647.  
  648. See Also   
  649.      GoBottom, NextRec, PrevRec, Skip, Locate
  650. ----------------------------------------------------------
  651.  
  652. Increment, MyIncrement
  653.  
  654. Description
  655.      Adds a real value to specified field data in the current
  656.      record and returns real.
  657.  
  658. Syntax     
  659.      Function Inrement( Field1 : String; By : Real ) : Real ;
  660.      Function MyIncrement( Fno : Byte  ; By : real ) : Real ;
  661.  
  662. Remarks    
  663.      Field1 is the FieldName of the numeric field.'By' is the
  664.      real value incremented.Ignores if FielName is not of Numeric
  665.      type and returns 0 with error bleep.
  666.  
  667.  
  668. See Also   
  669.      Decrement, Add, Sub, SUM, Average, Mul, Multiply
  670. ----------------------------------------------------------
  671.  
  672. Init
  673.  
  674. Description
  675.      Opens the Dbase file loading the necessary information into
  676.      memory.
  677.  
  678. Syntax     
  679.      Constructor Init( Fname : String66) ;
  680.      Eg.  NEW( MyDbf, init('MyDb.Dbf') );
  681.  
  682. Remarks    
  683.      Allocates minimum memory to accommodate information.
  684.      More fields means more memory.
  685.  
  686.  
  687. See Also   
  688.      Done
  689. ----------------------------------------------------------
  690.  
  691. LastDbError
  692.  
  693. Description
  694.      Returns the Last Errorvalue occurred and clears it to zero.
  695.  
  696. Syntax     
  697.      Function LastDberror : Byte ;
  698.  
  699. Remarks    
  700.      Useful to check the error occurred. If the DBerror is not
  701.      cleared by this call, All calls to any method will be
  702.      ignored. This applies to all methods in the Object.
  703.  
  704. Warning    
  705.      Exceptions are Init and Done.
  706.  
  707. ----------------------------------------------------------
  708.  
  709. Locate , MyLocate
  710.  
  711. Description
  712.      Sequentially Searches for a string in a specified field
  713.      and loads the record into memory record if found.
  714.  
  715. Syntax     
  716.      Procedure Locate(Field1: String; SearchStr : String );
  717.      Procedure MyLocate(Fno : Byte  ; SearchStr : String );
  718.  
  719. Remarks    
  720.      The exact search string is searched for match with Trailing
  721.      and leading spaces. If found, the record is loaded into
  722.      memory and the Object local variable Found is set to TRUE.
  723.  
  724. Warning    
  725.      If the field Data is filled with Null for trailing spaces,
  726.      searching with Trailing spaces may not work.
  727.  
  728. See Also   
  729.      GetDbRec
  730. ----------------------------------------------------------
  731.  
  732. Lupdate
  733.  
  734. Description
  735.      Returns the Date that the Dbase file is Last modified.
  736.  
  737. Syntax     
  738.      Function Lupdate : String;
  739.  
  740. Remarks    
  741.      The Date Format is affected by the SetDateFormat in DbDate
  742.      Unit. Refer DbDate unit procedures and function for allowed
  743.      formats and Default format.
  744.  
  745.  
  746. ----------------------------------------------------------
  747.  
  748. Mul, MyMul
  749.  
  750. Description
  751.      Multiplies two numeric fields and returns real.
  752.  
  753. Syntax     
  754.      Function Mul(Field1, Field2: String ) : Real ;
  755.      Function MyMul( Fno1, Fno2 : Byte   ) : Real ;
  756.  
  757. Remarks    
  758.      Checks for validity if Numeric Field type. Does Not Check
  759.      for overflow. ( may be in future versions)
  760.  
  761.  
  762. See Also   
  763.      Add, Increment, Sub, Decrement, Divide, SUM, Average
  764. ----------------------------------------------------------
  765.  
  766. Multiply, MyMultiply
  767.  
  768. Description
  769.      Multipies a Numeric FieldData with a real number and returns
  770.      real.
  771.  
  772. Syntax     
  773.      Function Multiply( Field1 : String; By : real ): Real;
  774.      Function MyMultiply( Fno1 : Byte  ; By : real ): Real;
  775.  
  776. Remarks    
  777.      Checks for Numeric fields. Returns 0 if not valid. Does not
  778.      check for Overflow.
  779.  
  780.  
  781. See Also   
  782.      Add, Increment, Decrement, Sub, Divide, Mul, SUM, Average
  783. ----------------------------------------------------------
  784.  
  785. NextRec
  786.  
  787. Description
  788.      Moves to the next record and loads it into memory record.
  789.  
  790. Syntax     
  791.      Procedure NextRec;
  792.  
  793. Remarks    
  794.      If Autosave is ON the previous memory record is flushed.
  795.  
  796.  
  797. See Also   
  798.      Skip, PrevRec, GoTop, GoBottom
  799. ----------------------------------------------------------
  800.  
  801. Pack
  802.  
  803. Description
  804.      Removes all the marked records for deletion. You no longer
  805.      have any deleted records.
  806.  
  807. Syntax     
  808.      Procedure Pack;
  809.  
  810. Remarks    
  811.      Current record is pointed to the last record.
  812.      Ignores if no record is found deleted ( Ofcourse !)
  813.      Slow as complete read-write occurs.
  814.  
  815. Warning    
  816.      Memory record will be lost if AutoSave is OFF.
  817.      No recovery possible after packed.
  818.  
  819. See Also   
  820.      Zap, DbDelete, Recall
  821. ----------------------------------------------------------
  822.  
  823. PutDbRec
  824.  
  825. Description
  826.      Writes the memory record to specified recordNumber.
  827.  
  828. Syntax     
  829.      Procedure PutDbRec( RecordNumber : LongInt );
  830.  
  831. Remarks    
  832.      Different than FlushDB in the sense that it writes the
  833.      memory record to a different location. Flushes the previous
  834.      memory record to its position if changed.
  835.  
  836. Warning    
  837.      If the memory record is marked for deletion it is written as
  838.      deleted. Recall if you want to.
  839.  
  840. See Also   
  841.      GetDbRec, FlushDb
  842. ----------------------------------------------------------
  843.  
  844. PrevRec
  845.  
  846. Description
  847.      Moves to the previous record and loads it into memory record
  848.  
  849. Syntax     
  850.      Procedure PrevRec;
  851.  
  852. Remarks    
  853.      Ignores if no record found.Previous memory record is written
  854.      to its position if Autosave is ON.
  855.  
  856.  
  857. See Also   
  858.      NextRec, Skip, GoTop, GoBottom
  859. ----------------------------------------------------------
  860.  
  861. Recall
  862.  
  863. Description
  864.      Undeletes the current record if marked.
  865.  
  866. Syntax     
  867.      Procedure Recall;
  868.  
  869. Remarks    
  870.      Does not immediately writes to file. When moving to another
  871.      record, memory is flushed if autosave is ON.
  872.  
  873. Warning    
  874.      If AutoSave is OFF, manually Flush the memory record.
  875.  
  876. See Also   
  877.      DbDelete, Pack
  878. ----------------------------------------------------------
  879.  
  880. RecCount
  881.  
  882. Description
  883.      Returns the Number of Records in the DBase file.
  884.  
  885. Syntax     
  886.      Function RecCount : LongInt ;
  887.  
  888.  
  889.  
  890. See Also   
  891.      RecNo
  892. ----------------------------------------------------------
  893.  
  894. RecNo
  895.  
  896. Description
  897.      Returns the Current record number positioned.
  898.  
  899. Syntax     
  900.      Function RecNo : LongInt;
  901.  
  902.  
  903.  
  904. See Also   
  905.      RecCount , FieldCount
  906. ----------------------------------------------------------
  907.  
  908. RecSize
  909.  
  910. Description
  911.      Returns the Record size of a record in Dbase.
  912.  
  913. Syntax     
  914.      Function RecSize : word;
  915.  
  916. Remarks    
  917.      This size will be adjusted if field structure is modified
  918.      by addfield, changefield or deletefield.
  919.  
  920. Warning    
  921.      If Recsize >4000 bytes, the Dbase file will NOT be Dbase III
  922.      and foxPro compatible. But Tbase3 will recognize.
  923.  
  924. ----------------------------------------------------------
  925.  
  926. ReadHeader ( Internal )
  927.  
  928. Description
  929.      Reads the Header description of the Dbase file.
  930.  
  931. Syntax     
  932.      Procedure ReadHeader;
  933.  
  934. Remarks    
  935.      Checks for valid Header. I use this Internally.
  936.  
  937.  
  938. See Also   
  939.      ReadFieldHeaders, WriteHeader, WriteFields
  940. ----------------------------------------------------------
  941.  
  942. Replace, MyReplace
  943.  
  944. Description
  945.      Replaces a FIeldData with a Formatted string Data.
  946.  
  947. Syntax     
  948.      Procedure Replace( Field1: String; InData : String );
  949.      Procedure MyReplace(Fno  : Byte  ; InData : String );
  950.  
  951. Remarks    
  952.      This is the comprehensive replace for all type of fields.
  953.      Checks if the Type fits with the Indata format.For dateType,
  954.      Checks for valid date also. Numeric are reformatted to fit.
  955.  
  956. Warning    
  957.      Date field requires a formatted date String according to the
  958.      current format setting.
  959.  
  960. See Also   
  961.      ReplaceAll, ReplNum, ReplDate, ReplStr and their MY versions
  962. ----------------------------------------------------------
  963.  
  964. ReplaceAll, MyReplaceAll
  965.  
  966. Description
  967.      Replaces all records' in specified field with indata string.
  968.  
  969. Syntax     
  970.      Procedure ReplaceAll(Field1: String; Indata : String );
  971.      Procedure MyReplaceAll(Fno1: Byte  ; Indata : String );
  972.  
  973. Remarks    
  974.      Comprehensive as Replace. See description for replace above.
  975.      Checks for valid field to match data. Numeric data is
  976.      reformatted to fit with fieldlen and fieldDec.
  977.  
  978. Warning    
  979.      Date Format requirs a formatted Date string.
  980.  
  981. See Also   
  982.      Replace, ReplNum, ReplDate, ReplStr and their MY versions
  983. ----------------------------------------------------------
  984.  
  985. ReplNum, MyReplNum
  986.  
  987. Description
  988.      Replaces a Numeric Field data with a real number.
  989.  
  990. Syntax     
  991.      Procedure ReplNum( Field1 : String; Re : real ) ;
  992.      Procedure MyReplNum( Fno1 : Byte  ; Re : real ) ;
  993.  
  994. Remarks    
  995.      Checks for Numeric field type, Formats the Real number
  996.      according to fieldsize, and field Decimal.
  997.  
  998. Warning    
  999.      Some Decimal accuracy maybe lost if the integral part of the
  1000.      number is beyond the limit.
  1001.  
  1002. See Also   
  1003.      Replace, ReplDate, ReplStr, ReplaceAll and their MY versions
  1004. ----------------------------------------------------------
  1005.  
  1006. ReplDate, MyReplDate
  1007.  
  1008. Description
  1009.      Replaces a Date field with the Indate Data.
  1010.  
  1011. Syntax     
  1012.      Procedure ReplDate(Field1 : String; Indate : Date ) ;
  1013.      Procedure MyReplDate(Fno1 : Byte  ; InDate : Date ) ;
  1014.  
  1015. Remarks    
  1016.      Date Datatype is defined in DbDate. Checks for valid Date
  1017.      and Date FieldType. Ignores if Fails. Formats the Date to
  1018.      the Date String form for the date field.
  1019.  
  1020. Warning    
  1021.      Year in Date record type MUST be in ccxx form. eg. 1993
  1022.  
  1023. See Also   
  1024.      DbDate Unit
  1025. ----------------------------------------------------------
  1026.  
  1027. ReplStr, MyReplStr ( Internal)
  1028.  
  1029. Description
  1030.      Replaces ANY field by a String data.
  1031.  
  1032. Syntax     
  1033.      Procedure ReplStr( Field1: String; Instr : String );
  1034.      Procedure MyReplStr(Fno1 : Byte  ; Instr : String );
  1035.  
  1036. Remarks    
  1037.      No checking is done during the replace. Only it trims the
  1038.      instr to fit with the Fieldsize. Use Replace if you want to
  1039.      replace string fields.
  1040.  
  1041. Warning    
  1042.      Do not use this as you might write wrong Data into a wrong
  1043.      FieldType. Internal
  1044.  
  1045. See Also   
  1046.      Replace, ReplaceAll, ReplNum, ReplStr
  1047. ----------------------------------------------------------
  1048.  
  1049. Save
  1050.  
  1051. Description
  1052.      Writes all the appropriate memory date to file.
  1053.  
  1054. Syntax     
  1055.      Procedure Save;
  1056.  
  1057. Remarks    
  1058.      Almost like flush. But writes the header also.
  1059.      Only for security reason if you are
  1060.      aware of any power failure.
  1061.  
  1062.  
  1063. See Also   
  1064.      FlushDb
  1065. ----------------------------------------------------------
  1066.  
  1067. Skip
  1068.  
  1069. Description
  1070.      Moves to the next record and loads it into memory.
  1071.  
  1072. Syntax     
  1073.      Procedure Skip;
  1074.  
  1075. Remarks    
  1076.      Excactly the same as NextRec. Just to make our old Dbase
  1077.      fans happy!.
  1078.  
  1079.  
  1080. See Also   
  1081.      NextRec, prevRec, GoTop, GoBottom
  1082. ----------------------------------------------------------
  1083.  
  1084. Sub, MySub
  1085.  
  1086. Description
  1087.      Subtracts Field2 Numeric data from Field1 Numeric Data and
  1088.      returns real.
  1089.  
  1090. Syntax     
  1091.      Function Sub(Field1, field2 : String ) : Real ;
  1092.      Function MySub(Fno1, Fno2   : Byte   ) : Real;
  1093.  
  1094. Remarks    
  1095.      Checks for  Numeric fields. Ignores if either one fails and
  1096.      returns zero.
  1097.  
  1098.  
  1099. See Also   
  1100.      Add, Mul, Divide , Inrement, Decrememnt, SUM, Average
  1101. ----------------------------------------------------------
  1102.  
  1103. SUM , MySUM
  1104.  
  1105. Description
  1106.      Adds all the data in the specified Numeric field and returns
  1107.      real.
  1108.  
  1109. Syntax     
  1110.      Function SUM ( Field1 : String ) : Real ;
  1111.      Function MySUM( Fno1  : Byte   ) : Real ;
  1112.  
  1113. Remarks    
  1114.      Checks for Numeric Field Type. Ignores if not and returns 0
  1115.      as result. Does NOT check for overflow. ( In the future )
  1116.  
  1117.  
  1118. See Also   
  1119.      Add, Sub, Mul, Divide, Increment, Decrement, Average
  1120. ----------------------------------------------------------
  1121.  
  1122. WriteHeader ( internal )
  1123.  
  1124. Description
  1125.      Writes the Header to Dbase file.
  1126.  
  1127. Syntax     
  1128.      Procedure WriteHeader;
  1129.  
  1130. Remarks    
  1131.      Last modified date is updated with the header.
  1132.  
  1133.  
  1134. See Also   
  1135.      Readheader, WriteFields, GetFieldHeaders
  1136. ----------------------------------------------------------
  1137.  
  1138. WriteFields ( internal )
  1139.  
  1140. Description
  1141.      Writes the field structure description to the disk.
  1142.  
  1143. Syntax     
  1144.      Procedure WriteFields;
  1145.  
  1146.  
  1147.  
  1148. See Also   
  1149.      GetFieldHeaders
  1150. ----------------------------------------------------------
  1151.  
  1152. Zap
  1153.  
  1154. Description
  1155.      Erases all data in the Dbase file.
  1156.  
  1157. Syntax     
  1158.      Procedure Zap;
  1159.  
  1160. Remarks    
  1161.      Permanently erases all data in the file.
  1162.      Complete recovery is not possible. A partial recovery is
  1163.      tried in this version.
  1164.  
  1165. Warning    
  1166.      Think Twice before you Zap!!
  1167.  
  1168. See Also   
  1169.      Pack, Recover
  1170. ----------------------------------------------------------
  1171.  
  1172. DisplayFields
  1173.  
  1174. Description
  1175.      Just Displays the fieldnames on the screen for reference.
  1176.  
  1177. Syntax     
  1178.      Procedure DisplayFields;
  1179.  
  1180. Remarks    
  1181.      Not much format is is provided as display is NOT the purpose
  1182.      of the Object. Use FieldName, FieldNo, FieldType, FieldSize
  1183.      and FieldDec for field description detail
  1184.  
  1185. Warning    
  1186.      Does not display in Graphical environment.
  1187.  
  1188. See Also   
  1189.      FieldName, FieldSize, FieldType, FieldNo, FieldDec
  1190. ----------------------------------------------------------
  1191.  
  1192. FieldDec , MyFieldDec
  1193.  
  1194. Description
  1195.      Returns the Decimal value of a Numeric field.
  1196.  
  1197. Syntax     
  1198.      Function FieldDec  (Field1: String ) : Byte ;
  1199.      Function MyFieldDec( Fno  : Byte   ) : Byte ;
  1200.  
  1201. Remarks    
  1202.      Zero is returned if the Field Type is not Numeric.
  1203.  
  1204.  
  1205. See Also   
  1206.      FieldName, FieldSize, FieldType, FieldNo, FieldCount
  1207. ----------------------------------------------------------
  1208.  
  1209. Autosaved ( Internal )
  1210.  
  1211. Description
  1212.      Flushes the memory record whenever needed if Autosave is ON.
  1213.  
  1214. Syntax     
  1215.      Procedure Autosaved;
  1216.  
  1217. Remarks    
  1218.      It writes the memory record to file only if any changes have
  1219.      been made since last flush or load. This minimizes the disk
  1220.      write when autosave is ON.
  1221.  
  1222.  
  1223. See Also   
  1224.      SetAutosave
  1225. ----------------------------------------------------------
  1226.  
  1227. SetAutoSave
  1228.  
  1229. Description
  1230.      Sets the autosave status to ON or OFF.
  1231.  
  1232. Syntax     
  1233.      Procedure SetAutosave( auto : Boolean ) ;
  1234.  
  1235. Remarks    
  1236.      If auto is TRUE, Autosave is set to ON otherwise OFF.
  1237.      Default is ON.
  1238.  
  1239. Warning    
  1240.      If autosave is set to OFF, any update to memory record MUST
  1241.      be manually saved to file.
  1242.  
  1243. ----------------------------------------------------------
  1244.  
  1245. *********************************************************************
  1246.                       Unit  DbEdit
  1247. *********************************************************************
  1248. Introduction
  1249.  
  1250.  This unit handles the field and variable editing. GET and MyGET
  1251.  prepares for editing of a dbase file fields while SAY prepares
  1252.  for a variable edit. All these three procedures can be mixed in
  1253.  a group of Editing. Dbread activates the editing.
  1254.  
  1255.  Dbread Updates the Fields automatically upon completing its job.
  1256.  If the fields are from different Dbase files, they are updated
  1257.  accordingly. Variables are kept in their names.
  1258.  
  1259.  Each edit item can have its own color. Just set the edit color
  1260.  for the next item by SetEditColor.
  1261.  
  1262.  Each Edit item can have its own help too. All you have to do is to
  1263.  write a FAR rpocedure that displays Help or anything you want.Then,
  1264.  Set the help procedure through SetHelpProc for the next edit item.
  1265.  Preesing F1 will call the assigned procedure. It is your responsibility
  1266.  to add fancy in that procedure. Eg. Open a winodow and close it.
  1267.  See My.Pas.
  1268.  
  1269.  The help procedure has no argument and ofcourse should
  1270.  be a far  {$F+} procedure {$F-}.
  1271.  If no help is needed for an Item, Use SetHelpProc ( NoHelp ) ;
  1272.  
  1273.  If Crtl_Brk is pressed, Dbread simply exits the editing without
  1274.  updating the Fields. But Variables (SAY) have the effect of change.
  1275.  
  1276.  Field Type, Length and Field Decimal ( for numeric ) are needed for
  1277.  SAY to identify the editing behaviour. Use SetEditDecimal to Set
  1278.  decimal before calling SAY With numerical String.
  1279.  
  1280.  MYGET and GET assume their field type and decimal values from the field
  1281.  being editted. No Picture support is provided for now. ( Too much to ask )
  1282.  DbEdit checks for the validity of the data for its type.
  1283.  
  1284.  
  1285.  Upon completing the edit, DbEdit sets a variable ReadExitCode a value
  1286.  according to the circumstance of the Exit. Different key press gives
  1287.  different values for ReadExitcode. This could be refered to take action
  1288.  according to the keypress.
  1289.  
  1290.  Following are the Keys and ReadExitCode for DbRead.
  1291.  
  1292.       Key             ReadExitCode
  1293.  
  1294.       F10                   3
  1295.       PgUp                  4
  1296.       PgDn                  5
  1297.       Alt_X                 6
  1298.       Ctrl_N                7
  1299.       Ctrl_Brk              8
  1300.       Ctrl_PgUp             9
  1301.       Ctrl_PgDn            10
  1302.       Ctrl_X               11
  1303.       Ctrl_End             12
  1304.  
  1305.  Dbedit is exitted in either of the situations.
  1306.  
  1307.  1. Pressing Enter when editting the last field or variable.
  1308.     ( ReadExitCode = 0 )
  1309.  2. Pressing Down arrow key when editing the last field or var
  1310.     ( ReadExitCode = 2 )
  1311.  3. Pressing any of the keys above from anywhere in editting.
  1312.     ( ReadexitCode as above)
  1313.  
  1314. See my.Pas for how these exitcodes are used to take action.
  1315.  
  1316.  
  1317. *********************************************************************
  1318. Set_Cursor
  1319.  
  1320. Description
  1321.      Sets the Cursor size to specified size from bottom.
  1322.  
  1323. Syntax     
  1324.      Procedure Set_Cursor( n : Byte ) ;
  1325.  
  1326.  
  1327. ----------------------------------------------------------
  1328.  
  1329. SetEditColor
  1330.  
  1331. Description
  1332.      Sets the editing color pair for field line editor.
  1333.  
  1334. Syntax     
  1335.      Procedure SetEditColor( fcolor , bcolor : byte );
  1336.  
  1337. Remarks    
  1338.      fcolor is the forground color and bcolor is background.
  1339.      Every field edit can have its own color pair. Just set the
  1340.      color just before a call to SAY.
  1341.  
  1342.  
  1343. See Also   
  1344.      Say , Dbread
  1345. ----------------------------------------------------------
  1346.  
  1347. Arrow
  1348.  
  1349. Description
  1350.      Reads a keypress and return ascii and scan code.
  1351.  
  1352. Syntax     
  1353.      Procedure Arrow( Var  Ascii , scan : Byte );
  1354.  
  1355. Remarks    
  1356.      Ctrl_Brk has no effect. But Returns Ascii = 3 and scan = 0.
  1357.  
  1358.  
  1359. ----------------------------------------------------------
  1360.  
  1361. edit ( internal )
  1362.  
  1363. Description
  1364.      Allows Editing of a string variable.
  1365.  
  1366. Syntax     
  1367.      Function Edit(var Item : ReaderPtr ) : Word ;
  1368.  
  1369. Remarks    
  1370.      Returns various code values depending on the exit key.
  1371.      The standard editing keys have their own function. See
  1372.      My.Pas for more detail. Allows Editing according to Type.
  1373.  
  1374. Warning    
  1375.      When Date Field is editted, leaving the date Blank will
  1376.      replace the System Todays Date.
  1377.  
  1378. See Also   
  1379.      Say, DBread
  1380. ----------------------------------------------------------
  1381.  
  1382. Say
  1383.  
  1384. Description
  1385.      Prepares a variable for editing. Say is not a displayer.
  1386.      Differ With GET in Say only edits Variable. NOT fields.
  1387.  
  1388. Syntax     
  1389.      Procedure Say( x , y , Len : Word; s : PtrStr;
  1390.      Ftype : FieldTypes);
  1391.  
  1392. Remarks    
  1393.      x,y is the starting position, Len is the length of string,
  1394.      s is the POINTER to the editted string variable.Eg @name
  1395.      Ftype is the type of variable to treat as a field type.
  1396.  
  1397. Warning    
  1398.      Decimal size for Numeric type must be set through
  1399.      SetEditDecimal.
  1400.  
  1401. See Also   
  1402.      Get, DbRead
  1403. ----------------------------------------------------------
  1404.  
  1405. Dbread
  1406.  
  1407. Description
  1408.      Activates all the variables prepared for ediitting by SAY
  1409.      , GET and MyGET
  1410.  
  1411. Syntax     
  1412.      Procedure Dbread;
  1413.  
  1414. Remarks    
  1415.      Called once for a group of SAYs and GETs.Checks for validity
  1416.      of Data for FieldType. Does not allow moving to next field
  1417.      if the check fails.
  1418.  
  1419. Warning    
  1420.      Exits for many key combinations with various ReadEditCode.
  1421.      See my.Pas for more detail.
  1422.  
  1423. See Also   
  1424.      Say
  1425. ----------------------------------------------------------
  1426.  
  1427. SetHelpProc
  1428.  
  1429. Description
  1430.      Sets a procedure for an edit field for Help.
  1431.  
  1432. Syntax     
  1433.      Procedure SetEditProc( Help : HelpProc );
  1434.  
  1435. Remarks    
  1436.      HelpProc is a Far procedure type with no arguments.
  1437.      You can assign help to each editted fields. See My.Pas.
  1438.      Default is NoHelp
  1439.  
  1440. Warning    
  1441.      If your HelpProcedure allocates any memory, make sure to
  1442.      deallocate them before exiting.
  1443.  
  1444. See Also   
  1445.      NoHelp
  1446. ----------------------------------------------------------
  1447.  
  1448. NoHelp
  1449.  
  1450. Description
  1451.      A null Help Procedure that does nothing.
  1452.  
  1453. Syntax     
  1454.      {$F+} Procedure NoHelp; {$F-}
  1455.  
  1456. Remarks    
  1457.      This is the Default Help procedure. An assignment to a user
  1458.      defined help procedure will be effective until it turned off
  1459.      Use SetHelpProc(Nohelp) to get back to Default.
  1460.  
  1461.  
  1462. See Also   
  1463.      SetHelpProc
  1464. ----------------------------------------------------------
  1465.  
  1466. Get
  1467.  
  1468. Description
  1469.      Prepares a Field of a Dbase File for editting.
  1470.      Handles Multiple Dbase files' Fields together.
  1471.  
  1472. Syntax     
  1473.      Procedure GET(x, y: Word; DbObj: DataObject; Field: String);
  1474.  
  1475. Remarks    
  1476.      DbObj is the pointer to the Dbase object. 'Field' is a Fiel
  1477.      in that object. You can give different Dbobj in a group of
  1478.      editting. They will be updated accordingly. Clever.. huh..
  1479.  
  1480. Warning    
  1481.      If the Field name is not valid, a bleep warns. Take care at
  1482.      this point as the data will not be updated in this case.
  1483.  
  1484. See Also   
  1485.      SAY , DbRead
  1486. ----------------------------------------------------------
  1487.  
  1488. MyGET
  1489.  
  1490. Description
  1491.      Prepares a Field for Editting and updates to the proper data
  1492.      base file when editting finishes.
  1493.  
  1494. Syntax     
  1495.      Procedure MyGET ( x,y, Dbase : DataObject ; Fno : Byte );
  1496.  
  1497. Remarks    
  1498.      This is just the My version of GET for those who uses the
  1499.      Field Number instead of FieldName itself. Or in otherwords,
  1500.      All the MY Versions are the TPDB fans.
  1501.  
  1502. Warning    
  1503.      If the Fno is out of range then the data will not be updated.
  1504.      ( Where to update? ) Thus you loose the editted data.
  1505.  
  1506. See Also   
  1507.      SAY , GET DbRead
  1508. ----------------------------------------------------------
  1509.  
  1510. ***********************************************************************
  1511.                           Unit  DbDate.TPU
  1512. ***********************************************************************
  1513.  
  1514. Introduction
  1515.  
  1516.  This unit performs most of the operations on date.
  1517.  
  1518.  Conversion between the three type of date formats are provided.
  1519.  Thse three fields are:
  1520.  
  1521.    Field        : The format that the Dbase file have date as Data.
  1522.                   field format is of the form 'ccyymmdd'. eg.  19921223 
  1523.    Display      : The format for display. This has many forms according
  1524.                   to country. Following are the formats supported in this
  1525.                   unit.
  1526.  
  1527.           French    :  dd/mm/yy
  1528.           German    :  dd.mm.yy
  1529.           Italian   :  dd-mm-yy
  1530.           British   :  dd/mm/yy
  1531.           American  :  mm/dd/yy
  1532.           Ansi      :  yy.mm.dd
  1533.  
  1534.     Pascal      : The pascal format is the record containing the
  1535.           three fields Year, month and day with year in 19yy.
  1536.           Date = Record
  1537.                 Year, Month , Day : Word ;
  1538.              End;
  1539.  
  1540.  I name Field   for Field format;
  1541.     Format  for Display format;
  1542.     Date    for Pascal format to name the convertion procedures.
  1543.  
  1544.  Thus, FieldToFormat will convert the filed format to Display format;
  1545.        DateToField  wil convert the Pascal format to Field Format
  1546.        and so on.
  1547.  
  1548.  SetDateFormat will set the current display format.
  1549.  
  1550.  
  1551. ***********************************************************************
  1552. Julian
  1553.  
  1554. Description
  1555.      Returns the classic Julian number of a Date.
  1556.  
  1557. Syntax     
  1558.      Function Julian ( d : Date ) : LongInt;
  1559.  
  1560. ----------------------------------------------------------
  1561.  
  1562. DaysBetween
  1563.  
  1564. Description
  1565.      Returns the number of days between two dates.
  1566.  
  1567. Syntax     
  1568.      Function DaysBetween( d1, d2 : Date ) : LongInt;
  1569.  
  1570.  
  1571. Warning    
  1572.      Negative days are reported if d2 is earlier d1.
  1573.  
  1574. See Also   
  1575.      DateAfter
  1576. ----------------------------------------------------------
  1577.  
  1578. MDY
  1579.  
  1580. Description
  1581.      Formats a date to Month dd, 19yy format
  1582.  
  1583. Syntax     
  1584.      Function MDY( d : Date ) : String ;
  1585.  
  1586. Remarks    
  1587.      Example.  const d : date = ( Year: 1992; Month:11; day:28);
  1588.      Begin Writeln( MDY( d ) ) End.
  1589.      result:   November 28, 1992
  1590.  
  1591.  
  1592. See Also   
  1593.      DateFormat
  1594. ----------------------------------------------------------
  1595.  
  1596. DateToField
  1597.  
  1598. Description
  1599.      Converts a date to a Dbase Date Field String type.
  1600.  
  1601. Syntax     
  1602.      Function DateToField( d : Date ) : String;
  1603.  
  1604. Remarks    
  1605.      The Dbase Date Format is : 19yymmdd
  1606.  
  1607. Warning    
  1608.      Checks valid date. Nul string returned if fails.
  1609.  
  1610. See Also   
  1611.      FieldToDate
  1612. ----------------------------------------------------------
  1613.  
  1614. DateToFormat
  1615.  
  1616. Description
  1617.      Formats a Date to a string format for display.
  1618.  
  1619. Syntax     
  1620.      Function DateToFormat( d : Date ) : Str8 ;
  1621.  
  1622. Remarks    
  1623.      The format wanted is selected through SetDateFormat.
  1624.  
  1625.  
  1626. See Also   
  1627.      DateToField, FieldToDate, FormatToDate, FieldToFormat
  1628. ----------------------------------------------------------
  1629.  
  1630. SetDateFormat
  1631.  
  1632. Description
  1633.      Sets the default date format for conversion.
  1634.  
  1635. Syntax     
  1636.      Procedure SetDateFormat( form : Byte ) ;
  1637.  
  1638. Remarks    
  1639.      Any conversion the returns or involves formatted date is
  1640.      affected by the current format. In Tbase unit, FieldData,
  1641.      Replace are affected. SAY in Dbedit is also affected.
  1642.  
  1643. See Also   
  1644.      FormatToDate, FormatToField, FieldToFormat, DateToFormat
  1645. ----------------------------------------------------------
  1646.  
  1647. FieldToDate
  1648.  
  1649. Description
  1650.      Converts a Dbase Date Format to a Pascal Date type.
  1651.  
  1652. Syntax     
  1653.      Procedure FieldToDate( s : String; Var d : date );
  1654.  
  1655. See Also   
  1656.      DateToField
  1657. ----------------------------------------------------------
  1658.  
  1659. DayofWeek
  1660.  
  1661. Description
  1662.      Returns the Day of week in number for the specified date
  1663.  
  1664. Syntax     
  1665.      Function DayOfweek( d : Date ) : Word;
  1666.  
  1667. Remarks    
  1668.      The returned number  is between 0 and 6 with 0 for Sunday.
  1669.  
  1670.  
  1671. See Also   
  1672.      NameOfWeek
  1673. ----------------------------------------------------------
  1674.  
  1675. NameOfWeek
  1676.  
  1677. Description
  1678.      Returns the name of week for the day.
  1679.  
  1680. Syntax     
  1681.      Function NameOfWeek( d : date ) : Str10 ;
  1682.  
  1683. Remarks    
  1684.      Sunday, Monday.. Etc
  1685.  
  1686.  
  1687. See Also   
  1688.      DayOfWeek
  1689. ----------------------------------------------------------
  1690.  
  1691. DateAfter
  1692.  
  1693. Description
  1694.      Returns the date after a certain days
  1695.  
  1696. Syntax     
  1697.      Procedure DateAfter( Var D : Date; days : LongInt );
  1698.  
  1699. Remarks    
  1700.      Negative days willadvance the date as usual
  1701.  
  1702. Warning    
  1703.      The previous date will be lost. Be careful.
  1704.  
  1705. ----------------------------------------------------------
  1706.  
  1707. Today
  1708.  
  1709. Description
  1710.      Returns the Date of the System Clock in Date type
  1711.  
  1712. Syntax     
  1713.      Procedure Today ( Var d : day );
  1714.  
  1715.  
  1716.  
  1717. ----------------------------------------------------------
  1718.  
  1719. ValidDate
  1720.  
  1721. Description
  1722.      Checks for the validity of a date and returns TRUE if valid.
  1723.  
  1724. Syntax     
  1725.      Function ValidDate( d : Date ) : Boolean ;
  1726.  
  1727.  
  1728.  
  1729. ----------------------------------------------------------
  1730.  
  1731. FormatToDate
  1732.  
  1733. Description
  1734.      Converts a formatted date to a Pascal date.
  1735.  
  1736. Syntax     
  1737.      Procedure FormatToDate( form: String;Var d : Date);
  1738.  
  1739. Remarks    
  1740.      Form is assumed to be a formatted date according to the
  1741.      current Date format set through SetDateFormat.
  1742.  
  1743.  
  1744. See Also   
  1745.      DateToFormat, FormatToField
  1746. ----------------------------------------------------------
  1747.  
  1748. FieldToFormat
  1749.  
  1750. Description
  1751.      Converts a Dbase Date format to Display Date format
  1752.  
  1753. Syntax     
  1754.      Function FieldToFormat( Fielddate : String) : String;
  1755.  
  1756. Remarks    
  1757.      Returned format is affected by Current format set through
  1758.      SetDateFormat.
  1759.  
  1760.  
  1761. See Also   
  1762.      FormatToField
  1763. ----------------------------------------------------------
  1764.  
  1765. FormatToField
  1766.  
  1767. Description
  1768.      Converts a Display Date Format to a Dbase Date Format.
  1769.  
  1770. Syntax     
  1771.      Function FormatToDate( Form : String ) : String;
  1772.  
  1773. Remarks    
  1774.      Form is a formatted Date String according to the current
  1775.      SetDateFormat.
  1776.  
  1777.  
  1778. See Also   
  1779.      FieldToFormat
  1780. ----------------------------------------------------------
  1781.  
  1782. DaysFromZero ( Internal )
  1783.  
  1784. Description
  1785.      Returns the number of days from a certain date.
  1786.  
  1787. Syntax     
  1788.      Function DaysFromZero( d : Date ) : LongInt;
  1789.  
  1790. Remarks    
  1791.      This is the serial day from the given date. This is 1721119
  1792.      days Less than the classical Julian Date.
  1793.  
  1794.  
  1795. See Also   
  1796.      Julian
  1797. ----------------------------------------------------------
  1798.  
  1799. **********************************************************************
  1800.               Unit  DbStr.TPU
  1801. **********************************************************************
  1802.  
  1803. Introduction
  1804.  
  1805.      String manipulations are done in this unit along with the three
  1806.  sound procedures: Beep, bleep and warnerror. ( Why wasting another unit for
  1807.  these? )
  1808.  
  1809.  Ltrim, Rtrim and Trim are used to delete the trailing and leading
  1810.  spaces and Nulls.
  1811.  
  1812.  Upper converts a string to Uppercase.
  1813.  
  1814.  Thats it..
  1815.  
  1816. **********************************************************************
  1817.  
  1818. Beep
  1819.  
  1820. Description
  1821.      Beeps a sound with the specified frequency
  1822.  
  1823. Syntax     
  1824.      Procedure Beep(Frequency : word);
  1825.  
  1826.  
  1827.  
  1828. See Also   
  1829.      Bleep, Warnerror
  1830. ----------------------------------------------------------
  1831.  
  1832. Bleep
  1833.  
  1834. Description
  1835.      Beeps twice with different frequency ( 1000, 2000 )
  1836.      making a Bleep
  1837.  
  1838. Syntax     
  1839.      Procedure Bleep;
  1840.  
  1841.  
  1842.  
  1843. See Also   
  1844.      Warerror, Beep
  1845. ----------------------------------------------------------
  1846.  
  1847. WarnError
  1848.  
  1849. Description
  1850.      Bleeps if the argument is non zero.
  1851.  
  1852. Syntax     
  1853.      Procedure WarnError ( Error : byte );
  1854.  
  1855. Remarks    
  1856.      Good to add with procedures that might have errors at
  1857.      anytime.
  1858.  
  1859.  
  1860. See Also   
  1861.      Beep , Bleep
  1862. ----------------------------------------------------------
  1863.  
  1864. Fileexists
  1865.  
  1866. Description
  1867.      Checks whether the specified file exist in the directory or
  1868.      not. Rturns TRUE if exists.
  1869.  
  1870. Syntax     
  1871.      Function Fileexists( Fname : String) : Boolean;
  1872.  
  1873.  
  1874. Warning    
  1875.      Does not Search for file in any path.
  1876.  
  1877. ----------------------------------------------------------
  1878.  
  1879. Rtrim
  1880.  
  1881. Description
  1882.      Trims the specified string from right. ( trailing )
  1883.      and returns the trimmed string.
  1884.  
  1885. Syntax     
  1886.      Function Rtrim( s : String ) : String ;
  1887.  
  1888. Remarks    
  1889.      Spaces( 32 ) and Nulls ( 0 ) on the right are trimmed.
  1890.  
  1891. Warning    
  1892.      Ignores if string is NUL ( '' ).
  1893.  
  1894. See Also   
  1895.      Ltrim, Trim
  1896. ----------------------------------------------------------
  1897.  
  1898. Ltrim
  1899.  
  1900. Description
  1901.      Trims the leading spaces from the specified string and
  1902.      returns string.
  1903.  
  1904. Syntax     
  1905.      Function Ltrim ( s : String ) : string ;
  1906.  
  1907. Remarks    
  1908.      Spaces and nulls are trimmed.
  1909.  
  1910.  
  1911. See Also   
  1912.      Rtrim, Trim
  1913. ----------------------------------------------------------
  1914.  
  1915. Trim
  1916.  
  1917. Description
  1918.      Trims a string from Both side.
  1919.  
  1920. Syntax     
  1921.      Function Trim ( s : String ) : String ;
  1922.  
  1923. Remarks    
  1924.      This is the combination of bothe Ltrim and Rtrim.
  1925.      i.e.        Trim (s) := Ltrim( Rtrim(s)) ;
  1926.  
  1927.  
  1928. See Also   
  1929.      Ltrim , Rtrim
  1930. ----------------------------------------------------------
  1931.  
  1932. NumValid
  1933.  
  1934. Description
  1935.      Checks whether a Numeric String is valid or not. If valid
  1936.      the value is returned in Re else Re is set to zero.
  1937.  
  1938. Syntax     
  1939.      Function NumValid( s : String; Var Re : Real ) : Boolean ;
  1940.  
  1941. Remarks    
  1942.      This is used to check the validity of the Numeric string in
  1943.      replace in Tbase.
  1944.  
  1945. Warning    
  1946.      Unlike in Pascal Val procedure, Spaces in Both sides are
  1947.      allowed here. Do NOT waste your code trimming before call.
  1948.  
  1949. ----------------------------------------------------------
  1950.  
  1951. NumFormat
  1952.  
  1953. Description
  1954.      Formats a real number with specified size and decimals and
  1955.      return string.
  1956.  
  1957. Syntax     
  1958.      Function NumFOrmat( re : Real; Len, Deci : Integer ):String;
  1959.  
  1960. Remarks    
  1961.      Used in Replace method to format numeric data in Tbase.
  1962.  
  1963. Warning    
  1964.      Only 11 digits of decimals are significant in Deci.
  1965.  
  1966. See Also   
  1967.      Cstr
  1968. ----------------------------------------------------------
  1969.  
  1970. Cstr
  1971.  
  1972. Description
  1973.      Formats a real number as in NumFormat and fills the spaces
  1974.      by '0'.
  1975.  
  1976. Syntax     
  1977.      Function Cstr( Re : Real; Len,Dec : Integer ) : String;
  1978.  
  1979. Remarks    
  1980.      Used to format Date string with leading zeros.
  1981.      eg. month = 03.
  1982.  
  1983.  
  1984. ----------------------------------------------------------
  1985.  
  1986. Upper
  1987.  
  1988. Description
  1989.      Converts the specified string to upper case.
  1990.  
  1991. Syntax     
  1992.      Function Upper ( s : string ) : String ;
  1993.  
  1994. ----------------------------------------------------------
  1995. ***********************************************************************
  1996.             Unit DbWin.TPU
  1997. ***********************************************************************
  1998.  
  1999. Introduction
  2000.  
  2001.   Just some simple text windowing routines. Frankly, I am not interested
  2002.   in Text mode windowing. So any inconvenience is upto you. The routines
  2003.   are modifications of TP 6.0 examples Win.Pas and WinDemo.Pas.
  2004.   So, anyone asking the source code of all my units will not be given
  2005.   the codes of Dbwin. Sorry!.. Ask Borland.
  2006.  
  2007.   InitWindow initializes the windowing variables along with filling
  2008.   the screen with a block character. The colors are limitted in this
  2009.   desktop. Soory.. I am not that intersted to develop it more. I am
  2010.   doing somethign in Graphics now..
  2011.  
  2012. ************************************************************************
  2013.  
  2014. InitWindow
  2015.  
  2016. Description
  2017.      Initializes the window variables and fill the screen with
  2018.      a block chracter making a DeskTop look.
  2019.  
  2020. Syntax     
  2021.      Procedure InitWindow( s : String );
  2022.  
  2023. Remarks    
  2024.      String s is displayed on the top line of the screen as a
  2025.      heading. Use WriteHeader for a centered Heading.
  2026.  
  2027.  
  2028. See Also   
  2029.      WriteHeader, WriteFoot, OpenWindow
  2030. ----------------------------------------------------------
  2031.  
  2032. OpenWindow
  2033.  
  2034. Description
  2035.      Opens a window on the screen with Title and Foot.
  2036.  
  2037. Syntax     
  2038.      Procedure OpenWindow( x,y,x1,y1: Byte; Title, foot : String;
  2039.      Framecol, wincol : Word );
  2040.  
  2041. Remarks    
  2042.      (x,y) ,(x1,y1) are the topleft and bottomright corners.
  2043.      Title is displayed in middle of top border.Foot is displayed
  2044.      on the right bottom. Framecol and wincol are colors to win.
  2045.  
  2046. Warning    
  2047.      Allowed values for (x,y) and (x1,y1) are (0,0) to (79,24)
  2048.  
  2049. See Also   
  2050.      CloseWindow
  2051. ----------------------------------------------------------
  2052.  
  2053. CloseWindow
  2054.  
  2055. Description
  2056.      Closes the recent window on the stack.
  2057.  
  2058. Syntax     
  2059.      Procedure CloseWindow;
  2060.  
  2061. Remarks    
  2062.      The topmost window is closed and its allocated memory is
  2063.      released. The next window becomes active with double line
  2064.      border.
  2065.  
  2066.  
  2067. See Also   
  2068.      OpenWIndow
  2069. ----------------------------------------------------------
  2070.  
  2071. CursorOff
  2072.  
  2073. Description
  2074.      Turns text the cursor OFF ( invisible )
  2075.  
  2076. Syntax     
  2077.      Procedure CursorOff;
  2078.  
  2079.  
  2080.  
  2081. See Also   
  2082.      CursorOn
  2083. ----------------------------------------------------------
  2084.  
  2085. CursorOn
  2086.  
  2087. Description
  2088.      Turns the cursor ON ( Blinking )
  2089.  
  2090. Syntax     
  2091.      Procedure CursorOn;
  2092.  
  2093.  
  2094.  
  2095. See Also   
  2096.      CursorOff
  2097. ----------------------------------------------------------
  2098.  
  2099. WriteHeader
  2100.  
  2101. Description
  2102.      Writes the heading in the Top line of the screen.
  2103.  
  2104. Syntax     
  2105.      Procedure WriteHeader( s : String );
  2106.  
  2107. Remarks    
  2108.      Directly writes on the screen memory thus independent of any
  2109.      windows. Colors is taken from Crt ( TextAttr )
  2110.      Text is centered.
  2111.  
  2112. Warning    
  2113.      If Length(s) is > 80, s is trimmed to fit.
  2114.  
  2115. See Also   
  2116.      WriteFoot
  2117. ----------------------------------------------------------
  2118.  
  2119. WriteFoot
  2120.  
  2121. Description
  2122.      Writes a foot note on the DeskTop.
  2123.  
  2124. Syntax     
  2125.      Procedure WriteFoot( s : String );
  2126.  
  2127. Remarks    
  2128.      Window independent. Colors is taken from TextAttr.
  2129.      Text is Left adjusted. Add spaces to make alligned.
  2130.  
  2131. Warning    
  2132.      Trimmed to fit the line.
  2133.  
  2134. See Also   
  2135.      WriteHeader.
  2136. ----------------------------------------------------------
  2137.  
  2138. DispWline
  2139.  
  2140. Description
  2141.      Writes a string on the screen through direct memory access.
  2142.  
  2143. Syntax     
  2144.      Procedure DispWline( r, c, col : word ;var s : string );
  2145.  
  2146. Remarks    
  2147.      Window Independant.
  2148.  
  2149.  
  2150. ----------------------------------------------------------
  2151.  
  2152.  
  2153.  
  2154. Nasir Haniffa ( ACDH083@SAUPM00.BITNET )
  2155.