GetField - extract a field from a field-separated string

Return to Introduction  Previous page  Next page

$return = GetField(string,field#[,separator])

Where:

$returnreceives 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

 

$Field = GetField("The quick brown fox",2," ")

$Field = GetField("The,quick,brown,fox",2,",")

 

Sample Script

 

' GetField.txt

' Sample script to extract fields

'

$String = "The quick brown fox"

$FieldNumber = 1

$Fields = 4

 

LOOP:

$Field = GetField($String,$FieldNumber," ")

type($Field)

$FieldNumber = $FieldNumber + 1

if $FieldNumber < $Fields then GoTo LOOP:

Exit

 

See Also:

 

Script Command Summary

Script Variables

Using the Scripting Language

 


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