Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

Find – PB Docs 2022 – PowerBuilder Library

Find – PB Docs 2022

Find

method (DataWindows)

Description

Finds the next row in a DataWindow or DataStore in which data meets
a specified condition.

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataWindowChild object, DataStore
object

Syntax

PowerBuilder

Argument

Description

dwcontrol

A reference to the DataWindow control, DataStore, or
child DataWindow in which you want to search the detail
band.

expression

A string whose value is a boolean expression that you
want to use as the search criterion. The expression includes
column names.

start

A value identifying the row location at which to
begin the search. Start can be greater than the number of
rows.

end

A value identifying the row location at which to end
the search. End can be greater than the number of rows. To search
backward, make end less than start.

buffer (optional)

The name of the buffer from which you want to find
data.

Values are:

  • Primary — (Default) The data in the primary buffer
    (the data that has not been deleted or filtered out).

  • Delete — The data in the delete buffer (data deleted
    from the DataWindow control).

  • Filter — The data in the filter buffer (data that was
    filtered out).

Return value

Returns the number of the first row that meets the search criteria
within the search range. Returns 0 if no rows are found and one of these
negative numbers if an error occurs:

-1 — General error

-5 — Bad argument

If any argument’s value is null, in PowerBuilder and JavaScript the
method returns null.

Usage

PowerBuilder environment

For use with a RichTextEdit control or presentation style, see
the section called “Find” in PowerScript Reference.

The search is case-sensitive. When you compare text to a value in
a column, the case must match.

When the Find expression includes
quotes

If the text you want to find includes quotes, you must treat the
nested quote as doubly nested, because the DataWindow parses the string
twice before the Find method uses it. Therefore, you cannot simply
alternate double and single quotes, as you can in most strings.

For example, to find the name O’Connor, the Find expression can
be:

“O~~~’Connor” (3 tildes and single quote) or

“O~~~~~”Connor” (5 tildes and double quote)

but not:

“O’Connor” or “O~”OConnor”

When the last row satisfies the search
criteria

If you use Find in a loop that searches through all rows, you may
end up with an endless loop if the last row satisfies the search criteria.
When the start value becomes greater than end, the search reverses
direction and Find would always succeed, resulting in an endless
loop.

To solve this problem, you could make the end value 1 greater than
the number of rows (see the examples). Another approach, shown below,
would be to test within the loop whether the current row is greater than
the row count and, if so, exit. This PowerBuilder code illustrates
how:

Examples

This statement searches for the first row in dw_status in which the
value of the emp_salary column is greater than 100,000. The search begins
in row 3 and continues until it reaches the last row in dw_status:

To test values in more than one column, use boolean operators to
join conditional expressions. The following statement searches for the
employee named Smith whose salary exceeds 100,000:

These statements search for the first row in dw_emp that matches the
value that a user entered in the SingleLineEdit called Name (note the
single quotes embedded in the search expression around the name):

This script excerpt finds the first row that has a null value in
emp_id. If no null is found, the script updates the DataWindow object. If
a null is found, it displays a message:

The following script attached to a Find Next command button searches
for the next row that meets the specified criteria and scrolls to that
row. Each time the button is clicked, the number of the found row is
stored in the instance variable il_found. The next time the user clicks
Find Next, the search continues from the following row. When the search
reaches the end, a message tells the user that no row was found. The next
search begins again at the first row.

Note that although the search criteria are hard-coded here, a more
realistic scenario would include a Find button that prompts the user for
search criteria. You could store the criteria in an instance variable,
which Find Next could use:

This example searches all the rows in dw_main and builds a list of
the names that include a lowercase a. Note that the end value of the
search is one greater than the row count, avoiding an infinite loop if the
name in the last row satisfies the search:

See also

FindGroupChange

FindRequired


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