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

This command can be used to search within a text file for a specified string. It returns a Boolean value to indicate whether the search was successful or not.

It can be used for custom File I/O scripts.

This command can only be run on a file that is already open using [fileOpen](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253738450) in Read mode. If the file has not been opened with readable flags then seekToString will fail.

## Functional area

Disk I/O

# Command syntax

## Syntax

> Macro (scroll-tablelayout)

|  |
| --- |
| `seekToString fileID "searchString"` |

### Arguments

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

### Flags

None

## Return value

boolean 

> Macro (scroll-pagebreak)

## Examples

```plaintext
//set search string
string $str = "zb"; 
int $fileID;
boolean $StringExists;
 
//open file for reading
int $fileID = `fileOpen "C:/myfile.txt" "r"`;
 
//search for string
$StringExists = `seekToString $fileID $str`;
 
//print true or false to log
print $StringExists;
 
//close file
fileClose $fileID;
```

# Additional information

## Related commands

- [fileClose](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736768)
- [fileOpen](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253738450)
- [isFileReadable](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253738146)