/
writeVec

writeVec

Description

Use to write one or more vectors to a file. Command will accept any number of vector 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 is always positive.

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

Functional area

Disk I/O

Command syntax

Syntax

writeVec "fileID" vecValue1 vecValue2...[-delim string] [-cast string]

Arguments

NameTypeRequiredComments
fileIDint
ID of file previously opened with fileOpen
vector1vector or vector array
One or more values to be written to the file
vector2optional vector or vector array
Command can accept any number of vectors/arrays to write to the file

Flags

NameFlag argumentsArgument typeExclusive toComments
delim1stringDelimiter to use between vector channel values. Cannot be used with binary files. Usually "," or "\t", etc.
cast1stringData type to cast to. Possible types are listed above. Note that data can be lost when casting.

Return value

void

Examples

vector $vec = << 100.0, 500.7, -50.5 >>;
int $fileID;
// Open the file and get the ID 
// ...
// Write the vector
// The -delims flag assumes you are writing to a text file 
writeVec $fileID $vec -delims ",";

Additional information

Related commands