10-10-2006 06:43 AM
10-10-2006 06:49 AM
10-10-2006 08:03 AM
10-10-2006 08:14 AM - edited 10-10-2006 08:14 AM
Hello,
the function ReadLine returns -2 if the end of the file is reached, and -1 if an error occurred. Here is some piece of code to show you an example:
filehandle = OpenFile (pathname, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_ASCII);
// Check if the file could be opened.
if (filehandle == -1 && (error = GetFmtIOError())){
MessagePopup ("Unable to open the file", GetFmtIOErrorString (error));
return 0;
}
// Get the data from the file.
while ((num_bytes = ReadLine (filehandle, linebuf, MAX_STRING_LEN-1)) >= 0){
if (num_bytes > 0){
// Do something with the bytes you read from the file...
}
}
// Check if an error occurred while reading from the file.
if (num_bytes == -1 && (error = GetFmtIOError ()) > 0){
MessagePopup ("Error while reading from file", GetFmtIOErrorString (error));
return 0;
}
Message Edited by Wim S on 10-10-2006 03:22 PM
10-10-2006 09:15 AM