The manual will really help you if you use it.
(See below)
Your open()'s and close()'s are not setup right.
Examples:
$RC=open(1,"Filename.txt", 5)
Opens Filename.txt using handle 1, the 5 is equal to 1 + 4 which if you look below 1 means create the file if it does not exist, and 4 open the file for writing. If the file already exists then the value could just be 4.
$RC=close(1) ; to close the file opened above. The 1 is the same handle used above.
Open( )
Action: Opens a text file.
Syntax: Open (FileHandle, "filename", mode)
Parameters: FileHandle
A numeric expression indicating the handle number of the file to open. Possible values range from 1 to 10.
Filename
A string expression indicating the path and name of the ASCII file to open.
Mode
Optional parameter that indicates what should happen if the file does not exist. This parameter can have the following values:
0
If the file does not exist, Open( ) fails with return code 2 (default).
1
If the file does not exist, Open( ) will create a new file.
2
Opens the file for read access (default).
4
Opens the file for write access.
Note: These values are cumulative. So if you want to open a file for write access, and create it if it does not yet exist, you should specify 5. Notice, however, that a file can not be opened for read and write access at the same time.
Remarks: Open opens the ASCII file specified by file name, for the internal buffer indicated by file number. KiXtart supports a maximum of ten open files, so file number must be within the range of 1 to 10.
The file-I/O functions in KiXtart (Open, ReadLine, and Close) process small configuration files. They are not intended for larger operations, such as scanning long files. For the sake of simplicity and speed, Open reads an entire ASCII file into memory, and subsequent ReadLine commands read lines stored in memory.
Although this design is memory-intensive, it is also very fast and simple.
Returns: -3 File number already in use
-2 Invalid file number specified
-1 Invalid file name specified
0 File opened successfully
>0 System error
See Also: FreeFileHandle( ), Close( ), ReadLine( ), WriteLine( )
Example: IF Open(3, @LDRIVE + "\CONFIG\SETTINGS.INI") = 0
$x = ReadLine(3)
WHILE @ERROR = 0
? "Line read: [" + $x + "]"
$x = ReadLine(3)
LOOP
ENDIF
Close( )
Action: Closes a file previously opened by the Open function.
Syntax: Close (FileHandle)
Parameters: FileHandle
A numeric expression indicating the handle number of the file to close. Possible values range from 1 to 10.
Returns: 0 File Closed
-2 Invalid File Number Specified
See Also: FreeFileHandle( ), Open( ), ReadLine( ), WriteLine( )
Example: If Close(3)
Beep
? "Error closing file!"
EndIf