# field() function

The field() function returns a substring
from a string expression, by specifying a delimiter and the desired
occurrence.

## Syntax

```
field(str.exp, search.delimiter, num.delimiters, num.substr)
```

## Parameter(s)

| str.exp | String from which the substring will be returned. |
| --- | --- |
| search.delimiter | Delimiter to search for. The delimiter is limited to a single character. Any additional characters are ignored. |
| num.delimiters | Number of delimiters to skip, plus one, prior to substring extraction. |
| num.substr | Number of substrings separated by the specified delimiter to be returned. |

## Description

After executing the field() function, the col1() and col2() functions return the beginning and ending positions
within the string at which the delimiters were found.

## Example(s)

This causes all characters up
to the first asterisk in `gl.account` to be assigned
to the variable `company.code`. As a result, afterward, `company.code` contains the value, 02. col1() has a value of 0, and col2() has a value of 3.

```
gl.account = "02*4000*11"
company.code = field(gl.account,"*",1)
```
This causes all characters from the first to the second
asterisk to be stored in the variable, `acct.number`, which contains the value, 4000.

```
acct.number = field(gl.account,"*",2)
```

## See also

- [col1() function](https://d3codex.com/pickbasic-flashbasic/col1-function/)
- [col2() function](https://d3codex.com/pickbasic-flashbasic/col2-function/)
- [BASIC functions](https://d3codex.com/pickbasic-flashbasic/basic-functions/)
- [Numeric expressions](https://d3codex.com/pickbasic-flashbasic/numeric-expressions/)
- [procread statement](https://d3codex.com/pickbasic-flashbasic/procread-statement/)
- [Statements and functions](https://d3codex.com/pickbasic-flashbasic/statements-and-functions/)
- [Substring expressions](https://d3codex.com/pickbasic-flashbasic/substring-expressions/)
- [Substring expressions](https://d3codex.com/pickbasic-flashbasic/substring-expressions/)
- [Substring expressions](https://d3codex.com/pickbasic-flashbasic/substring-expressions/)
- [Substring expressions](https://d3codex.com/pickbasic-flashbasic/substring-expressions/)
- [tclread statement](https://d3codex.com/pickbasic-flashbasic/tclread-statement/)

---
Source: https://d3codex.com/pickbasic-flashbasic/field-function/ - part of the D3Codex reference.
