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

Use to read an integer value 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 signed character, or signed 8-bit (1 byte) value, and converts it to an integer |
| `uc` | Reads an unsigned character, or unsigned 8-bit (1 byte) value, and converts it to an integer |
| `s` | Reads a signed short integer, or signed 16-bit (2 bytes) value, and converts it to an integer |
| `us` | Reads an unsigned short integer, or unsigned 16-bit (2 bytes) value, and converts it to an integer |
| `i` | Reads a signed integer, or signed 32-bit (4 bytes) value, and converts it to an integer |
| `ui` | Reads an unsigned integer, or unsigned 32-bit (4 bytes) value, and converts it to an integer |
| `f` | Reads a floating point value, a 32-bit (4 byte) value, and converts it to an integer |

## Functional area

Disk I/O

# Command syntax

## Syntax

> Macro (scroll-tablelayout)

|  |
| --- |
| `readInt fileID [-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) |

> Macro (scroll-pagebreak)

### Flags

> Macro (scroll-tablelayout)

| Name | Flag arguments | Argument type | Exclusive to | Comments |
| --- | --- | --- | --- | --- |
| `cast` | 1 | string | — | Data type to cast from. Possible types are listed above. Note that data can be lost when casting. |

## Return value

integer

## Examples

```plaintext
//Read example
int $val;
int $fileID;
int $fileID = `fileOpen "C:/FileTesting.txt" "r"`;
  
$val = `readInt $fileID`; // Read the boolean value
 
fileClose $fileID;  //make sure to close the file
  
// Display the value
print $val;
```

# 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)
- [readRot](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737158)
- [readString](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736766)
- [readVec](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737170)