/
writeFloat

writeFloat

Description

Use to write one or more floating point values to a file. This command will accept any number of floating point arguments, including arrays.

The following list shows 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.

CastDescription
"c"Writes float as a signed character, or a signed 8 bit (1 byte) value
"uc"Writes float as an unsigned character, or an unsigned 8 bit (1 byte) value
"s"Writes float as a signed short integer, or a signed 16 bit (2 bytes) value
"us"Writes float as an unsigned short integer, or an unsigned 16 bit (2 bytes) value
"i"Writes float as a signed integer, or a signed 32 bit (4 bytes) value
"ui"Writes float as an unsigned integer, or an unsigned 32 bit (4 bytes) value
"f"Writes float as a floating point value, a 32 bit (4 byte) value

Functional area

Disk I/O

Command syntax

Syntax

writeFloat fileID floatVal1 [floatVal2...] [-cast string]

Arguments

NameTypeRequiredComments
float2optional float or float array
Command can accept any number of floats/arrays to write to the file
float1float or float array
One or more values to be written to the file
fileIDint
ID of file previously opened with fileOpen

Flags

NameFlag argumentsArgument typeExclusive toComments
cast1stringData type to cast to. Possible types are listed above. Note that data can be lost when casting.

Return value

void

Examples

//Write example
float $val = 5.75;
int $fileID; 
int $fileID = `fileOpen "C:/FileTesting.txt" "w"`;

// Write the float value
writeFloat $fileID $val;
fileClose $fileID;

Additional information

Related commands