PANORAMIC: USER's GUIDE

FOR THE VERSION 0.9.27

PART 6 - FILES AND DIRECTORIES

MAIN PAGE / DOCUMENTATION


1 - READING AND WRITING WITH FILES

2 - FILE MANAGEMENT

3 - DIRECTORY MANAGEMENT


1 - READING AND WRITING WITH FILES

It is possible to use:
- text files, which are sequential (data are read or written one after one) and which contain text and indication for end of ligne characters (separators),
- binary files, which are direct access files (data can be read or written anywhere) and which can contain any data.

1.1 - COMMANDS AND FUNCTIONS ON THE TEXT FILES

A text file can be open for reading or for writing, and can be closed.
If a test file is open for writing, it is created if it did not exist. If it existed, it is canceled then created again (its content is lost).
To write at the end of an existing file, the command
FILE_OPEN_APPEND must be used.
A line or a part of a line can be written or read.
It is also possible to read and write a certain number of characters.
It is possible to manage 5 files simultaneously.

FILE_OPEN_READ N, Name_of_File Opens a text file for reading.
FILE_OPEN_WRITE N, Name_of_File Creates a text file for writing.

FILE_OPEN_APPEND N, Name_of_File

Opens a text file to write at its end.

FILE_CLOSE N Closes the text file number N.
FILE_READ N, V$ Reads character V$ from text file.
FILE_READBUF N, V$, C Reads C characters from text file to the variable V$.
FILE_READLN N, V$ Reads line V$ from text file.
FILE_WRITE N, V$ Writes V$ to text file.
FILE_WRITEBUF N, E, C Writes C characters from string E to text file.
FILE_WRITELN N, V$ Writes V$ then "next line" to text file.
FILE_EOF(N) Returns 1 if position is beyond the last character, 0 otherwise.
FILE_READLN$(N) Returns the current line of the text file number N.

N = file number

to the top

1.2 - COMMANDS AND FUNCTIONS ON THE BINARY FILES

A binary file can be open for reading or for writing, and can be closed.
It is possible to change the current position by the command
FILEBIN_POSITION and to read it by the function FILEBIN_POS.
It is possible to manage 5 files simultaneously.

FILEBIN_OPEN_READ N, Name_of_File Opens a binary file for reading.
FILEBIN_OPEN_WRITE N, Name_of_File Opens a binary file for writing.
FILEBIN_CLOSE N Closes the binary file number N.
FILEBIN_READ N, V Reads one byte from the binary file and store the value to the variable V.
FILEBIN_WRITE N, V Writes one byte to the binary file.
FILEBIN_POSITION N, P Changes the current position P of the binary file number N.
FILEBIN_POS(N) Returns the current position in the binary file number N.
FILEBIN_SIZE(N) Returns the size (number or bytes) of the binary file number N.
FILEBIN_HEXA_READ N, C, V$ Reads C bytes from the binary file number N and stores the values to the variable V$.
FILEBIN_HEXA_WRITE N, C, S Writes C bytes to the binary file number N, data to be written are in the string expression S.
FILEBIN_BLOCK_READ N, C, V%(P) Reads C bytes from the binary file number N and stores the values to the array V% from the index P.
FILEBIN_BLOCK_WRITE N, C, V%(P) Writes C bytes to the binary file number N, data to be written are in the array V% from the index P
FILEBIN_READ(N)

Returns one byte read from the binary file number N.

FILEBIN_HEXA_READ$(N,C)

Returns C bytes read from the binary file number N.

N = file number

to the top


2 - FILE MANAGEMENT

2.1 - Handling

A file can be renamed, deleted, copied and moved.

Its existence can be tested.

FILE_EXISTS(Name) Returns 1 if the file "Name" exists, 0 otherwise.
FILE_DELETE Name Deletes the file "Name".
FILE_RENAME Name1, Name2 Renames the file "Name1" to "Name2".
FILE_COPY F1, F2

Copies the existing file "F1" to the new file "F2".

FILE_MOVE F1, F2

Moves the existing file "F1" to the new file "F2".

to the top

2.2 - Attributes

The attributes of a file can be changed.

FILE_ARCHIVE(F) Sets the attribute "archive" of the file F.
FILE_ARCHIVE_OFF(F) Cancels the attribute "archive" of the file F.
FILE_HIDE(F) Sets the attribute "hide" of the file F.
FILE_HIDE_OFF(F) Cancels the attribute "hide" of the file F.
FILE_READ_ONLY(F) Sets the attribute "read only" of the file F.
FILE_READ_ONLY_OFF(F) Cancels the attribute "read only" of the file F.
FILE_SYSTEM(F) Sets the attribute "system" of the file F.
FILE_SYSTEM_OFF(F) Cancels the attribute "system" of the file F.

to the top

2.3 - Extract

Things can be extracted from the absolute name of a file.

FILE_EXTRACT_DISK$(F)

Returns a disk name from F.

FILE_EXTRACT_EXTENSION$(F)

Returns a file extension from F.

FILE_EXTRACT_NAME$(F)

Returns a file name from F.

FILE_EXTRACT_PATH$(F)

Returns a file path from F.

to the top


3 - DIRECTORY MANAGEMENT

A directory can be created.
The existence of a directory can be tested.
The current directory can be changed and its name is available in a system variable.

DIR_EXISTS(Name) Returns 1 if the directory "Name" exists, 0 otherwise.
DIR_CURRENT$ Returns the name of the current directory.
DIR_CHANGE Name "Name" becomes the current directory.
DIR_MAKE Name The directory "Name" is created.
DIR_REMOVE Name Removes the empty directory "Name".
RMDIR Name Removes the empty directory "Name".
FILE_FIND_FIRST$ Returns the name of the first file found in the current directory and begins to find the file names.
FILE_FIND_NEXT$ Returns the name of the next file in the current directory.
FILE_FIND_CLOSE Ends the finding of file names with FILE_FIND_FIRST$ and FILE_FIND_NEXT$ and frees the resource.

to the top


Last update: January 22, 2017