User's Guide

LASAWK

Return a substring from an ASCII file

Function:

Search the contents of a file for a specified text string. Extract a substring of the the line where the search string was found and return it to a TAE variable.

Parameters:

INFILE
Input file name. The name of the ASCII file to be searched. Host file naming conventions must be used.

TEXT
Text string. The text string to be searched for. This string must be unique within INFILE. If not, the substring in each line that matches will be returned in OUT. UNIX wild card characters are not allowed within this string.

WORDNUM
Word number. Specifies which word is to be extracted from the line of INFILE where TEXT was found.

START(1)
Starting position. The starting character position in WORDNUM where the substring will be extracted.

LENGTH(--)
Length of substring. The number of characters to extract from WORDNUM. If LENGTH is NULL, all characters from START to the end of the substring are extracted.

OUT
Output string. The substring of the desired word is returned in the specified TAE string variable.

Example:

  1. LAS> lasawk infile="dspassoc.prt" text="sun_elev" wordnum=3 start=3 length=2 out=temp

    The file, dspassoc.prt, is searched for the text string "sun_elev". From this line, the third word, starting at the third character and having a length of two, will be returned in the TAE string variable TEMP. Based on these parameters and given the following string which exists in dspassoc.prt, "53" is returned to TEMP.

    	annotation_sun_elevation      SUN EL53
    

Description/Algorithm:

A system-specific routine is called to perform the extraction, and the output value is returned to the TAE variable specified in OUT.

Nonfatal Error Messages:

    None.

Fatal Error Messages:

    None.

User Notes:

  1. LASAWK is useful for getting information from an ASCII file into a procedure PDF for use as a parameter or for procedure control.

  2. Refer to the UNIX man page for more information on awk.