E r g e b n i s / R e s u l t
The C_READ function reads data from a file previously opened by C_OPEN.
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_READ function reads data from the file specified by the filedescriptor fd to a string. The maximum length can be 254 characters.
S y n t a x
Code:
res = call ('C_READ' , fd, len) P a r a m e t e r
fd - The file descriptor you obtained from C_OPEN
len - The number of characters to read from file, 254 max.
R e t u r n s
A string containing the requested data plus an additional char at the end representing the return code.
If data could be read successfully, the return code is 0. On EOF, the return code is 1.
B e i s p i e l / E x a m p l e
Code:
attach 'FILE0'
fd = CALL ("C_OPEN", "FILE.TXT", "r")
ret = CALL ("C_READ", fd, 3)
lret = LENGTH(ret)
rc = EXTRACT(ret, lret, 1)
rcstr = EXTRACT(ret, 1, lret-1)
PUT AT 1,1 rc ! Writes the return code to the first line, usually 0
PUT AT 1,2 rcstr ! Writes the string read to the second line
b = CALL("C_CLOSE", fd)
detach 'FILE0'