home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / BMULKEY.ZIP / MULKEY.DOC < prev    next >
Encoding:
Text File  |  1988-05-05  |  32.3 KB  |  659 lines

  1.  
  2.  
  3.                       DOCUMENTATION FOR THE MULKEY SYSTEM
  4.  
  5.      Copyright 1986, 1987 and 1988 by Mark R. Boler - All Rights Reserved.
  6.      This  source  code  must  not  be  distributed  without prior written
  7.      permission.
  8.  
  9.                             !! IMPORTANT NOTICE !!
  10.  
  11.      These routines require the use of  the Btrieve file manager system by
  12.      Softcraft,  Version 4.10  or equivalent.  It must  have this  version
  13.      since  earlier   versions  don't  deal  with   Turbo  Pascal  strings
  14.      correctly. These  routines were tested  as well as  could be expected
  15.      but I  assume no responsibility  for any errors,  omissions, problems
  16.      etc. It  is your responsibility  to test these  routines thouroughly!
  17.      This code is provided "AS IS"  without warranty of any kind. Further,
  18.      neither PMI nor Mark R. Boler  warrant, guarantee, or make any claims
  19.      of suitability to a particular purpose with reguard to this software.
  20.      The entire risk as to the results and/or performance of this software
  21.      is assumed by you. Neither PMI nor  Mark R. Boler shall be liable for
  22.      any direct, indirect, consequential, or incidental damages including,
  23.      but  not limited  to, loss  of profits,  loss of  information and the
  24.      like.  By  using  this  software  you  agree  to  the above terms and
  25.      condiions.
  26.  
  27.       -=-=-=-=-=-=-=-=-=-=-=-< MULKEY DEFINITION >-=-=-=-=-=-=-=-=-=-=-=-
  28.  
  29.      First an appology for the documentation. I did not attempt to write a
  30.      user  manual  for  Mulkey.  The  documentation  is  terrible. All the
  31.      required information is there for use of Mulkey, only in bad form.
  32.  
  33.      MULKEY  is  a  collection  of  routines  written  in Turbo Pascal for
  34.      compilation with  Turbo Pascal version  4.xx. This is  version 3.00A.
  35.      Version 1.xx of Mulkey was written for compilation using Turbo Pascal
  36.      version 3.xx.  Version 2.xx of  Mulkey was rewritten  for compilation
  37.      using Turbo Pascal  version 4.0. Version 3.xx of  Mulkey has changed,
  38.      among other things, the master  FileDesc file layout. Your other data
  39.      files are still the same. Only the master file has to be changed. You
  40.      may use the  convert option to translate the  master file description
  41.      files to the new version.
  42.  
  43.      Mulkey is  finally fairly stable  now and does  not seem to  have any
  44.      more major  bugs. You still  use Mulkey at  your own risk  but I have
  45.      used  it for  very large  (10 files  in one  program averaging over 2
  46.      megabytes per  file) databases with 24  keys in one file  now without
  47.      problems.
  48.  
  49.      These  routines  interface  with  the  product  from Novell (formerly
  50.      Softcraft)  called Btrieve.  They are  for database  applications and
  51.      deal with  indexed data files. With  these routines you simply  put a
  52.      key value in  a parameter to a procedure and  Mulkey, with the aid of
  53.      Btrieve  will find  it. You  no longer  have to  worry about any file
  54.      access, record  locking in a  network environment. Mulkey  simplifies
  55.      the set-up requirements of Btrieve and maintains them for you.
  56.  
  57.      Mulkey  will  not  work  without  Btrieve.  Using  Mulkey  is  not  a
  58.      substitute for  the Btrieve manual.  You still must  be familiar with
  59.      the workings of Btrieve to make these work for you.
  60.  
  61.      The program  MULKEY.EXE is a  utility for setting  up and maintaining
  62.      master file description files. MULKEY.PAS  is the source code for the
  63.      MULKEY.TPU  unit you  "use" in  your program.  Your program must also
  64.      "use" the following  units: Dos, - For DOS  functions, Btrieve, - The
  65.      Btrv  function  which  calls  Btrieve,  Env,  -  Environment variable
  66.      access, Strings,  - Various string functions,  Convert - Various data
  67.      conversion routines
  68.  
  69.      These  routines  are  kept  in   separate  unit  files  because  many
  70.      programmers already have pre-written functions for these that already
  71.      do the  same things and duplication  of code is not  exactly good for
  72.      program size and efficiency. You will probably not want to write your
  73.      own Btrv() function but if you do, make sure you know about the inner
  74.      workings of Btrieve or you may have very undesirable results.
  75.  
  76.      You can contact me (Mark Boler)  at P.O. BOX 81211, Corpus Christi TX
  77.      78412. This  software is distributed under  the shareware concept. If
  78.      you use  them in your  program, you must  register by sending  $20.00
  79.      to  the  above  address.  You  will  be  kept informed of the latest
  80.      revisions of Mulkey automatically after  doing so. No support will be
  81.      provided  for un-registered  copies unless  you are  still trying the
  82.      software out (for a reasonable period please).
  83.  
  84.      Setup:
  85.      Mulkey requires an  environment variable (so i hope  you have lots of
  86.      environment space free - as almost every other program requires). The
  87.      environment variable is FILEDESC = and must be a complete drive, path
  88.      and filename of  the master file description file you  wish to use or
  89.      create. MULKEY.EXE will  not run unless it can  find this environment
  90.      variable. Mulkey itself  will. This variable is Mulkeys  link to what
  91.      it should do in  the case it is called upon to  open a file that does
  92.      not exist. Btrieve  stores in each file, the  file configuration (key
  93.      locations, number of keys, etc.) that it needs to use that file. Your
  94.      application will  open these files,  when Mulkey goes  out to open  a
  95.      file, it first tries to open the  file normally, but when the file is
  96.      not found, it  then tries to create a new  one. When Mulkey creates a
  97.      file, it  must know the number  of keys, position, type  of key, etc.
  98.      This is where the master file  description file comes in. It searches
  99.      the environment for  the FILEDESC variable and opens  the master file
  100.      (that you created  with MULKEY.EXE) and uses the  information in that
  101.      file to  create the new  data file. After  the data file  is created,
  102.      Mulkey  no longer  opens the  master description  file anymore unless
  103.      creating another file. Therefore if you change the master description
  104.      file  after a  file has  been  created,  that file  will NOT  get the
  105.      change. The  master file is  opened only when  a data file  has to be
  106.      created. MULKEY.EXE  must have the environment  variable available to
  107.      create  this  master  file.  You  do  not  have  to  have  it in your
  108.      application but if  you don't you must have  empty data files created
  109.      by your application to distribute since mulkey will not create a file
  110.      without it. If  you choose to distibute your  master description file
  111.      then  your   application  can  create   its  own  empty   data  files
  112.      automatically  at  run  time  since  it  has  access  to  the  master
  113.      description file through the  environment variable FILDESC. Each file
  114.      description in the master file is  accessed by a 25 character or less
  115.      name called a TypeName by Mulkey.  This TypeName is used whenever you
  116.      open a file so that if the file is not found, the file layout is used
  117.      to create it. If you have not previously set up this TypeName through
  118.      the MULKEY.EXE  utility, Mulkey will  not find it  and the open  will
  119.      fail. There is also a 25 character or less SYSTEM name you can add in
  120.      MULKEY.EXE. The OpenFile  function will return a number  of type WORD
  121.      as a handle for the open file.  If it returns a 0 then something went
  122.      wrong. These handles are NOT the same handles as the DOS file handle.
  123.      DO NOT use them as such. These  are handles that have meaning only to
  124.      Mulkey. Mulkey insulates you from  having to worry about DOS handles.
  125.      Mulkey for Turbo Pascal must have Btrieve version 4.10 or later so it
  126.      can handle Turbo Pascal strings properly.
  127.  
  128.  
  129.      If you  use MULKEY.EXE you  need to provide  a printer driver  in the
  130.      form of an environment variable called  PRINTDEF= and name one of the
  131.      printer driver files supplied. This program will also read and accept
  132.      a printer driver file in the format supplied by Borland in the editor
  133.      toolbox package  with Microstar. I  can not provide  you with one  of
  134.      those drivers since they are Borlands.
  135.  
  136.       ------------------------------------------------------------------
  137.  
  138.      This source code is intended for use with DOS 3.xx or later since the
  139.      use of GetEnv()  uses a function call only  avaiable in that version.
  140.      To use  this code under DOS  2.xx also, you will  need to rewrite the
  141.      code for GetEnv. GetEnv is a function in the unit ENV:
  142.  
  143.         GetEnv(EnvVar: STRING): STRING;
  144.  
  145.      GetEnv will provide the complete pathname of the file DOS executed if
  146.      you use GetEnv(''); This works only under DOS 3.xx or later.
  147.  
  148.         -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  149.  
  150.      When  this  is  running,  the  master  file  description file must be
  151.      available  in an  environment variable  called FILEDESC  = <path> and
  152.      must give a  valid path complete with file name  and extension of the
  153.      master  file  description  file  to  use  for  the create function in
  154.      openfile. If  this can't be  found or opened,  the openfile procedure
  155.      will fail when opening a file that does not yet exist. I suppose this
  156.      could  be a  feature. If  you only  want an  application to open only
  157.      existing  files that  you have   opened and  prepared, don't  use the
  158.      environment variable  or don't have the  file description master file
  159.      available. When changes are made to the structure of the types below,
  160.      make changes to the master file editing and creation utility as well!
  161.  
  162.      As of May 5, 1988, Mulkey is version 3.00A:
  163.  
  164.      Revisions:
  165.  
  166.      1.00A: Original version of Mulkey - ran under Turbo Pascal 3.xx
  167.      1.01A: Corrected  a bug in  the CloseFile procedure  that would cause
  168.             Turbo Pascal to hang when DISPOSE() was called. Also corrected
  169.             a   FILLCHAR  that   would  overwrite   pointers  after  their
  170.             allocation in the Key Buffers on AddRecord
  171.      1.02A: Corrected  a problem with pre-allocation of a  file if it  was
  172.             requested and  later not allowed, Mulkey  would pre-allocate a
  173.             random  number  of  pages  anyway
  174.      1.03A: Corrected  a minor problem  with the memory  allocation of key
  175.             buffers and minor screen changes  Added the date to the Mulkey
  176.             version routine Corrected a bug that  would not allow a key to
  177.             be the  last field in a  record Corrected a bug  in MULKEY.COM
  178.             print routine  that would not  shut off underline  mode on all
  179.             printers.  ( Turbo  3.xx )
  180.      1.04A: Added GetEqGreater()  and GetEqLessThan()  procedures
  181.      1.05A: Minor changes to Longint arrangement and declarations
  182.      1.06A: Removed some redundant code from MULKEY.INC
  183.      2.00A: Modified  code to conform  with Turbo Pascal  4.0. This was  a
  184.             rewrite to take advantage of Turbo Pascals new features, not a
  185.             translation just to get it  to compile. The MULKEY.COM utility
  186.             is now  MULKEY.EXE.
  187.      2.01A: Changed  the  meaning  of  GetDirect  GetPosition  and  added
  188.             GetMarked. Added  MulkeyError function.
  189.      2.02A: Added ability to keep  Mulkey from automatically closing files
  190.             when the  program is halted.  Use with care!
  191.      2.03A: Took away  the ability in 2.02A above, plan  to have Mulkey do
  192.             this  automatically   in  future.
  193.      2.04A: Minor revision - unreleased.
  194.      2.05A: Added ability of Mulkey to sense  that it is running on top of
  195.             itself and not to reset all of  the resources of a node if so.
  196.             If  mulkey is  running in  a shell  and another  copy of it is
  197.             active below it in memory, Mulkey will only close the files it
  198.             has opened in  the shell, otherwise it will  issue the request
  199.             to close all resources held by  the station. It also exports a
  200.             new  function:  AllowShell:  BOOLEAN;  which  will  tell  your
  201.             application  if  the  automatic  sensing  feature  has worked.
  202.             Otherwise a shell to another Mulkey operation could damage the
  203.             operation  below.  This  feature  used  the  Intra-Application
  204.             Communications area so it should not be run with programs that
  205.             make  use  of  that  area.
  206.      2.06A: Rewrote memory allocation  routines and added extra protection
  207.             in  the case  that the  heap memory  runs out  during an open.
  208.      2.07A: Optimized the most repetitive functions.
  209.      3.00A: Mulkey was modified to accomodate  all the extended data types
  210.             of  Btrieve  version  4.10  and  the  data  file  layouts were
  211.             changed. Corrected a problem in NumRecords() that would return
  212.             0 if there  were more than 14 keys in  your file. This was not
  213.             considered a bug since Mulkey  was originally designed to only
  214.             handle 14  keys but now it  can handle Btrieves maximum  of 24
  215.             keys and will open files  created with BUTIL -Create and Butil
  216.             -SIndex. The length for FDesc has been increased from 20 to 25
  217.             characters  as  was  the  System  field  length.  Your  master
  218.             FileDesc  files are  no longer  compatible with  this version.
  219.             CNVMULKY.EXE was  created to translate  these files. The  data
  220.             files  you have  created with  the old  version of  Mulkey are
  221.             still the same. ONLY the master FileDesc file has changed. The
  222.             Mulkey  array  of  pointers  now  exists  in  the Data segment
  223.             instead of on  the heap since it was  always allocated anyway.
  224.             The  functions  BtVersion  and  MulkeyVersion  were changed to
  225.             strings instead  of functions for  increased speed since  they
  226.             never change after program  initialization anyway. The ability
  227.             to  set locking  attributes for   each file  was added.  If no
  228.             explicit locking  attributes are set for  each file, a default
  229.             is  used. The  procedures GetMarked()  and MarkPosition()  are
  230.             gone. If you need them it is very easy to write them using the
  231.             new procedures  GetPosition() and GetDirect().  They were just
  232.             duplication of code and were never used. Mulkey no longer uses
  233.             the intra-  applications communications area and  it no longer
  234.             releases all resources of the workstation when it terminates.
  235.  
  236.            --------------------------------------------------------
  237.  
  238.      You have 25  characters for the Type Name  - This is the name  of the
  239.      file  layout itself.  There are  25 characters  for the  system name.
  240.      Starting with theis  version, Mulkey will not find  a FileDesc record
  241.      unless the System names also match or a system name is not given.
  242.  
  243.       ------------------------------------------------------------------
  244.  
  245.      The following are some defininitions of constants and variables:
  246.  
  247.      The next six  variables are maintained by mulkey  and should NEVER be
  248.      changed  by  your  program  directly!  They  are variables instead of
  249.      functions for efficiency and speed.
  250.  
  251.      MulkeyActive : BOOLEAN { True if Mulkey itself has been initialized }
  252.      TransActive  : BOOLEAN { True if  a transaction is active }
  253.      IndexError   : BOOLEAN { True if last op resulted  in error }
  254.      LastErrCode  : WORD    { Set to last Btrieve error code, initially 0 }
  255.      BtVersion    : STRING[45] { Returns the version of Btrieve loaded }
  256.      MulkeyVersion: STRING[45] { Returns the version Mulkey being used }
  257.  
  258.      These constants and types are exported by the Mulkey unit:
  259.  
  260.      FDescLen     = 25;    { Length of a file description string             }
  261.      FSystLen     = 25;    { Length of a file system name string             }
  262.      MaxKeys      = 24;    { If these are changed, the record structure of   }
  263.                            { the master file layout files must be modified.  }
  264.      MaxKeyLen    = 128;   { Maximum length of any key possible.             }
  265.      MaxMulkey    = 40;    { Maximum number of mulkey files open at once.    }
  266.                            { MaxMulkey MUST never be allowed to be > 255     }
  267.  
  268.      TYPE                  { Exported Types }
  269.      FDescStr     = STRING[FDescLen];
  270.      FSystStr     = STRING[FSystLen];
  271.  
  272.      The next variables are to be set by your program and will be obeyed by
  273.      Mulkey:
  274.  
  275.      SystemName   : STRING[FSystStr] = '';  { '' will find any FileDesc -def }
  276.      WaitLocks    : BOOLEAN = TRUE;   { Set to true if use waitlocks -def    }
  277.      MultiLocks   : BOOLEAN = FALSE;  { Set to true if multi-record locks    }
  278.      UseLocks     : BOOLEAN = TRUE;   { Set to true if using those locks -def}
  279.      KeyOnly      : BOOLEAN = FALSE;  { Set to true for "get key" only +50   }
  280.      DefAllowRO   : BOOLEAN = FALSE;  { Set to true to allow RO on creates   }
  281.      DefEncrypt   : BOOLEAN = FALSE;  { Set to true to encrypt on creates    }
  282.  
  283.  
  284.        ----------------------------------------------------------------
  285.  
  286.      The Key Type descriptor given to Btrieve can be on of the following:
  287.  
  288.         VALUE   DESCRIPTION                     ALLOWABLE LENGTH
  289.        ------------------------------------------------------------------
  290.            0    Array of Character              1 - ?? (variable)
  291.            1    Signed Whole Number (binary)    Even Number of Bytes
  292.            2    IEEE Floating Point Real        4 or 8 bytes
  293.            3    Date                            4 bytes
  294.            4    Time                            4 bytes
  295.            5    Decimal (semi-BCD)              1 - ?? (variable)
  296.            6    Money (same as Decimal)         1 - ?? (variable)
  297.            7    Logical (Boolean)               1 or 2 bytes
  298.            8    Numeric                         1 - ?? (variable)
  299.            9    BFloat                          4 or 8 bytes (Microsoft Real)
  300.           10    lString (pascal string)         1 - 256 (max length = 255)
  301.           11    zString (null terminated)       1 - ??  (C string)
  302.           14    Unsigned Whole Number (binary)  Even Number of Bytes
  303.  
  304.      Mulkey allows  you to use them  all however there are  some that just
  305.      probably  wouldn't be  efficient in  Turbo Pascal.  Since you  may be
  306.      reading a file  created by another language, or  using XQL or another
  307.      report generator that requires them, these types are described below:
  308.  
  309.      Type  0: Array of Character
  310.               All characters in the array are significant. BASIC uses this
  311.               type of string padded with blanks ASCII Hex 20.
  312.  
  313.      Type  1: Signed Whole Number
  314.               Normally  use  this  for  INTEGER  (2  bytes)  or LONGINT (4
  315.               bytes). It must be an even number of bytes so don't use this
  316.               for BYTE or SHORTINT values. (Use logical).
  317.  
  318.      Type  2: IEEE Floating Point
  319.               A 4 or 8 bytes IEEE floating point real number. Use this for
  320.               SINGLE or DOUBLE real types.
  321.  
  322.      Type  3: Date
  323.               This is a 4 byte type that corresponds to:
  324.  
  325.               RECORD
  326.                  Day  : BYTE;  { day number   }
  327.                  Month: BYTE;  { month number }
  328.                  Year : WORD;  { stored as the year, not an offset like 1988 }
  329.               END;
  330.  
  331.      Type  4: Time
  332.               This is a 4 byte type that corresponds to:
  333.  
  334.               RECORD
  335.                   Hundredths: BYTE;  { hundredths of a second }
  336.                   Second    : BYTE;  { Second                 }
  337.                   Minute    : BYTE;  { Minute                 }
  338.                   Hour      : BYTE;  { Hour                   }
  339.               END;
  340.  
  341.      Type  5: Decimal
  342.               This  is an  ANSI-74 standard   COBOL type  stored in  a BCD
  343.               format.
  344.  
  345.      Type  6: Money
  346.               This format is exactly the same as Decimal above.
  347.  
  348.      Type  7: Logical
  349.               A 1  or 2 byte value.  Btrieve will actually sort  and store
  350.               these as a 1 or 2 byte  array of character but it will still
  351.               work with  unsigned numeric values, etc.  With Turbo Pascal,
  352.               use  these only  for storage   of BOOLEAN,  One or  Two byte
  353.               enumerated types,  or for one byte  numerical values such as
  354.               BYTE or SHORTINT. As of the time this is created, Novell has
  355.               acknowledged to me, a bug with version 4.10 and they say not
  356.               to use this type for now.
  357.  
  358.      Type  8: Numeric
  359.               Numeric  values  stored  as  ascii  strings  that  are right
  360.               justified  with leading  zeros.  The  rightmost byte  of the
  361.               number contains an embedded sign.  The table below shows how
  362.               to make a number contain  a negative sign. A positive number
  363.               evaluates to the same as a number without a negative sign.
  364.  
  365.           NUMBER          POSITIVE SIGN          NEGATIVE SIGN
  366.           --------------------------------------------------------------
  367.              1                  A                     J
  368.              2                  B                     K
  369.              3                  C                     L
  370.              4                  D                     M
  371.              5                  E                     N
  372.              6                  F                     O
  373.              7                  G                     P
  374.              8                  H                     Q
  375.              9                  I                     R
  376.              0                  {                     }
  377.  
  378.      Type  9: BFloat
  379.               This is the  old Microsoft real format used  by old MASM and
  380.               the  older BASIC  compilers and  interpreters. It  is 4 or 8
  381.               bytes long.
  382.  
  383.      Type 10: lString
  384.               This is for the standard Turbo Pascal string.
  385.  
  386.      Type 11: zString
  387.               This is  for a null  terminated string. C  compilers usually
  388.               use these types of strings.
  389.  
  390.      Type 14: Unsigned Whole Number
  391.               Must contain an  even number of bytes. Use  this for WORD or
  392.               your  own  user  produced  integer  type  numbers  that  are
  393.               unsigned and are even number of bytes long.
  394.  
  395.          -------------- MULKEY FUNCTIONS AND PROCEDURES --------------
  396.  
  397.      This sets  the error codes  maintained by Mulkey  -- to clear  out an
  398.      error just do: SetErr(0);
  399.  
  400. PROCEDURE SetErr(Status: WORD);    { sets error codes }
  401.  
  402. BEGIN {seterr}
  403.       LastErrCode:= Status;
  404.       IndexError := (Status <> 0);
  405. END; {seterr}
  406.  
  407.                ----------------------------------------
  408.  
  409. FUNCTION HandleActive(Handle: WORD): BOOLEAN;
  410.  
  411.                ----------------------------------------
  412.  
  413. FUNCTION BtVersion: STRING;
  414.  
  415.                ----------------------------------------
  416.  
  417. FUNCTION MulkeyVersion: STRING;
  418.  
  419.                ----------------------------------------
  420.  
  421. FUNCTION OpenFile(FDesc   : STRING;      { The description name }
  422.                   OpenMode: INTEGER;     { Use 0 for now - see Btrieve }
  423.                   Owner   : STRING;      { The name of the files owner }
  424.                   FileName: STRING): WORD;  { The file pathname }
  425.  
  426. Openfile will return a handle in the range of 1 - MaxMulkey. This numeric
  427. handle is how you refer to the open file from here on. A handle of 0 means
  428. something went wrong and you should check IndexError and LastErrCode.
  429. The handle returned by Mulkey is NOT the same as the DOS file handle
  430. corresponding to your file by DOS. Btrieve conveniently takes care of
  431. this for you. The handle returned by this function will be in the range
  432. of 1 through MaxMulkey in the CONST declarations unless an error occured
  433. in which case you should get a 0 back by this function.
  434.  
  435.                ----------------------------------------
  436.  
  437. PROCEDURE CloseFile(Handle: WORD);
  438.  
  439.                ----------------------------------------
  440.  
  441. PROCEDURE AbortTransaction;
  442.  
  443.                ----------------------------------------
  444.  
  445. PROCEDURE EndTransaction;
  446.  
  447.                ----------------------------------------
  448.  
  449. PROCEDURE BeginTransaction;
  450.  
  451.                ----------------------------------------
  452.  
  453. PROCEDURE ResetFiles;
  454.  
  455. ResetFiles closes any open files, releases any locks or resources held by
  456. this station. Usually, you would only want to do this when you must
  457. terminate the program, but it can be used any time and does release the
  458. handles held by Mulkey.
  459.  
  460.                ----------------------------------------
  461.  
  462. PROCEDURE SetOwner(Handle : WORD;      { what file to add owner to        }
  463.                    Owner  : STRING;    { only 8 characters please         }
  464.                    AllowRO: BOOLEAN;   { allow read only without an owner }
  465.                    Encrypt: BOOLEAN);  { encrypt the data stored in file  }
  466.  
  467. Make sure you only specify 8 characters for an owner.
  468.  
  469.                ----------------------------------------
  470.  
  471. PROCEDURE ClearOwner(Handle: WORD);   { what file to clear on }
  472.  
  473.                ----------------------------------------
  474.  
  475. PROCEDURE Unlock(Handle: WORD);       { what file to unlock }
  476.  
  477. This procedure will release any locks accumulated on a file.
  478.  
  479.                ----------------------------------------
  480.  
  481. PROCEDURE Stat(Handle: WORD);
  482.  
  483. This procedure does a stat operation on the file. All information is
  484. stored into the files data records in the FileDescType. It does nothing
  485. unless the file handle is an active handle. IndexError will be set if not.
  486. For more information on this, see the Btrieve documentation.
  487.  
  488.                ----------------------------------------
  489.  
  490. FUNCTION NumRecords(Handle: WORD): LONGINT;
  491.  
  492. This function will return the number of records in a file. It returns 0.0
  493. if the handle is not active and sets IndexError (set in Stat).  This
  494. function uses the Stat() procedure.  It will also, of course return 0.0
  495. if there are no data records in the file.
  496.  
  497.                ----------------------------------------
  498.  
  499. PROCEDURE AddRecord(Handle: WORD;       { what file to use }
  500.                      VAR d);            { what data to put into the file }
  501.  
  502. Add record d to the file. IndexError usually indicates a duplicate key.
  503.  
  504.                ----------------------------------------
  505.  
  506. PROCEDURE UpdateRecord(Handle: WORD;     { what file to use }
  507.                         VAR d);          { what data to put in the file }
  508.  
  509. Updates the last retrieved record (you must have just used a get operation)
  510. with data from record d. IndexError usually indicates a duplicate key in a
  511. unique key index.
  512.  
  513.                ----------------------------------------
  514.  
  515. PROCEDURE DeleteRecord(Handle: WORD);    { what file to use }
  516.  
  517. Deletes the last retrieved record (you must have just used a get operation)
  518. from the database and all its keys.  IndexError usually indicates no valid
  519. last record retrieved.
  520.  
  521.                ----------------------------------------
  522.  
  523. FUNCTION GetPosition(Handle: WORD): LONGINT;
  524.  
  525. This function returns the position of the file maintained by Btrieve.
  526.  
  527.                ----------------------------------------
  528.  
  529. The following are the get record procedures, they are filtered by procedure
  530. RPN_Record, which does the work.  This is where KeyOnly gets reset, not in
  531. AdjOp().  If KeyOnly was set, it is set to FALSE after function execution.
  532.  
  533. PROCEDURE GetDirect(Handle: WORD;       { the file to use  }
  534.                          p: LONGINT;    { The position     }
  535.                      VAR d);            { the data to read }
  536.  
  537. This procedure uses the position (p) to get the record that corresponds to it.
  538. This procedure will destroy the contents of the data record position in the
  539. data type FileDescType.
  540.  
  541.                ----------------------------------------
  542.  
  543. PROCEDURE GetLowest(Handle: WORD;      { what file number to use }
  544.                     KeyNum: WORD;      { what key number to use  }
  545.                      VAR d);           { where the data goes to  }
  546.  
  547. Read lowest record from the database with KeyNum.  IndexError usually
  548. indicates no key found.
  549.  
  550.                ----------------------------------------
  551.  
  552. PROCEDURE GetHighest(Handle: WORD;      { what file number to use }
  553.                      KeyNum: WORD;      { what key number to use  }
  554.                       VAR d);           { where the data goes to  }
  555.  
  556. Read highest record from the database with KeyNum.  IndexError usually
  557. indicates no key found.
  558.  
  559.                ----------------------------------------
  560.  
  561. PROCEDURE StepDirect(Handle: WORD;      { what file number to use }
  562.                       VAR d);           { where the data goes to  }
  563.  
  564. This procedure should be used when the data file is damaged and must
  565. be opened to recover it.  See the Btrieve documentation
  566.  
  567.                ----------------------------------------
  568.  
  569. PROCEDURE GetEqual(Handle: WORD;      { what file number to use }
  570.                    KeyNum: WORD;      { what key number to use  }
  571.                     VAR k;            { the key value itself    }
  572.                     VAR d);           { where the data goes to  }
  573.  
  574. Read record from the database with a key equal to k.
  575. IndexError usually indicates search key not found.
  576.  
  577.                ----------------------------------------
  578.  
  579. PROCEDURE GetGreater(Handle: WORD;      { what file number to use }
  580.                      KeyNum: WORD;      { what key number to use  }
  581.                       VAR k;            { the key value itself    }
  582.                       VAR d);           { where the data goes to  }
  583.  
  584. Read record from the database with a key greater than k.
  585. IndexError usually indicates search key not found.
  586.  
  587.                ----------------------------------------
  588.  
  589. PROCEDURE GetLessThan(Handle: WORD;      { what file number to use }
  590.                       KeyNum: WORD;      { what key number to use  }
  591.                        VAR k;            { the key value itself    }
  592.                        VAR d);           { where the data goes to  }
  593.  
  594. Read record from the database with a key less than k.
  595. IndexError usually indicates search key not found.
  596.  
  597.                ----------------------------------------
  598.  
  599. PROCEDURE GetGreaterOrEqual(Handle: WORD;     { what file number to use }
  600.                             KeyNum: WORD;     { what key number to use  }
  601.                              VAR k;           { the key value itself    }
  602.                              VAR d);          { where the data goes to  }
  603.  
  604. { Read record from the database with a key equal to or greater than k.
  605.   IndexError usually indicates search key not found. }
  606.  
  607.                ----------------------------------------
  608.  
  609. PROCEDURE GetLessThanOrEqual(Handle: WORD;    { what file number to use }
  610.                              KeyNum: WORD;    { what key number to use  }
  611.                               VAR k;          { the key value itself    }
  612.                               VAR d);         { where the data goes to  }
  613.  
  614. { Read record from the database with a key equal to or less than k.
  615.   IndexError usually indicates search key not found. }
  616.  
  617.                ----------------------------------------
  618.  
  619. PROCEDURE NextRecord(Handle: WORD;      { what file number to use }
  620.                      KeyNum: WORD;      { what key number to use  }
  621.                       VAR d);           { where the data goes to  }
  622.  
  623. Read next record by last key from database.
  624. IndexError usually indicates end of file by key.
  625.  
  626.                ----------------------------------------
  627.  
  628. PROCEDURE PrevRecord(Handle: WORD;      { what file number to use }
  629.                      KeyNum: WORD;      { what key number to use  }
  630.                       VAR d);           { where the data goes to  }
  631.  
  632. Read previous record by last key from the database.
  633. IndexError usually indicates end (start) of file by key }
  634.  
  635.                ----------------------------------------
  636.  
  637. FUNCTION AllowShell: BOOLEAN;           { True if a transaction is not active }
  638.  
  639.                ----------------------------------------
  640.  
  641. FUNCTION BtError(Code: WORD): STRING;
  642.  
  643. Returns a text string explaining error codes.
  644.  
  645. FUNCTION MulkeyError: STRING;
  646.  
  647. Returns a text string explaining the last error code in the form of
  648.  
  649. 'MULKEY ERROR: '<explanation>
  650.  
  651.            - or -
  652.  
  653. 'NO MULKEY ERROR'  if none occurred.
  654.  
  655. Note: Using either of these functions in your program will add a
  656.       significant amount of code to your .EXE file.
  657.  
  658.                ----------------------------------------
  659.