Optimizing expressions for DataWindow and external objects
No compiler validation for container objects
When you use dot notation to
refer to a DataWindow object in a DataWindow control or DataStore,
the compiler does not check the validity of the expression:
1 |
dw_data.Object.column.<i>property</i> |
Everything you specify after the Object property passes the
compiler and is checked during execution.
The same applies to external OLE objects. No checking occurs
until execution:
1 |
ole_1.Object.<i>qualifier</i>.<i>qualifier</i>.<i>property</i>.<i>Value</i> |
Establishing partial references
Because of the runtime syntax checking, using many expressions
like these can impact performance. To improve efficiency when you
refer repeatedly to the same DataWindow component object or external
object, you can define a variable of the appropriate type and assign
a partial reference to the variable. The script evaluates most of
the reference only once and reuses it.
The datatype of a DataWindow component object is DWObject:
1 |
DWObject dwo_column<br />dwo_column = dw_data.Object.column<br />dwo_column.SlideLeft = ...<br />dwo_column.SlideUp = ... |
The datatype of a partially resolved automation expression
is OLEObject:
1 |
OLEObject ole_wordbasic<br />ole_wordbasic = ole_1.Object.application.wordbasic<br />ole_wordbasic.propertyname1 = value<br />ole_wordbasic.propertyname2 = value |
Handling errors
The Error and (for automation) ExternalException events are
triggered when errors occur in evaluating the DataWindow and OLE
expressions. If you write a script for these events, you can catch
an error before it triggers the SystemError event. These events
allow you to ignore an error or substitute an appropriate value.
However, you must be careful to avoid setting up conditions that
cause another error. You can also use try-catch blocks to handle
exceptions as described in “Exception handling in PowerBuilder”.
For information
For information about DataWindow data expressions and property
expressions and DWObject variables, see the DataWindow
Reference
. For information about using OLEObject variables
in automation, see Chapter 19, “Using OLE in an Application .”