---
title: "readToken"
canonical: "https://help.vicon.com/space/ShogunPost121/1253737987/readToken"
format: markdown
---
# 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

> Macro (scroll-tablelayout)

|  |
| --- |
| `readToken fileID [-delims string]` |

### Arguments

| Name | Type | Required | Comments |
| --- | --- | --- | --- |
| `fileID` | int |  | ID of file previously opened with [fileOpen](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253738450) |

### Flags

> Macro (scroll-tablelayout)

| Name | Flag arguments | Argument type | Exclusive to | Comments |
| --- | --- | --- | --- | --- |
| `delims` | 1 | string | — | Delimiters to expect between tokens. Default is space, tab, or newline. |

## Return value

string 

> Macro (scroll-pagebreak)

## Examples

```plaintext
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

- [readLine](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737732)
- [readString](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736766)