---
title: "readVec"
canonical: "https://help.vicon.com/space/ShogunPost121/1253737170/readVec"
format: markdown
---
# Description

Use to read a vector from a file. Command will fail if at the end of the file.

The following is a listing of 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.

> Macro (scroll-tablelayout)

| Cast | Description |
| --- | --- |
| `c` | Reads a series of signed characters, or signed 8-bit (1 byte) values, and converts them to floats |
| `uc` | Reads a series of unsigned characters, or unsigned 8-bit (1 byte) values, and converts them to floats |
| `s` | Reads a series of signed short integers, or signed 16-bit (2 bytes) values, and converts them to floats |
| `us` | Reads a series of unsigned short integers, or unsigned 16-bit (2 bytes) values, and converts them to floats |
| `i` | Reads a series of signed integers, or signed 32-bit (4 bytes) values, and converts them to floats |
| `ui` | Reads a series of unsigned integers, or unsigned 32-bit (4 bytes) values, and converts them to floats |
| `f` | Reads a series of floating point values, a 32-bit (4 byte) values, and converts them to floats |

## Functional area

Disk I/O

> Macro (scroll-pagebreak)

# Command syntax

## Syntax

> Macro (scroll-tablelayout)

|  |
| --- |
| `readVec fileID[-delim string] [-cast 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 |
| --- | --- | --- | --- | --- |
| `delim` | 1 | string | — | Delimiter to expect between vector channel values. Cannot be used with binary files. Usually"," or "\t", etc. |
| `cast` | 1 | string | — | Data type to cast to. Possible types are listed above. Note that data can be lost when casting data. |

## Return value

vector

> Macro (scroll-pagebreak)

## Examples

```plaintext
vector $vec;
int $fileID;
int $fileID = `fileOpen "C:/FileTesting.txt" "r"`;
  
// Read the vector
// The -delims flag assumes you are reading from a text file 
$vec = `readVec $fileID -delim ","`;
fileClose $fileID;
  
// Display the value
print $vec;
```

# Additional information

## Related commands

- [readBool](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736547)
- [readFloat](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736929)
- [readInt](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736844)
- [readRot](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737158)
- [readString](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736766)