/
readToken

readToken

Description

Use to read a string token from a file. A string token is simply a series of characters, separated by any number of delimiters. For example, the sentence "ShogunPost is for editing" is composed of the tokens "ShogunPost", "is", "for", and "editing", assuming the delimiter is a space. You can " tokenize" the contents of a file for easy parsing.

Note that this command can only be used with text files (files opened without the -b flag). Command will fail if at the end of the file.

Functional area

Disk I/O

Command syntax

Syntax

readToken fileID [-delims string]

Arguments

NameTypeRequiredComments
fileIDint
ID of file previously opened with fileOpen

Flags

NameFlag argumentsArgument typeExclusive toComments
delims1stringDelimiters to expect between tokens. Default is space, tab, or newline.

Return value

string

Examples

string $token;
int $fileID;
  
// Open a sample text file
$fileID = `fileOpen "c:/samplefile.txt" "r"`;
  
// Keep reading in tokens from the file
while( `isEndOfFile $fileID` == false )
 { 
     $token = `readToken $fileID`; 
     // Do something with token 
     print $token;
 }

Additional information

Related commands

Related content


© Copyright Vicon Motion Systems. All rights reserved.

Vicon trademarks