home *** CD-ROM | disk | FTP | other *** search
-
- ------------------------------------------------------------------------------
- M M U U L TTTTTTT IIIIIII NN N EEEEEE TTTTTTT
- MM MM U U L T I N N N E T
- M M M M U U L T I ---- N N N EEE T
- M M M U U L T I N NN E T
- M M UUUUUU LLLLLL T IIIIIII N N EEEEEE T v1.02
- ------------------------------------------------------------------------------
- Written by: Mike Whitaker, Copyright 1992 Elite Software Productions
-
- Multi-Net is a set of Turbo Pascal v6.0 routines which allow a programmer
- to add simple Networking/Multitasking File Sharing support to their products.
- Multi-Net is the most complete and the simplest to use of all that i have
- found.
-
- WHY DO I NEED IT?
- If you are writing a software which can have more than 1 User on at once,
- you may run into problems (ie. BBS Software, Application, etc..). ie. If
- WorkStation #1 Is Inserting a Record in MNTEST.DAT while
- WorkStation #2 Is Deleting a Record within MNTEST.DAT, and no file sharing
- is available in the application then POW.. Who knows the results, besides
- knowing the file is going to be messed up. This program does require the
- presence of SHARE.EXE (comes with DOS) resident in the Multiplex Environment
- (SHARE.EXE must be run). These routines work only for FILEs and FILE of x
- and unfortunately not TEXT files, A Look at the Header of MNET.PAS:
-
- Const MNVer : String[4] = '1.01'; { Multi-Net Version }
- MNLock = 0; { Process = LOCK FILE }
- MNUnLock = 1; { Process = UNLOCK FILE }
-
- Var UseLocking, { Use File Sharing? (Locking & Unlocking)
- Give_IOError, { Set Off TP's IOResult Function }
- ShareLoaded : Boolean; { Is SHARE.EXE Loaded? }
-
- (* Is Share Activated? Returns TRUE or FALSE and Sets SHARELOADED Variable *)
- Function Share_Active : Boolean;
-
- (* Set DOS Lock Retry by the Wait in MS and how many times to try.
- REASON: If a file is locked and another workstation is trying to access it,
- you'd most likely want it to wait til the other workstation is done
- with that file so that you can access it next *)
- Function DOS_LockRetry (Wait, Times : Word) : Word;
-
- (* Lock/UnLock Entire File: F = File Variable; Process = MNLock or MNUnLock
- to lock and unlock the file *)
- Function LockFile (Var F; Process:Byte):Boolean;
-
- (* Use Just like WRITE. F = File, Buf = Data Buffer }
- Procedure NWrite (Var F,Buf);
-
- (* Use Just like READ. F = File, Buf = Data Buffer }
- Procedure NRead (Var F,Buf);
-
- (* Use Just like BLOCKWRITE, F = File, Buf = Data Buffer, Count = Bytes to
- Write, Res = Bytes Written *)
- Procedure NBlockWrite (Var F,Buf; Count,Res:Word);
-
- (* Use Just like BLOCKREAD, F = File, Buf = Data Buffer, Count = Bytes to
- Read, Res = Bytes Read *)
- Procedure NBlockRead (Var F,Buf; Count,Res:Word);
-
- (* Allows a user to send a Pascal String (S) to F (File) as an ASCIIZ String *)
- Procedure NWriteStr (Var F; S:String);
-
- Examples on Use (see how not much is changed):
-
- procedure Write_Read;
- type TRec = record
- blank1:char;
- blank2:char;
- textstr:string[250];
- end;
- var
- F : File of TRec;
- TR : TRec;
- begin
- assign (F,'TEST.FIL');
- reset (F);
- if ioresult <> 0 then
- rewrite (F);
- write (F,TR);
- seek (F,0);
- read (F,TR);
- close (F);
- end;
-
- procedure Net_Write_Read;
- type TRec = record
- blank1:char;
- blank2:char;
- textstr:string[250];
- end;
- var
- F : File of TRec;
- TR : TRec;
- begin
- assign (F,'TEST.FIL');
- reset (F);
- if ioresult <> 0 then
- rewrite (F);
- nwrite (F,TR); <--- Changed to NWRITE
- seek (F,0);
- nread (F,TR); <--- Changed to NREAD
- close (F);
- end;
-
- procedure BlockRead_Write;
- var
- F : File;
- D : Array [1..1000] Of Char;
- O : Word;
- begin
- assign (F,'TEST.FIL');
- rewrite (F,1);
- blockwrite (F,D,sizeof(D),O);
- seek (F,0);
- blockread (F,D,sizeof(D),O);
- close (F);
- end;
-
- procedure Net_BlockRead_Write;
- var
- F : File;
- D : Array [1..1000] Of Char;
- O : Word;
- begin
- assign (F,'TEST.FIL');
- rewrite (F,1);
- nblockwrite (F,D,sizeof(D),O); <-- Changed to NBLOCKWRITE
- seek (F,0);
- nblockread (F,D,sizeof(D),O); <-- Changed to NBLOCKREAD
- close (F);
- end;
-
- Do you use TEXT variables to write text files? There is a very simple way
- to get around and use these net routines.
-
- Step 1: Make the TEXT a FILE of CHAR
- Step 2: Substitute Writeln for NWriteStr with #13#10 at end, and Write for
- NWriteStr
- Step 3: Substitute ReadLn for NTextRLn and Read for NRead
- Step 4: Wasn't that easy?
-
- procedure NTextRLn (var F; Var S:String);
- var
- S2 : String;
- Cnt : Integer;
- C : Char;
- begin
- S2 := '';
- For Cnt := 1 To 255 Do Begin
- NRead (F,C);
- If C = #13 Then Begin
- S := S2;
- Exit;
- End Else
- S2 := S2 + C;
- end;
- S := S2;
- end;
-
-
- If you use this product in your code, all i ask is that you place me in
- your documentation or credits some where and you may use it freely.
-
- For the Complete source and latest updates send $25 to:
-
- Mike Whitaker
- P.O. Box 871958
- Dallas,Tx 75287-1958
-
-
- REVISIONS:
- v1.01 - Fixed NBlockWrite and NBLockRead with returning characters read.
-