Use to write one or more strings to a file. This command accepts any number of string arguments, including arrays.
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 the value is always positive.
Casting doesn't make sense when writing strings, but the option is still there for you.
|Writes each string character as a signed character, or a signed 8 bit (1 byte) value|
|Writes each string character as an unsigned character, or an unsigned 8 bit (1 byte) value|
|Writes each string character as a signed short integer, or a signed 16 bit (2 bytes) value|
|Writes each string character as an unsigned short integer, or an unsigned 16 bit (2 bytes) value|
|Writes each string character as a signed integer, or a signed 32 bit (4 bytes) value|
|Writes each string character as an unsigned integer, or an unsigned 32 bit (4 bytes) value|
|Writes each string character as a floating point value, a 32 bit (4 byte) value|
|String or string array||No||Command can accept any number of strings/arrays to write to the file|
|String or string array||No||1 or more string to be written to the file|
|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.|
|1||integer||—||Length of the string to write. Strings are usually written out at a fixed length, or prepended with the length of the string if the string length is variable. If you want to write out a fixed length string, use this flag. Max length is 1024|
string $str = "This is some text";
int $fileID = `fileOpen "C:/FileTesting.txt" "w"`;
// Get the string length
$length = `strLength $str`;
// First write out the string length
writeInt $fileID $length;
// Then write the string
writeString $fileID $str;