File functions

File functions. More...

Functions

 fcreate (afile)
 Create a file on disk.

 fopen (afile)
 Open file.

 fseek (offset, origin)
 Reposition the read/write point in file.

 fread (char_no)
 Read from file.

 fwrite (data)
 Write to file.

 fclose ()
 Close file.


Detailed Description

File functions.


Function Documentation

fclose  ) 
 

Close file.

Close the previously opened file.

fcreate afile   ) 
 

Create a file on disk.

Creates a file on disk with afile path and name.
If the file already exists it will be overwritten with empty content.

Parameters:
afile File to be created with complete path if not in Easy Control folder
Example:
fcreate("myfile.txt")

fopen afile   ) 
 

Open file.

Open file afile. Allows full access for others.
If the return value is 0 or greater, the function was successful and the value is the file handle of the opened file. A return value of -1 indicates that an error occurred.
Only one file can be open at a time.

Parameters:
afile File to be open
Note:
Do not forget to close the file using fclose() when you are done with it!!
Example:
fh=fopen("myfile")

fread char_no   ) 
 

Read from file.

Read up to char_no characters (bytes) from the current position of the open file. Advances read/write point.

Parameters:
char_no How many characters (bytes) to be read
Example:
a=fread(12)

fseek offset  ,
origin 
 

Reposition the read/write point in file.

Use fseek to reposition the read/write point in open file.

Parameters:
offset Specifies the number of bytes from Origin where the file pointer should be positioned
origin Origin is a code with three possible values, denoting the beginning of the file, the end of the file, and the current position of the file pointer.
Origin Action
0 The file pointer is positioned offset bytes from the beginning of the file.
1 The file pointer is positioned offset bytes from its current position.
2 The file pointer is positioned offset bytes from the end of the file.
Example:
fseek(215,0)

fwrite data   ) 
 

Write to file.

Write data at the current position of the open file.
Returns the number of bytes actually written. Advances read/write point.

Parameters:
data Data to be written in file
Example:
t=fwrite("testing 123"&chr(13)&chr(10))


Generated on Wed Dec 3 10:18:42 2003 for Easy Control