Home page  
Help >
String Parsing Functions
Version 7.11
String Parsing Functions String Parsing Functions

You can break any string apart and determine its components so as to make decisions or for later use in downstream commands or statements. The choices are whether you want the scan to be blank delimited (NXT), to be for a specific number of characters (NXTN or NXTW), or you want to specify the possible delimiters (NXTD).

nxt(string) -Selects all characters up to the next space (blank)
encountered in the subject string. Since this is blank
delimited it is basically scanning one word at a time.

nxtn(string;n) -Selects the number of characters you specify.

nxtd(string;"d") -Selects all characters up to the next delimiter
encountered in the subject string. Note that the
specified delimiter(s) must be surrounded by quotes.

nxtw(string;n) -Same as NXTN except it will not split a word. That is,
it tries to give you n characters, but if that winds up
right in the middle of a word it will back up to the
nearest blank and give you less than n characters.

We call the portion selected from the subject string a "token." In all of the above, "string" is a variable.

When the scan is from a variable to a variable it is destructive, that is, the requested token is shifted (actually removed) from the subject string and becomes the result. So if you wish to preserve the original string you must SET it into a working variable before you start scanning. For example:

timing %time Suppose the TIMING left %time=11:30:32.
set %hour=nxtd(%time;":") At the end of the three scans %hour=11,
set %min =nxtd(%time;":") %min=30, %sec=32, and %time=null.
set %sec =nxtd(%time;":")

timing %time Same as above, but now at the end of the
set %xxx=%time three scans %hour=11, %min=30, %sec=
set %hour=nxtd(%xxx;":") 32, %xxx=null and %time still retains its
set %min =nxtd(%xxx;":") original value of 11:30:32.
set %sec =nxtd(%xxx;":")

When the scan is from a memo field (in Reports) it is non-destructive, a pointer is advanced through the subject string as the scan progresses. You can start the scan over by saying RESETTEXT.

set %xx=nxt(%aa) Transfers the next whole word of %aa into %xx.

set %xx=nxtd(%aa;"/-,") Scan and transfer to the next delimiter. The possible
delimiters are the slash, dash, or comma.

set %xx=nxtn(%aa;5) Transfer the next five characters of %aa into %xx.

Copyright © 2019 , WhamTech, Inc.  All rights reserved. This document is provided for information purposes only and the contents hereof are subject to change without notice. Names may be trademarks of their respective owners.