On the file handles thing:

Unless Ruud sees fit to provide FileNumOpen() and / or FreeFileNum() functions, this will be an issue.

However, all is not lost. If a function needs file system access, there are ways to do this with KiX functionality like Redirect, SHELL, or with File System Objects, thus bypassing the file number limitations.

It is a pain to have to bypass KiXtart file numbers in a function, but with only ten choices, I have a pretty good chance of trying to use an already open file number and causing the function to fail.

Here is an example using KiXtart file numbers to avoid this:

code:
FUNCTION Unique(OPTIONAL $sDS)
; Create a unique-named file in a given (or current) directory. Supports up to
; 32767 unique files in one directory.
; Syntax: Unique(DirectorySpec)
; Returns: Directory and file spec of created file or empty string if no
; file was created.
; Error level returned is that of the Open() return value
DIM $RC, $iFN
SRnd(@MSECS)
IF $sDS = '' $sDS = @CURDIR ENDIF
IF SubStr($sDS,Len($sDS),1) <> '\' $sDS=$sDS + '\' ENDIF
IF GetFileAttr($sDS) & 16 ; If sDS is a directory
DO
$Unique=DecToHex(Rnd())
$Unique=$sDS+'~KIX'+Right('0000'+$Unique,4)+'.TMP'
UNTIL NOT Exist($Unique)
$iFN=1
$RC=Open($iFN,$Unique,1)
WHILE $RC = -3 AND $iFN <= 10
$iFN=$iFN+1 $RC=Open($iFN,$Unique,1)
LOOP
IF $RC
$Unique=''
ELSE
IF Close($iFN) $Unique='' ENDIF
ENDIF
ENDIF
EXIT $RC
ENDFUNCTION

Here is the same function, but using the file system object to avoid the problem entirely.
code:
FUNCTION Unique(OPTIONAL $sDS)
; Create a unique-named file in a given (or current) directory. Supports up to
; 32767 unique files in one directory.
; Syntax: Unique(DirectorySpec)
; Returns: Directory and file spec of created file or empty string if no
; file was created.
; Error level returned is that of CreateObject() or OpenTextFile()
DIM $RC, $iFN
SRnd(@MSECS)
IF $sDS = '' $sDS = @CURDIR ENDIF
IF SubStr($sDS,Len($sDS),1) <> '\' $sDS=$sDS + '\' ENDIF
IF GetFileAttr($sDS) & 16 ; If sDS is a directory
DO
$Unique=DecToHex(Rnd())
$Unique=$sDS+'~KIX'+Right('0000'+$Unique,4)+'.TMP'
UNTIL NOT Exist($Unique)
$iFN=1
$RC=Open($iFN,$Unique,1)
WHILE $RC = -3 AND $iFN <= 10
$iFN=$iFN+1 $RC=Open($iFN,$Unique,1)
LOOP
$oFS = CreateObject("Scripting.FileSystemObject")
IF @ERROR EXIT @ERROR ENDIF
$oFileOpen = $oFS.OpenTextFile($Unique,2,1,0)
$RC=@ERROR
ENDIF

New Mexico Mark