SetActionCode method (DataWindows)
Description
Sets the action code for an event in a DataWindow control.
The action code determines the action that PowerBuilder takes following
the event. The default action code is 0.
Where to use SetActionCode
SetActionCode is obsolete in PowerBuilder.
To return a value, include a RETURN statement
in the event script using the return codes documented for that event.
For the Web ActiveX, use SetActionCode for
event return values.
Controls
|
DataWindow type |
Method applies to |
|---|---|
|
PowerBuilder |
DataWindow control, DataWindowChild object |
|
Web ActiveX |
DataWindow control, DataWindowChild object |
Syntax
[PowerBuilder]
|
1 |
integer <span>dwcontrol</span>.<span>SetActionCode</span> ( long <span>code</span> ) |
[Web ActiveX]
|
1 |
number <span>dwcontrol</span>.<span>SetActionCode</span> ( number <span>code</span> ) |
|
Argument |
Description |
|---|---|
|
dwcontrol |
A reference to a DataWindow control or |
|
code |
A value specifying the action you want |
Return Values
Returns 1 if it succeeds and –1 if an error occurs.
If any argument’s value is null, SetActionCode returns
null.
Usage
Use SetActionCode to change the action
that occurs following a DataWindow event. Not all DataWindow events
have action codes, only those events that can have different outcomes.
SetActionCode last statement in script
Although SetActionCode is not required
to be the last statement in a script, it may not perform as expected
if other statements follow it.
Examples
In the ItemChanged event script for dw_Employee,
these statements set the action code in dw_Employee to
reject data that is less than the employee’s age:
|
1 |
integer a, age |
|
1 |
age = Integer(sle_Age.Text) |
|
1 |
a = Integer(dw_Employee.GetText()) |
|
1 |
IF a < age THEN dw_Employee.<span>SetActionCode</span>(1) |
This example shows a script for the DBError event
script that displays a version of the error message to the user.
Because PowerBuilder also displays a message to the user after the
event, the script calls SetActionCode to set
the action code to 1, which suppresses the PowerBuilder error message:
|
1 |
integer errnum |
|
1 |
errnum = dw_emp.DBErrorCode() |
|
1 |
|
1 |
// Show error code and message to the user |
|
1 |
MessageBox("Database Error", & |
|
1 |
"Number " + String(errnum) + " " + & |
|
1 |
dw_emp.DBErrorMessage(), StopSign!) |
|
1 |
|
1 |
// Stop PowerBuilder from displaying its message |
|
1 |
dw_emp.<span>SetActionCode</span>(1) |