PowerScript Statements

GOTO statement

Description

PowerScript GOTO statements and Label are unsupported. Using GOTO is not recommended in structured programming.

Workaround

Analyze the code that uses GOTO and re-write the code in a structured way by applying IF ... THEN ... statements.

If the statement that the GOTO label is associated with has a return value, place the statement in a user function, and in place of the GOTO statement, call the user function.

If the statement that the GOTO label is associated with has no return value, place the statement directly in place of the GOTO statement.

Example

The original script:

IF sle_1.text = "" THEN GOTO hide_sle_1
sle_1.text = ""
hide_sle_1:
sle_1.visible = false
MessageBox ("","SingleLineEdit sle_1 is cleared and hidden.")

Re-write it using IF ... THEN... statement:

IF sle_1.text = "" THEN 
sle_1.visible = false
MessageBox ("","SingleLineEdit sle_1 is cleared and hidden.")
ELSE
sle_1.text = ""
sle_1.visible = false
MessageBox ("","SingleLineEdit sle_1 is cleared and hidden.")
END IF

Re-write it using CHOOSE CASE statement:

CHOOSE CASE sle_1.text
CASE ""
sle_1.visible = false
MessageBox ("","SingleLineEdit sle_1 is cleared and hidden.")
CASE ELSE
sle_1.text = ""
sle_1.visible = false
MessageBox ("","SingleLineEdit sle_1 is cleared and hidden.")
END CHOOSE