Go to: Return value. Related commands. Examples.
// Make a sample file to use as a test example // $exampleFileName = ( `internalVar -userTmpDir` + "example.tmp" ); $fileId=`fopen $exampleFileName "w"`; fprint $fileId "Hello there\nMEL-Developer-+Using+fgetword\n"; fclose $fileId; // Now read it back one word at a time // $fileId=`fopen $exampleFileName "r"`; string $nextWord = `fgetword $fileId`; while ( size( $nextWord ) > 0 ) { print ( $nextWord + "\n" ); $nextWord = `fgetword $fileId`; } fclose $fileId; // This will print: // Hello // there // MEL-Developer-+Using+fgetword // Read it back again using "+" and "-" as separators // $fileId=`fopen $exampleFileName "r"`; string $nextWord = `fgetword $fileId "+-"`; while ( size( $nextWord ) > 0 ) { print ( $nextWord + "\n" ); $nextWord = `fgetword $fileId "+-"`; } fclose $fileId; // This will print: // Hello there // MEL // Developer // Using // fgetword