home *** CD-ROM | disk | FTP | other *** search
- ///////////////////////// \
- /////// TP NET! /////// /
- ///////////////////////// /
- \________________________\/
-
- File Sharing and Locking Functions
- for
- Turbo Pascal v4.0 and up
-
- Author: Julio Monroy
- September 19, 1991
- v2.0
-
- Introduction
- ____________
-
- TP NET! is a Turbo Pascal Unit that contains several simple
- functions that allow file sharing on Microsoft compatible networks,
- like Invisible Network. These functions allow the programmer to:
-
- * Open files and share them among many users on a network
-
- * Lock records or files
-
- * Unlock records or files
-
- Using these basic functions, any programmer should be able to
- write a multi-user database application using Pascal records.
- TP NET is easy to use, and has been tested on several NETBios/DOS
- compatible networks.
-
-
- Description
- ___________
-
- The following are the headers for the various procedures
- See the paragraphs following the headers on how to use each part-
- icular procedure:
-
- * Procedure LockRec(VAR Handle : Word;
- RecSize : Longint;
- Recnum : Longint;
- VAR Error : Word);
-
- * Procedure UnLockRec(VAR Handle : Word;
- RecSize : Longint;
- Recnum : Longint;
- VAR Error : Word);
-
-
- Usage
- ____________
-
-
- To use these procedures, you must use the TPNET.TPU Turbo Pascal
- Unit included with this archive. To use it, you must include it in
- the USES statement at the beginning of a program. For example:
-
- Uses Dos,Crt,TpNet;
-
- Make sure the TPNET.TPU file is located in the current directory, or
- in the UNITS directory specified in your Turbo Pascal setup. Once
- this is included, any of the below mentioned procedures can be called
- from within a program.
-
- The following procedure examples contain references to records and
- files of records. Assume the following are the TYPE and VAR declaration
- for the data to be discussed and referenced from hereafter. Refer to
- this section if you don't understand the data format (this structure is
- taken directly from the sample program TPTEST.PAS included with this
- archive).
-
- CONST Filename = 'TPTEST.DAT';
-
- TYPE Item_Rec = Record { Structure of disk file to }
- Model : String; { be read/written and }
- Price : Real; { locked/unlocked }
- End;
-
- Item_File = File of Item_Rec; { Type declarations of data }
- Item_Record = Item_Rec; { structure for VAR headers }
-
- VAR Errcode : Word; { Global variable declarations }
- Itemfile : Item_File;
- ItemRec : Item_Record;
-
-
-
- -=[ DETAILS ON COORDINATING EACH STEP/HEADER ]=-
-
- = Opening Files in Shared Mode =
- _______________________________
-
- In Turbo Pascal, to open files in a SHARED mode, you simply need
- to do one thing. Set the FILEMODE variable to 66 (decimal). This
- will affect the way all files are opened from then on.
- Before you attempt doing this, you must make sure the program
- SHARE is loaded, otherwise the file open might fail.
- Once the FILEMODE variable is set 66, then use the Turbo Pascal
- convention for opening files (i.e., ASSIGN, RESET).
- This step is very important! Do not forget to do this!
-
-
- * Procedure LockRec
- ___________________
-
- This procedure does the actual file and record locking.
- In order to use this procedure properly, you need to pass it
- several parameters:
-
- Handle = File handle of file to perform file/record lock on.
- RecSize = Size of the record to lock (or size of disk area to lock)
- RecNum = The number of the record to lock
- Error = Return code for lock operation.
-
-
- Handle
- ------
- To pass the handle, use the FILEREC convention. For further reference
- on this internal Turbo Pascal record, see the Pascal reference guide.
- The enclosed sample program TPTEST.PAS shows how FILEREC can provide
- the file handle. Although this is the easiest approach, it certainly
- isn't the only way to pass a file handle. However, to prevent any
- problems, it is recommended that the FILEREC convention be used.
-
- RecSize
- -------
- The size of the record can be passed using the Turbo Pascal SizeOf()
- function. This field can be filled with a variable or a straight number.
- Using a straight number is not recommended, and taking advantage of TP's
- SizeOf() function is most convenient, as it guarantees the record size
- passed will always be correct, even if the record declaration is
- modified from time to time. The largest record size that can be locked
- is 2,147,483,647 bytes.
-
- RecNum
- ------
- This is the record number to lock. For example, if you had a file with
- 100 records, and you wanted to lock record #50, then put the number 50
- in this field. The record number to lock can be anywhere from 0 to
- 2,147,483,647, and can be substituted with a variable or a straight number.
-
- Error
- -----
- The return code is a variable that needs to be declared from
- within the application program. In the TPTEST.PAS program, the
- variable called ERRCODE serves as this variable.
-
- One important note: The LockRec function can be called as often as
- the SHARE program on the server will allow.
- Use the same parameters with UNLOCKREC
- to undo any lock(s) created with LOCKREC.
-
-
- * Procedure UnLockRec
- _____________________
-
- Everything described in LOCKREC applies here. When calling this
- function, use the exact same parameters used in LOCKREC to "undo"
- the previous lock, otherwise the area can remain locked for an
- indefinite amount of time.
-
-
-
-
- TPTEST.PAS - A program that tests the TPNET.TPU Unit
- ____________________________________________________
-
- If, by now, you still have problems understanding how to use
- the TPNET unit, refer to the TPTEST.PAS program included with the
- archive. This program uses all of the functions decribed above.
- This program should be used as a guide on how to correctly use the
- TPNET unit.
- To truly test the file/record locking functions, run the TPTEST
- program from a directory. Then run the same program from the same
- directory from another node. When program from node 1 says "Record
- Locked", then run the same program from another node. The second
- program should recieve a "Lock Violation" error message. This
- verifies that it works! If you receive any errors, make sure the file
- TPNET.DAT file is located in the current directory.
-
-
- Support & Registration
- ______________________
-
- * Support *
-
- If there are any questions, do not hesistate to call and leave
- a message on one of the following BBS's:
-
- Incipits Remote Menlo Park, Ca. 415-324-2601
- Invisible BBS Foster City, Ca. 415-345-5509
- Turbo Sys Redwood City, Ca. 415-365-7491
-
-
- Please address your messsage to Julio Monroy.
-
-
- * Registration *
-
- This program is shareware. You are required to register your
- copy. Registration qualifies you for:
-
- * Complete unabridged source for TPNET code in Turbo Pascal.
-
- * Added functions (Retry Limit, quad-word manipulation, more...)
-
- * 1 free communications Unit in Turbo Pascal. Write your own
- program that utilizes serial communications with this easy
- to use Unit! Small... only 5k in size. Interrupt driven,
- supports ANSI escape codes, and more!
-
-
- The shareware registration cost is $25.00. Mail check to the following
- location:
-
- Julio Monroy
- c/o Incipits Software, Inc.
- P.O. Box 7238
- Menlo Park, California 94025
-
-
- Make check or money order payable to: Julio Monroy
-
- * Please do not send cash! *
-
- {end of document}
-