Additional functions and (modified) commands for GFA BASIC 4.36 for Windows and GFA-BASIC 4.54 for MS-DOS and Compiler version 1.05.

_NAME$
Returns the name of the computer, as specified for the network used.
_SHARE
Returns -1 if share.exe (or similar) is available, 0 if no share functions available.
LOCK #file,start,count
Locks a part of a file for exclusive access. Error, if no share is available. Error, if it fails for othe reasons. start is the Number of the first BYTE to lock, starting at 0 for the first Byte of a file. To lock a record of a random file use Lock #1,RecIndex*Reclen,Reclen (if Recindex starts with 0, else Lock #1,(RecIndex-1)*Reclen,Reclen).
= LOCK( #file,start,count)
Locks a part of a file for exclusive access. Error, if no share is available. If it fails for othe reasons it returns an non zero value.
UNLOCK #file,start,count
Unlocks a part of a file, which has been previously locked, using exactly the same parameters. Error, if no share is available. Error, if it fails for othe reasons.
= UNLOCK( #file,start,count)
Unlocks a part of a file, which has been previously locked, using exactly the same parameters. Error, if no share is available. If it fails for othe reasons it returns an non zero value.
ZTRIM$(sexp)
Ends a string at the first zero byte in the string. Usefull to get the valid part of strings returned from the operating system in a buffer. Example:
a$ = SPACE$(20)
_DS = HIWORD(V:a$), _DX = LOWORD(V:a$)
~INTR($21,_AX=$5e00)
IF _FL & 1 || _CH = 0
	a$ = ""
ELSE
	a$ = TRIM$(ZTRIM$(a$))
ENDIF
// This is the _NAME$-function
The function ZTRIM$ is equivalent to the older:
a$ = ZTRIM$(a$)
		old:
IF INSTR(a$, CHR$(0))
	a$ = LEFT$(a$,INSTR(a$, CHR$(0)))
ENDIF
		or:
a$ = CHAR{v:a$}
This is used quite often, but does contain an error: In the, seldom occuring, case that the creation of the result string causes a garbage collection, the V:a$ becomes invalid. That means that the string may contain garbage characters. In rare situations it may even lead to a (Windows) GP-Fault. This is the reason of some hard to catch errors, occuring only after hours of execution...
OPEN file [FOR mode] [access] [lock] As #fileno [LEN reclen]
file		is a filename
mode 		is one of
	OUTPUT	INPUT	UPDATE	APPEND	BINARY	RANDOM
access	is optional one of
	ACCESS READ		ACCESS WRITE		ACCESS READ WRITE
lock		is optional on of
	LOCK READ			LOCK WRITE		LOCK READ WRITE	SHARED
fileno		is a integer between 0 and 100
reclen		is the record len for Random Files.

Opens a file with sharing enabled. If no Share is available, the not-share open is used instead. A file is opened as #fileno. The mode is not given as a single letter (I,O,U,A,R) but as a longer description. For Output ("O"), For Input ("I"), For Binary ("U"), For Append ("A"), For Random .. Len xxx ("R"...,xxx).
To restrict opened files to read only or write only access, an optional Access may be used. An Open "xx" For Binary Access Read .. opens a file for read only access, that is the network (share) will allow this open to succed, unless some other program has not allowed read access to this file (it may allow read but not write to a file). (The Access may not be used with Input, Output or Update: These automatically set Access to Read, Write or Read Write.)
With the Lock Read, Lock Write, Lock Read Write or Shared the access by other program is restricted. a Lock Write does not any other open with Access Write.A Shared does allow multiple Read and Write opens of this file.
The Len specifies the record len for Random files. In compiled programs it does specify the size of the internal buffers used for reading and writing. It is somewhat faster, if the buffer size matches the lock size used later. It is not requiered that this buffer size and lock size match. (because each lock or unlock does use flush internally).

FLUSH #n
This command flushes the internal buffers used for a file to the OS. This does not mean, that this buffers will be written to disk immediatly, but the OS Buffers (or a Smartdrive with write back caching) will get the data. But it will (probably) be transfered thru the cable to the other networked computer. FLUSH is automatically called for Lock and Unlock.






