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

Sets the current file position.

Use this command to set your position in a file. The value is in bytes from the origin, which you specify in the `origin` argument. The file position can be set past the end of the file in Write mode.

This command only makes sense in files opened in binary mode.

## Functional area

Disk I/O

# Command syntax

## Syntax

> Macro (scroll-tablelayout)

|  |
| --- |
| `setFilePos fileID offset [-cur] [-end]` |

### Arguments

> Macro (scroll-tablelayout)

| Name | Type | Required | Comments |
| --- | --- | --- | --- |
| `origin` | string |  | Origin that the offset is defined against, either beg for the beginning of the file, cur for the current file position, or end for the end of the file. |
| `offset` | int |  | Offset in bytes from the origin to set the file position to |
| `fileID` | int |  | ID of file previously opened with [fileOpen](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253738450) |

### Flags

| Name | Flag arguments | Argument type | Exclusive to | Comments |
| --- | --- | --- | --- | --- |
| `cur` | 0 | — | end | — |
| `end` | 0 | — | cur | — |

## Return value

void

## Examples

```plaintext
int $fileID;
int $filePos;
$fileID = `fileOpen "C:/testfile.log" "r"`;
 
// Read a value from the file, which "points" to another part of the
// file. This could be done in a file "header" section
$filePos = `readInt $fileID`;
print $filePos;
 
// Move to the file position "pointed" to earlier, so we can do some
// reading
setFilePos $fileID $filePos;
```

# Additional information

## Related commands

- [getFilePos](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737915)