Important

   

This documentation space contains information about PATROL Agents when deployed in a TrueSight Operations Management environment. If you are a BMC Helix Operations Management user, see PATROL Agent 22.1 for BMC Helix Operations Management. Open link

nthargf()

Return a formatted string containing fields from a text string.

Syntax

nthargf(text,arguments,[delimiters],[separator],[line_separator])

Parameter

Parameter

Definition

text

text to be separated into fields by the nthargf() function The text can be a text string enclosed in double quotation marks, or one or more PSL commands that produce text as output.

arguments

integer list specifying the field numbers nthargf() should look for in each line of text*Valid Values* 
x,y field x and field y 
x-y all fields from x to y inclusive 
-x all fields from 1 to x inclusive 
x- all fields from x to the new-line character inclusive

delimiters

one or more characters that nthargf() should treat as field separators when examining text Thenthargf() function treats each occurrence of delimiters as delimiting a field. The nthargf() function interprets two or more adjacent delimiters as delimiting one or more NULL fields.

Default 
space and \t (tab)

separator

optional character(s) that should be placed between each field of nthargf() output*Default* 
new-line character (\n).

line_separator

optional character(s) that nthargf() uses to replace each new-line character (\n) that appears intext

Default 
new-line character (\n).

Example 
If separator is "-" and line_separator is "?", ntharg() converts "red green\nblue orange\nyellow purple" to "red-green?blue-orange?yellow-purple".

Description

The nthargf() function returns the arguments in text. The nthargf() function normally interprets each line in text as a white space-separated (space or tab) list of fields. If delimiters is given, it specifies the list of characters that nthargf()should treat as field separators. The nthargf() function normally returns selected fields as a new-line delimited list. Ifseparator is given, it specifies the delimiter to be placed between items in the returned list. 

The difference between the nthargf() function and the ntharg() function is as follows:

  • The nthargf() function treats each delimiter as the end of a field. The nthargf() function interprets two or more adjacent delimiters as delimiting one or more NULL strings whose content can be requested and returned.
  • The ntharg() function treats each delimiter that follows a non-delimiter character as the end of a field. Thentharg() function interprets two or more adjacent delimiters as a single delimiter, thereby ignoring multiple delimiters and treating them as one.

Example

The following example illustrates the difference between the ntharg() function and the nthargf() function:

string = "abc::123:xyz";
A = ntharg(string,"3",":");
B = nthargf(string,"3",":");
print("ntharg() 3rd string argument is ",A,"\n");
print("nthargf() 3rd string argument is ",B,"\n");

The example produces the following output:

ntharg() 3rd string argument is xyz
nthargf() 3rd string argument is 123


Was this page helpful? Yes No Submitting... Thank you

Comments