CHOOSE CASE – PB Docs 126

CHOOSE CASE

Description

A control structure that directs program execution based on
the value of a test expression (usually a variable).

Syntax

Parameter

Description

testexpression

The expression on which you want to base
the execution of the script

expressionlist

One of the following expressions:

  • A single value

  • A list of values separated by commas (such as 2,
    4, 6, 8)

  • A TO clause (such as 1
    TO 30
    )

  • IS followed by a relational operator
    and comparison value (such as IS>5)

  • Any combination of the above with an implied OR between
    expressions (such as 1, 3, 5, 7, 9, 27 TO 33, IS >42)

statementblock

The block of statements you want PowerBuilder
to execute if the test expression matches the value in expressionlist

Usage

At least one CASE clause is required. You
must end a CHOOSE CASE control structure
with END CHOOSE.

If testexpression at the beginning of
the CHOOSE CASE statement
matches a value in expressionlist for a CASE clause,
the statements immediately following the CASE clause
are executed. Control then passes to the first statement after the END CHOOSE clause.

If multiple CASE expressions exist, then testexpression is
compared to each expressionlist until a match
is found or the CASE ELSE or END CHOOSE is encountered.

If there is a CASE ELSE clause and the
test value does not match any of the expressions, statementblock in
the CASE ELSE clause is executed. If no CASE ELSE clause
exists and a match is not found, the first statement after the END CHOOSE clause
is executed.

Examples

[Example 1]

These statements provide different processing based on the
value of the variable Weight:

[Example 2]

These statements convert the text in a SingleLineEdit control
to a real value and provide different processing based on its value:


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