Pos – PB Docs 2017

Pos

PowerScript function

Description

Finds one string within another string.

Syntax

Argument

Description

string1

The string in which you want to find
string2.

string2

The string you want to find in
string1.

start (optional)

A long indicating where the search will begin in
string1. The default is 1.

Return value

Long. Returns a long whose value is the starting position of the
first occurrence of string2 in string1 after the position specified in
start. If string2 is not found in string1 or if start is not within
string1, Pos returns 0. If any argument’s value is null, Pos returns
null.

Usage

The Pos function is case sensitive.

Examples

This statement returns 6:

This statement returns 1:

This statement returns 0, because the case does not match:

This statement starts searching at position 4 and returns 0, because
position 4 is after the occurrence of BE:

These statements change the text NY in the SingleLineEdit
sle_group to North East:

These statements separate the return value of GetBandAtPointer into
the band name and row number. The Pos function finds the position of the
tab in the string and the Left and Mid functions extract the information
to the left and right of the tab:

You could write similar code for a generic parsing function with
three arguments. The string s would be an argument passed by value and
ls_left and ls_right would be strings passed by reference.

Other functions that return a pair of tab-separated values for which
you could use the parsing function are GetObjectAtPointer and
GetValue.

See also

GetValue method for DataWindows in the section called “GetValue” in DataWindow Reference.

GetObjectAtPointer method for DataWindows in the section called “GetObjectAtPointer” in DataWindow Reference.

LastPos

Left

Mid

Right

Pos method for DataWindows in the section called “Pos” in DataWindow Reference.


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x