Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

Version 1 Current »

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

  • No labels