Einzelnen Beitrag anzeigen
Alt 10.10.2012, 01:05   #74
leecher
Moderator
C_OPEN

E r g e b n i s / R e s u l t

The C_OPEN function opens the file specified by filename and returns a file descriptor to it.

B e s c h r e i b u n g / D e s c r i p t i o n

The C_OPEN function opens the file specified by filename in the given mode and returns a file descriptor for later use by the other file-functions.

S y n t a x

Code:
fd = call ('C_OPEN' , filename, mode)
P a r a m e t e r

filename - Filename
mode - Type of access permitted

The character string mode specifies the type of access requested for the file, as follows:

"r"
Opens for reading. If the file does not exist or cannot be found, the fopen call fails.

"w"
Opens an empty file for writing. If the given file exists, its contents are destroyed.

"a"
Opens for writing at the end of the file (appending) without removing the EOF marker before writing new data to the file; creates the file first if it doesn‚t exist.

"r+"
Opens for both reading and writing. (The file must exist.)

"w+"
Opens an empty file for both reading and writing. If the given file exists, its contents are destroyed.

"a+"
Opens for reading and appending; the appending operation includes the removal of the EOF marker before new data is written to the file and the EOF marker is restored after writing is complete; creates the file first if it doesn‚t exist.


R e t u r n s

A valid file descriptor or -1 on error.
You have to close the file descriptor after work with the C_CLOSE function.

B e i s p i e l / E x a m p l e

Code:
attach 'FILE0'
fd = CALL ("C_OPEN", "FILE1.TXT", "r")
PUT CALL ("C_READ", fd, 10)
b = CALL("C_CLOSE", fd)
detach 'FILE0'
Angehängte Dateien
Dateityp: oac FILE0.OAC‎ (21.0 KB, 4x aufgerufen)
leecher ist offline   Mit Zitat antworten