PowerScript statements

Supported

The following table shows the supported PowerScript statements with examples:

Table 172. 

Statement

Examples

Assignment

a = b + 2

Note: There must not be any space between the following operators: ++, --, +=, -=, *=, /=, ^=.

CALL

CALL ancestorobject {controlname}::event

Call super::eventname

Example:

Call super::clicked

Note: It is supported to use the local variable AncestorReturnValue in an event of a descendant object, if the AncestorReturnValue is generated in a Call Super statement.

Call windowname::eventname

Example:

Call w_parent::ue_ok

Call windowname Controlname::eventname

Example:

Call w_parent dw_1::ue_retrieve

CHOOSE...CASE

CHOOSE CASE testexpression
CASE expressionlist
statementblock
{ CASE expressionlist
statementblock
. . .
CASE expressionlist
statementblock }
CASE ELSE
statementblock }
END CHOOSE

Notes:

Expressionlist can be one of the following expressions:

1) A single value

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

3) A TO clause (such as 1 TO 30)

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

5) Functions

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

CONTINUE

integer A=1, B=1
  DO WHILE A < 10
  A ++
    IF A < 3 THEN CONTINUE
    B+=A
  LOOP

CREATE

CREATE

Support creating object instances for all objects except for PowerObject object, GraphicObject object, WindowObject object, DragObject object, DrawObject object, Function_object object and SystemFunctions object.

CREATE USING

Support dynamically creating object instances except for:

1) Dynamically creating PowerObject object, GraphicObject object, WindowObject object, DragObject object, DrawObject object, Function_object object and SystemFunctions object.

Example:

UserObject luo_1
luo_1 = create using "PowerObject"

2) Dynamically creating Transaction object.

Example:

lds_main = Create using "Transaction"

3) Dynamically creating object instances for nested objects.

Example:

w_main cb_1 lcb
lcb = Create using w_main cb_ 1

DESTROY

DESTROY DBTrans

Supported:

  1. The Destroy statement in non-visual system objects (DataStore, DynamicStagingArea, and Transaction Object) and non_visual user objects is supported.

    Example:

    Destroy lnv_string // lnv_string = create n_cst_string
  2. The Destroy statement in visual controls and visual user objects is supported.

    Example:

    commandbutton lcb_1
    lcb_1 = create using "cb_2"
    Destroy lcb_1

Note: As one of the best development practices, it is strongly recommended that you use DESTROY statement.

DO...LOOP

Four formats of Do...Loop:

Do...Until

DO UNTIL a > 15
  a = (a + 1) * b
LOOP

Do...While

Integer a = 1, b = 1
DO WHILE a <= 15
  a = (a + 1) * b
LOOP

Loop...Until

Integer a = 1, b = 1
DO
 a = (a + 1) * b
LOOP UNTIL a > 15

Loop...While

Integer a = 1, b = 1
DO
 a = (a + 1) * b
LOOP WHILE a <= 15

Nesting of Do...Loop statement.

Example:

Int li_array[100,50,200]
FOR i = 1 to 100
 FOR j = 1 to 50
  FOR k = 1 to 200
   ll_array[i,j,k]= i + j + k
  NEXT
 NEXT
NEXT

Nesting of Do...Loop statement and For...Next statement. Example:

FOR ll_i = 5 to 25
DO UNTIL ll_j > 15
 ll_j ++
LOOP
 ll_j = 1
NEXT

EXIT

DO WHILE a < 10
 a ++
 IF a > 3 THEN
 EXIT
  b += a
LOOP

FOR NEXT

Integer a=1
Integer start, end, increment
For n=start TO end STEP increment
a*=n Next

1) End the FOR loop with the keywords END FOR instead of NEXT.

Example:

FOR ll_i = 5 to 25
ll_j = ll_j+10
END FOR

2) Using a positive or negative variable for the step increment.

Example:

FOR N = 5 TO 25 STEP 5
A = A+10
NEXT

3) Nesting of the For...Next statements or For ... Next statement with Do ... Loop statement.

Example:

Int li_array[100,50,200]
FOR i = 1 to 100
 FOR j = 1 to 50
  FOR k = 1 to 200
   ll_array[i,j,k]= i + j + k
  NEXT
 NEXT
NEXT

HALT

IF sle_password.Text <> CorrectPassword
THEN HALT CLOSE

Notes:

  1. The code following the Halt statement will not be executed in Appeon Mobile. For example, in the following script, "close(parent)" will be ignored in the Appeon conversion process.

    Halt //supported
    Close(parent) //this will be ignored
    
  2. The reserved word HALT is supported.

  3. If HALT CLOSE statement is invoked in a nested call, the mobile application will not be closed immediately at the execution of the statement, instead it will be closed after the nest call is executed.

IF...THEN

IF num >= 1 THEN result = 1 ELSE result = 0
 IF num >= 1 THEN
  result = 1
 ELSEIF num <= -1 THEN
  result = -1
 ELSE
  result = 0
 END IF

RETURN

RETURN 0

Unsupported

The following statements are unsupported:

  • GOTO

  • THROW

  • THROWS

  • TRY...CATCH...FINALLY...END TRY