GetField - extract a field from a field-separated string

Return to Introduction  Previous page  Next page

GetField $variable,string,field#[,separator]

Where:

$variablereceives the field read from the string.
stringis the string containing the field to be extracted.
field#is the field number to extract.        
separator is the single character field separator. The default is a comma. If coding a comma it should be enclosed in double quotes.

 

string, field# and separator may be variables.

The GetField command extracts a field from a field-separated string and copies it into a script variable.

Examples

 

GetField        $FIELD,"The quick brown fox",2," "
GetField        $FIELD,"The,quick,brown,fox",2,","

 

Sample Script

 

* GetField.txt

* Sample script to extract fields

*

SetVar $String,"The quick brown fox"

SetVar $FieldNumber,1

SetVar $Fields,4

 

LOOP:

GetField $Field,$String,$FieldNumber," "

type $Field

CalcVar $FieldNumber,$FieldNumber,+,1

if $FieldNumber,LE,$Fields,LOOP:

 

Exit

 


TN3270 Plus is continually being improved. To learn more about the latest enhancements, please review our Version History web page.