Please enable JavaScript to view this site.

ESL Documentation

Action Statement

Extract data fields from an input string and assign them to a variable.

extract from SOURCE

[skip {by|to}

{word|number|last|marker|float|TEXT|COLUMN}] ...

take {by|to}

{word|number|last|marker|float|TEXT|COLUMN} VAR_NAME

[[ take {by|to}

{word|number|last|marker|float|TEXT|COLUMN} VAR_NAME

| skip {by|to}

{word|number|last|marker|float|TEXT|COLUMN}] ...]

SOURCE

A string value representing the source of the input being examined. If you are extracting strings from a textual region, the SOURCE should be one of the textual built-in functions.

TEXT

A string value representing the text being extracted or skipped.

COLUMN

An integer value representing the number of columns (when used with skip by or take by), or the column number (when used with skip to or take to).

VAR_NAME

The identifier for a variable name.

skip to marker

take to marker

Start with the current pointer position and skip or take characters up to, but not including, the pointer position at the time of the last extract from statement. After execution, the pointer position is the marker.

skip to last

take to last

Start with the current pointer position and skip or take characters up to and including the last character in the source. After execution, the pointer is positioned after the last character in the source.

skip by word

take by word

Start with the current pointer position, skip over any leading blanks, then skip or take the characters up to but not including the first non-printing character (e.g., blank) or the end of the source. Numeric characters are considered part of the word. After execution, the pointer is positioned after the last character of the word.

skip to word

take to word

Start with the current pointer position and skip or take characters up to, but not including, the first non-printing character encountered. After execution, the pointer is positioned at the beginning of the word.

skip by number

take by number

Start with the current pointer position, skip over any leading blanks, and then skip or take subsequent digits (which may include a leading sign) up to the first non-digit (e.g., a blank, a decimal point, or an alphabetic character) or the end of the source. These clauses only skip over spaces and tabs. After execution, the pointer is positioned immediately after the end of the number.

skip to number

take to number

Start with the current pointer position and skip or take blanks, up to the first non-blank character that might start an integer. These clauses only skip over spaces and tabs. After execution, the pointer is positioned at the beginning of the number.

skip by float

take by float

Start with the current pointer position, skip over any leading blanks and alphabetic characters, then skip or take subsequent digits (which may include a decimal point or a leading sign) up to either the first non-digit (e.g., a blank, an alphabetic character, or a second decimal point) or the end of the source. After execution, the pointer is positioned immediately after the end of the floating point number.

skip to float

take to float

Start with the current pointer position and skip or take subsequent characters up to the first non-blank, non-alphabetic character that might start a floating point number (e.g., a digit, leading sign, or decimal point). These clauses do pass over alphabetic characters. After execution, the pointer is positioned at the beginning of the floating point number.

skip by TEXT

take by TEXT

Start with the current pointer position, search for the beginning of the specified string, and skip or take the specified string. After execution, the pointer is positioned at the first character after the end of the string.

skip to TEXT

take to TEXT

Start with the current pointer position, search for the beginning of the specified string, and skip or take characters up to but not including the specified string. The pointer is then positioned at the first character in the string.

skip by COLUMN

take by COLUMN

Start with the current pointer position and skip or take characters from left to right for the specified number of columns. After execution, the pointer is positioned after the last character for the specified number of columns.

This is the only clause for the extract from statement that allows you to specify a negative value. When you specify a negative number, either of these clauses starts at one position to the left of the current pointer position and moves the pointer by the specified number of columns, from right to left. For take clauses, characters are taken from left to right. After execution, the pointer is positioned at the leftmost column to which it was moved.

skip to COLUMN

take to COLUMN

Start with the current pointer position and skip or take characters up to but not including the specified column number. The designated column number must be in the range of one to the column number of the final character of the source. After execution, the pointer is positioned at the specified column number.

Description

You must specify at least one take clause. The only difference between the take clause and the skip clause is that take both moves the internal pointer and copies the processed characters into the variable, whereas skip simply moves the pointer.

If the program is compiled with External Strings, then any string literals used in this statement will be externalized.

If ESL cannot find the specified characters, the pointer does not move, and, in take clauses, the following values are copied to the specified variable:

Variable

Value

word

""

number

0

float

0.00

TEXT

""

COLUMN

""

Errors

The following are invalid clauses and will generate error messages:

skip by marker

take by marker

skip by last

take by last

Example

 

response to line from Host # line is " 123%Four "

 extract from input

 skip to number # Cursor positioned on "1"

 take to "%" MyID # "123" stored in MyID

# and cursor positioned on "%"

 skip by 1 # Cursor positioned on "F"

 take by word MyPW # "Four" stored in MyPW

See Also

textual Object Inquiry Built-in Function