Use to read a string from a file. Command will fail if at the end of the file.
The following is a listing of the different cast types. Note that data can be lost when casting. 'Signed' means the value can be negative. 'Unsigned' means value will always be positive.
Casting doesn't make sense when reading strings, but the option is still there for you.
|Reads each string character as a signed character, or signed 8-bit (1 byte) value|
|Reads each string character as an unsigned character, or unsigned 8-bit (1 byte) value|
|Reads each string character as a signed short integer, or signed 16-bit (2 bytes) value|
|Reads each string character as an unsigned short integer, or unsigned 16-bit (2 bytes) value|
|Reads each string character as a signed integer, or signed 32-bit (4 bytes) value|
|Reads each string character as an unsigned integer, or unsigned 32-bit (4 bytes) value|
|Reads each string character as a floating point value, or a 32-bit (4 byte) value|
|int||Length of the string to read from the file. Must be a positive value.|
Will read in characters up to the newline character, or length, whichever comes first.
Will not return the newline character. Maximum value is 1024
|int||ID of file previously opened with fileOpen.|
|Name||Flag arguments||Argument type||Exclusive to||Comments|
|1||string||—||Data type to cast to. Possible types are listed above. Note that data can be lost when casting.|
int $fileID = `fileOpen "C:/FileTesting.txt" "r"`;
// First read the string length
$length = `readInt $fileID` + 1;
// Now read the string
$str = `readString $fileID $length`;
fileClose $fileID; //close the file
// Print out the value