home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TPNET20.ZIP / TPNET.DOC next >
Encoding:
Text File  |  1991-09-19  |  8.6 KB  |  228 lines

  1.                           ///////////////////////// \
  2.                          ///////  TP NET!  ///////  /
  3.                         /////////////////////////  /
  4.                         \________________________\/
  5.  
  6.                     File Sharing and Locking Functions
  7.                                     for
  8.                          Turbo Pascal v4.0 and up
  9.  
  10.                            Author: Julio Monroy
  11.                             September 19, 1991
  12.                                   v2.0
  13.  
  14. Introduction
  15. ____________
  16.  
  17.          TP NET! is a Turbo Pascal Unit that contains several simple
  18.     functions that allow file sharing on Microsoft compatible networks,
  19.     like Invisible Network.  These functions allow the programmer to:
  20.  
  21.          *  Open files and share them among many users on a network
  22.  
  23.          *  Lock records or files
  24.  
  25.          *  Unlock records or files
  26.  
  27.     Using these basic functions, any programmer should be able to
  28.     write a multi-user database application using Pascal records.
  29.     TP NET is easy to use, and has been tested on several NETBios/DOS
  30.     compatible networks.
  31.  
  32.  
  33. Description
  34. ___________
  35.  
  36.          The following are the headers for the various procedures
  37.     See the paragraphs following the headers on how to use each part-
  38.     icular procedure:
  39.  
  40.    * Procedure LockRec(VAR Handle  : Word;
  41.                            RecSize : Longint;
  42.                            Recnum  : Longint;
  43.                        VAR Error   : Word);
  44.  
  45.    * Procedure UnLockRec(VAR Handle  : Word;
  46.                              RecSize : Longint;
  47.                              Recnum  : Longint;
  48.                          VAR Error : Word);
  49.  
  50.  
  51.    Usage
  52. ____________
  53.  
  54.  
  55.          To use these procedures, you must use the TPNET.TPU Turbo Pascal
  56.     Unit included with this archive.  To use it, you must include it in
  57.     the USES statement at the beginning of a program.  For example:
  58.  
  59.                             Uses Dos,Crt,TpNet;
  60.  
  61.     Make sure the TPNET.TPU file is located in the current directory, or
  62.     in the UNITS directory specified in your Turbo Pascal setup.  Once
  63.     this is included, any of the below mentioned procedures can be called
  64.     from within a program.
  65.  
  66.          The following procedure examples contain references to records and
  67.     files of records. Assume the following are the TYPE and VAR declaration
  68.     for the data to be discussed and referenced from hereafter.  Refer to
  69.     this section if you don't understand the data format (this structure is
  70.     taken directly from the sample program TPTEST.PAS included with this
  71.     archive).
  72.  
  73. CONST  Filename = 'TPTEST.DAT';
  74.  
  75. TYPE  Item_Rec = Record                {  Structure of disk file to  }
  76.         Model : String;                {  be read/written and        }
  77.         Price : Real;                  {  locked/unlocked            }
  78.       End;
  79.  
  80.       Item_File = File of Item_Rec;    {  Type declarations of data  }
  81.       Item_Record  = Item_Rec;         {  structure for VAR headers  }
  82.  
  83. VAR Errcode  : Word;                   {  Global variable declarations }
  84.     Itemfile : Item_File;
  85.     ItemRec  : Item_Record;
  86.  
  87.  
  88.  
  89.             -=[ DETAILS ON COORDINATING EACH STEP/HEADER ]=-
  90.  
  91. = Opening Files in Shared Mode =
  92. _______________________________
  93.  
  94.     In Turbo Pascal, to open files in a SHARED mode, you simply need
  95.     to do one thing.  Set the FILEMODE variable to 66 (decimal).  This
  96.     will affect the way all files are opened from then on.
  97.     Before you attempt doing this, you must make sure the program
  98.     SHARE is loaded, otherwise the file open might fail.
  99.     Once the FILEMODE variable is set 66, then use the Turbo Pascal
  100.     convention for opening files (i.e., ASSIGN, RESET).
  101.     This step is very important! Do not forget to do this!
  102.  
  103.  
  104. * Procedure LockRec
  105. ___________________
  106.  
  107.          This procedure does the actual file and record locking.
  108.     In order to use this procedure properly, you need to pass it
  109.     several parameters:
  110.  
  111.        Handle  =  File handle of file to perform file/record lock on.
  112.        RecSize =  Size of the record to lock (or size of disk area to lock)
  113.        RecNum  =  The number of the record to lock
  114.        Error   =  Return code for lock operation.
  115.  
  116.  
  117.     Handle
  118.     ------
  119.     To pass the handle, use the FILEREC convention.  For further reference
  120.     on this internal Turbo Pascal record, see the Pascal reference guide.
  121.     The enclosed sample program TPTEST.PAS shows how FILEREC can provide
  122.     the file handle.  Although this is the easiest approach, it certainly
  123.     isn't the only way to pass a file handle.  However, to prevent any
  124.     problems, it is recommended that the FILEREC convention be used.
  125.  
  126.     RecSize
  127.     -------
  128.     The size of the record can be passed using the Turbo Pascal SizeOf()
  129.     function. This field can be filled with a variable or a straight number.
  130.     Using a straight number is not recommended, and taking advantage of TP's
  131.     SizeOf() function is most convenient, as it guarantees the record size
  132.     passed will always be correct, even if the record declaration is
  133.     modified from time to time.  The largest record size that can be locked
  134.     is 2,147,483,647 bytes.
  135.  
  136.     RecNum
  137.     ------
  138.     This is the record number to lock.  For example, if you had a file with
  139.     100 records, and you wanted to lock record #50, then put the number 50
  140.     in this field.  The record number to lock can be anywhere from 0 to
  141.     2,147,483,647, and can be substituted with a variable or a straight number.
  142.  
  143.     Error
  144.     -----
  145.     The return code is a variable that needs to be declared from
  146.     within the application program. In the TPTEST.PAS program, the
  147.     variable called ERRCODE serves as this variable.
  148.  
  149.     One important note:  The LockRec function can be called as often as
  150.                          the SHARE program on the server will allow.
  151.                          Use the same parameters with UNLOCKREC
  152.                          to undo any lock(s) created with LOCKREC.
  153.  
  154.  
  155. * Procedure UnLockRec
  156. _____________________
  157.  
  158.     Everything described in LOCKREC applies here.  When calling this
  159.     function, use the exact same parameters used in LOCKREC to "undo"
  160.     the previous lock, otherwise the area can remain locked for an
  161.     indefinite amount of time.
  162.  
  163.  
  164.  
  165.  
  166. TPTEST.PAS - A program that tests the TPNET.TPU Unit
  167. ____________________________________________________
  168.  
  169.          If, by now, you still have problems understanding how to use
  170.     the TPNET unit, refer to the TPTEST.PAS program included with the
  171.     archive.  This program uses all of the functions decribed above.
  172.     This program should be used as a guide on how to correctly use the
  173.     TPNET unit.
  174.          To truly test the file/record locking functions, run the TPTEST
  175.     program from a directory. Then run the same program from the same
  176.     directory from another node.  When program from node 1 says "Record
  177.     Locked", then run the same program from another node.  The second
  178.     program should recieve a "Lock Violation" error message.  This
  179.     verifies that it works! If you receive any errors, make sure the file
  180.     TPNET.DAT file is located in the current directory.
  181.  
  182.  
  183. Support & Registration
  184. ______________________
  185.  
  186.                               * Support *
  187.  
  188.          If there are any questions, do not hesistate to call and leave
  189.     a message on one of the following BBS's:
  190.  
  191.          Incipits Remote    Menlo Park, Ca.       415-324-2601
  192.          Invisible BBS      Foster City, Ca.      415-345-5509
  193.          Turbo Sys          Redwood City, Ca.     415-365-7491
  194.  
  195.  
  196.     Please address your messsage to Julio Monroy.
  197.  
  198.  
  199.                              * Registration *
  200.  
  201.          This program is shareware.  You are required to register your
  202.     copy.  Registration qualifies you for:
  203.  
  204.          *  Complete unabridged source for TPNET code in Turbo Pascal.
  205.  
  206.          *  Added functions (Retry Limit, quad-word manipulation, more...)
  207.  
  208.          *  1 free communications Unit in Turbo Pascal.  Write your own
  209.             program that utilizes serial communications with this easy
  210.             to use Unit!  Small... only 5k in size.  Interrupt driven,
  211.             supports ANSI escape codes, and more!
  212.  
  213.  
  214.     The shareware registration cost is $25.00.  Mail check to the following
  215.     location:
  216.  
  217.                           Julio Monroy
  218.                           c/o Incipits Software, Inc.
  219.                           P.O. Box 7238
  220.                           Menlo Park, California 94025
  221.  
  222.  
  223.                Make check or money order payable to:  Julio Monroy
  224.  
  225.                          * Please do not send cash! *
  226.  
  227. {end of document}
  228.