PowerScript Topics

Calling functions and events

Overriding system function

Description

Overriding system functions is unsupported.

Workaround

Create a user-defined function and rewrite the user code in the system function into the user-defined function.

Example

In the original application, the SetTransObject function of the u_dw object contains the following user code:

trans_current = atrans_current return super::settransobject(itrans_current)

In the converted Web application, remove the preceding user code from the SetTransObject function, then create a user-defined function uf_settransobject and rewrite the following code:

itrans_current = atrans_current settransobject(itrans_current)

When the SetTransObject function of the u_dw object is called in the Web application, the user code is executed in the newly created uf_settransobject function.

Passing arguments to functions and events
Duplicate arguments for a function

Description

Repetitively referring objects as arguments for a function is unsupported. Use the following workaround and example to change it into a supported format.

Workaround

Assign the repetitively referenced object to multiple different variables and pass these variables to a function.

Example

The original script:

w_1.wf_1(dw_1,dw_1)

Re-write it using the following format:

u_dw ldw_1, ldw_2 
ldw_1 = dw_1 
ldw_2 = dw_1 
w_1.wf_1(ldw_1,ldw_2)
Passing Menu object as a reference parameter

Description

Passing Menu object as a reference parameter is unsupported.

Workaround

Pass the Menu object by value or as read-only instead of by reference. The reason is, when passing by value or as read-only, if you change the properties of the object by value or as read-only, you are changing the original object, which is the same as passing by reference.

Reference parameter

Description

The return values of functions and properties of objects cannot be directly used as reference parameters for functions.

Workaround

Follow the steps below to work around this issue:

Step 1: Create a variable and assign the return value of a function or the property of an object to the variable.

Step 2: Call the variable where the return value or the property is called in the original code.

Step 3: Assign the return value of calling the variable to the original property or object.

Code example

The original code

poptags(theobject.item[theitem])

Modified to

menu lm_menu 
lm_menu = theobject.item[theitem] 
poptags(lm_menu)

Declarations

Shared variables

Description

Shared variables are unsupported. For example, In the pfcmain.pbl of a PFC application, the pfc_u_dw uses a shared variable snv_property with its type being n_cst_dwsrv_property. The snv_property is unsupported.

Workaround

Follow the steps below to work around this issue.

Step 1: Change the variable snv_property as an instance variable of n_cst_appmanager (usually declared as gnv).

Step 2: Open the pfc_u_dw, and replace all the "snv_property" with the "gnv_app.snv_property".

Note

Since the parent code is changed, when deploying a new PFC, the same modification needs to be done again.

Other shared variables can also be worked around in this way.

Language basics

Null values

Description

The Null value calculation in Appeon is quite different from that in PowerBuilder. This is caused by the different calculation methods used in PowerScript and JavaScript.

Workaround

When using expressions with Null value calculations, you should add conditional statements to ensure that you get the correct result.

Example #1

A and/or B is/are likely to carry a Null value in the following assignment:

C = A + B

Re-write it using the following format:

IF IsNull(A) or IsNull(B) THEN 
 SetNull(C) 
ELSE 
 C = A + B 
END IF

Example #2

Another example for relational operations:

IF A = B then 
 MessageBox ("Return Value","True") 
ELSE 
 MessageBox ("Return Value","False") 
END IF

Re-write it using the following format:

IF IsNull(A) or IsNull(B) then 
 MessageBox ("Return Value", "False") 
ELSEIF A = B then 
 MessageBox ("Return Value", "True") 
ELSE 
 MessageBox ("Return Value", "False")
END IF

Note

The following table shows the different return values that PowerBuilder and Appeon will produce when an expression contains at least one null value. In these examples, the values of variables A and B are both null:

Expressions

Return Value in PowerBuilder

Return Value in Appeon

A+1

Null

1

A+B

Null

Null

A*B

Null

0

A=1 (relational)

Null

False

A<>1

Null

True

NOT (A=1)

Null

True

A=A (relational)

Null

True

A=B

Null

True

IsNull(A=1)

True

False