Previous Topic: EXECNCL Macro

Next Topic: GENALERT Macro

EXTRACT Macro

The EXTRACT macro extracts a segment from a text string.

Parameters: EXTRACT Macro

Where to Extract From—Input

Specifies the string from which you want to extract the text segment. This string can contain text and variables.

Variable to hold Extracted String—Output

Specifies the name of the variable in which you want to put the extracted text string.

How to do the Extraction

The following fields determine the text you want to extract. You must specify at least one of the Starting Position and Find Text fields. If you complete both fields, the macro looks first at the value of the Find Text field and then adds the value of the Starting Position field. The result locates the first character of the extracted segment.

Starting Position

Used in conjunction with the Length to Extract field, the Input field, and the Find Text field (if it is completed) to identify the text string you want to extract.

The Starting Position field accepts a number (n) from 1 through 256. The value specifies the first character of the text segment to be extracted.

Length to Extract

Specifies the number of characters you want to extract, effectively indicating the end point of the extracted text string.

The Length to Extract field accepts a number from 1 through 256. The value specifies the number of characters that will be in your extracted string. If a value is not specified in this field, the full string or substring is extracted.

Find Text

If completed, must contain a section of the string specified in the Input field.

The Find Text field accepts a text string from 1 through 53 characters in length. The first character in this text string, plus the value in the Starting Position field, determines the first character of the extracted text. The last character in the extracted text is determined by the value in the Length to Extract field.

Example 1: EXTRACT Macro

In the following example, the EXTRACT macro is used to extract the text string DEF. Because no value is specified in the Find Text field, the reference point for the starting position is the first character of the value of the Input field. In this example, the first character of the extract is the 5th character of the Input text string (D), and because the length to extract is 3, the resulting extract is DEF.

PROD----- Automation Services : EXTRACT Macro Parameter Definition ------------ Command ===> Function=BROWSE .- Where to Extract From -----------------------------------------------------. | Input .... ABC DEF GHI JKL MNO | | (Text String or Variable(s)) | ’-----------------------------------------------------------------------------’ .- Variable to hold Extracted String -----------------------------------------. | Output ... FRED (Variable Name) | | | ’-----------------------------------------------------------------------------’ .- How to do the Extraction --------------------------------------------------. | Starting Position ... 5 (Extraction to begin from this position. (1-256)) | | | | Length to Extract ... 3 (Extract data for this length. (1-256)) | | | | Find Text ........... | | (Extraction to begin from the start of this text + Starting Position) | ’-----------------------------------------------------------------------------’ F1=Help F2=Split F3=Exit F9=Swap

Example 2: EXTRACT Macro

In the following example, the EXTRACT macro is used to extract the text string GHI J. Because no value has been given to the Starting Position field, the reference point for the starting position is the value of the Find Text field. In this example, the first character of the extract is the first character of the Find Text string (G), and because the length to extract is 5, the resulting extract is GHI J.

PROD----- Automation Services : EXTRACT Macro Parameter Definition ------------ Command ===> Function=BROWSE .- Where to Extract From -----------------------------------------------------. | Input .... ABC DEF GHI JKL MNO | | (Text String or Variable(s)) | ’-----------------------------------------------------------------------------’ .- Variable to hold Extracted String -----------------------------------------. | Output ... FRED (Variable Name) | | | ’-----------------------------------------------------------------------------’ .- How to do the Extraction --------------------------------------------------. | Starting Position ... (Extraction to begin from this position. (1-256)) | | | | Length to Extract ... 5 (Extract data for this length. (1-256)) | | | | Find Text ........... GH | | (Extraction to begin from the start of this text + Starting Position) | ’-----------------------------------------------------------------------------’ F1=Help F2=Split F3=Exit F9=Swap

Example 3: EXTRACT Macro

In the following example, the EXTRACT macro is used to extract the text string HI JK. In this example, a value has been given to the Find Text field, and therefore that value becomes the reference point for the starting position. Because a value of 2 has been given to the Starting Position field, the first character of the extract is the second character of the Find Text string (H), and because the length to extract is 5, the resulting extract is HI JK.

PROD----- Automation Services : EXTRACT Macro Parameter Definition ------------ Command ===> Function=BROWSE .- Where to Extract From -----------------------------------------------------. | Input .... ABC DEF GHI JKL MNO | | (Text String or Variable(s)) | ’-----------------------------------------------------------------------------’ .- Variable to hold Extracted String -----------------------------------------. | Output ... FRED (Variable Name) | | | ’-----------------------------------------------------------------------------’ .- How to do the Extraction --------------------------------------------------. | Starting Position ... 2 (Extraction to begin from this position. (1-256)) | | | | Length to Extract ... 5 (Extract data for this length. (1-256)) | | | | Find Text ...........GH | | (Extraction to begin from the start of this text + Starting Position) | ’-----------------------------------------------------------------------------’ F1=Help F2=Split F3=Exit F9=Swap