Concept Framework 2.2 documentation Contents | Index

standard.C.io.fgetstring

Name Version Deprecated
fgetstring version 1.0 no

Prototype:
string fgetstring(number fd, string separator, number max_size)

Parameters:
fd      [in] A valid file descriptor
separator      [in] String separator
max_size      [in] Maximum number of bytes to be read

Description:
fgetstring reads one item from the input file, fd, formed by the string separator, with maximum size max_size.
If separator contains a value that is not found, then fgetstring will return the content of the input file.

Example:
import standard.C.io

define FILENAME          "test.txt"

class Main {
     function Main() {
          if(!(var fd = fopen( FILENAME, "r" )))
               echo "The file " + FILENAME + " was not opened\n";
          else {          
               var buffer = "*";
               while (!feof(fd))      
                    echo fgetstring(fd, buffer, 10)+"\n";
               fclose(fd);
          }
     }
}  

Input test.txt 
First item*Second item*Third item  

Results 
First item
Second item
Third item  

Returns:
Returns the string read.

Documented by Simona Plesuvu, generation time: Sun Jan 27 18:15:15 2013 GMT(c)2013 Devronium Applications