Pos Command

Obsolete

This command is replaced by the Pos function.

 

See Also

Purpose

To return the position of the beginning of one string of characters within another string that includes the value of the first string.

Syntax

pos subString in hostString [to variable]

What It Does

Pos scans hostString for subString. If subString is in hostString, pos moves the position (counted from the left) of the first character in subString to Predefined Variable strmark and to variable, if specified, and sets Predefined Indicator found true. If subString is not in source, zero is moved to strmark and variable, and found is set false.

string whole

number place

move "abcdefgh" to whole

pos "def" in whole to place

In this example, pos searches for subString def in the value of String Variable source. It will place a value of 4 in Predefined Variable strmark and Number Variable place, and set Predefined Indicator found true.

Pos sets the value of Predefined Variable strmark, which is used by the mid and right commands when those commands omit a variable specification. This is intended to facilitate implicit positioning illustrated by the following example:

string alpha_suffix

pos "A" in "123ABC"

[found] right "123ABC" to alpha_suffix

In this example, the pos command places 4 (the position of A in 123ABC) in strmark. The succeeding right command will use 4 as the position specification, and move the subString (ABC) beginning at that position to String Variable alpha_suffix. The action would not be affected if the pos command had a variable specifier, but it would be defeated if the right command had one.

Notes

 

pos "DEF" in "abcdefgh" to place