ASSIGN {
[ [ INPUT ] FRAME frame | BROWSE browse ]
{ field [ = expression ] } [ WHEN expression ]
} ... [ NO-ERROR ]
|
ASSIGN { record [ EXCEPT field ... ] } [ NO-ERROR ]
|
[ FRAME
frame | BROWSE
browse ] field
The name of the field or variable (field) to be set from the corresponding value found in the screen buffer or expression. The
field must be qualified by a frame name (
frame) or browse name (
browse) if
field is specified as an input widget in more than one frame. If
field is set from
expression,
field can include all of the elements that are defined for the left side of an
Assignment (=) statement.
Moves data to the record buffer only when expression has a value of TRUE. Here,
expression is a field name, variable name, or expression whose value is logical. The AVM evaluates WHEN expressions at the beginning of the assignment, before any assignments take place.
Suppresses ABL errors or error messages that would otherwise occur and diverts them to the
ERROR-STATUS system handle. If an error occurs, the action of the statement is not done and execution continues with the next statement. If the statement fails, any persistent side-effects of the statement are backed out. If the statement includes an expression that contains other executable elements, like methods, the work performed by these elements may or may not be done, depending on the order the AVM resolves the expression elements and the occurrence of the error.
|
Check if the ERROR-STATUS:NUM-MESSAGES attribute is greater than zero to see if the AVM generated error messages. ABL handle methods used in a block without a CATCH end block treat errors as warnings and do not raise ERROR, do not set the ERROR-STATUS:ERROR attribute, but do add messages to the ERROR-STATUS system handle. Therefore, this test is the better test for code using handle methods without CATCH end blocks. ABL handle methods used in a block with a CATCH end block raise ERROR and add messages to the error object generated by the AVM. In this case, the AVM does not update the ERROR-STATUS system handle.
|
|
A CATCH statement, which introduces a CATCH end block, is analogous to a NO-ERROR option in that it also suppresses errors, but it does so for an entire block of code. It is different in that the error messages are contained in a class-based error object (generated by the AVM or explicitly thrown), as opposed to the ERROR-STATUS system handle. Also, if errors raised in the block are not handled by a compatible CATCH block, ON ERROR phrase, or UNDO statement, then the error is not suppressed, but handled with the default error processing for that block type.
|
|
When a statement contains the NO-ERROR option and resides in a block with a CATCH end block, the NO-ERROR option takes precedence over the CATCH block. That is, an error raised on the statement with the NO-ERROR option will not be handled by a compatible CATCH end block. The error is redirected to the ERROR-STATUS system handle as normal.
|
|
If an error object is thrown to a statement that includes the NO-ERROR option, then the information and messages in the error object will be used to set the ERROR-STATUS system handle. This interoperability feature is important for those integrating code that uses the traditional NO-ERROR technique with the newer, structured error handling that features error objects and CATCH end blocks.
|
The next procedure changes the order number and line number of an order-line record. (It copies an order-line from one order to another.) It sets the new values into variables and modifies the record with a single ASSIGN statement that contains two assignment phrases in the form
field = expression. Thus, both fields are changed within a single statement. Because the AVM re-indexes records at the end of any statement that changes an index field value, and because
OrderLine.OrderNum and
OrderLine.LineNum are used jointly in one index, this technique does not generate an index until both values change.
|
If field is an integer and expression is a decimal, the AVM rounds the value of the expression before assigning it. If field is a decimal and expression is a decimal, the AVM rounds the value of the expression to the number of decimal places defined for the field in the Data Dictionary, or defined or implied for a variable or temp-table field.
|
|
If field is an ABL array type (defined with EXTENT) and expression is not an array, and you do not identify a particular array element, the AVM stores expression in each element of the array. If you identify a particular element, the AVM stores expression in the specified array element.
|
|
If both field and expression are ABL array types, the AVM copies the data for all expression array elements into the corresponding elements of the field array. This is known as a deep copy.
|
|
An indeterminate array is one where the size of the EXTENT is not yet fixed. A determinate array is one where the EXTENT size is fixed. When deep copying one array to another, the following rules apply:
|
|
ABL allows you to assign ABL arrays and .NET array objects to each other. How an array assignment works between ABL and .NET arrays depends upon the array type of field (the target of the assignment) and the array type of expression (the source for the assignment). For more information, see the Data types reference entry.
|
|
If expression is an ABL handle-based object (for example, a temp-table, ProDataSet, widget, or socket), field must be a temp-table field, variable, or other ABL data element defined as a compatible handle. In this case, the AVM assigns only the handle of the ABL handle-based object to field, not the entire object and its contents.
|
|
If any field is a field in a database record, the ASSIGN statement upgrades the record lock condition to EXCLUSIVE-LOCK before updating the record.
|
|
If any field is part of a record retrieved with a field list, the ASSIGN statement rereads the complete record before updating it.
|
|
If field is a handle, the expression on the right-hand-side of the corresponding assignment must also evaluate to a handle value that is specified using an appropriate reference to a handle-based object handle. For more information on object handle references, see the “Handle Attributes and Methods Reference” section.
|
|
ASSIGN does not move data into a field or variable if there is no data in the corresponding screen field. There is data in a screen field if a DISPLAY of the field was done or if data was entered into the field. If you PROMPT-FOR a field or variable that has not been DISPLAYed in the frame and enter blanks, the AVM does not change the field or variable because it considers the screen field changed only if the data differs from what was in the field.
|
Table 9 lists the default character conversions that the AVM performs when assigning CLOB, LONGCHAR, and CHARACTER data. References to CLOBCP and CLOBDB represent CLOB data in either the CLOB’s defined code page or the database's defined code page, respectively. References to the "fixed code page" represent the code page of a target LONGCHAR variable set using the FIX-CODEPAGE statement.
|
When you assign the Unknown value ( ?) to a BLOB or CLOB field, the AVM deletes any associated object data.
|
|
You can assign DATE, DATETIME, and DATETIME-TZ data. When the data type expression on the left side of the assignment statement contains more information than the data type expression on the right side provides (for example, datetime-tz = date where a DATETIME-TZ value contains more information than a DATE value), the time value defaults to midnight and the time zone value defaults to the session's time zone. When the data type expression on the left side of the assignment statement contains less information than the data type expression on the right side provides (for example, date = datetime-tz where a DATE value contains less information than a DATETIME-TZ value), the AVM converts the DATETIME-TZ value to the local date and time of the session, then drops the time and time zone.
|
|
If expression is a solitary invocation of the NEW function, this function behaves according to the rules specified for the NEW function (classes) when not operating in the context of a NEW statement.
|
|
If expression evaluates to an object reference value, field must also be a data element defined as a class or interface type that is type-compatible with expression according to the rules for assigning references to class instances defined for the NEW statement. For more information, see the NEW statement reference entry. Thus, you can assign one object reference variable to another object reference variable when the destination object reference (on the left side of the assignment) is defined for the same class, a super class, or an interface of the object reference being assigned (on the right side of the assignment). The destination object reference retains its defined class or interface type for compilation. However, following its assignment, at run time, the destination represents the subclass of field (or the class that implements the interface specified by field) that is defined by expression.
|
If field has a class type that is a subclass lower in the class hierarchy than the class type represented by
expression, you can cast
expression to the type of
field using the CAST function, but only if
expression is a super class that actually contains an instance of the
field class type. If
field has a class type that implements an interface type represented by
expression, you can similarly cast
expression using the CAST function, but only if
expression actually contains an instance of the
field class type. For more information about the CAST function, see the
CAST function reference entry.
After the assignment, field contains a copy of the object reference value returned by
expression, which points to the same object instance, not a copy of the object referenced by
expression.
Assignment (=) statement,
CAST function,
Class-based object reference,
COPY-DATASET( ) method,
COPY-LOB statement,
COPY-TEMP-TABLE( ) method,
Data types,
Expression,
FIX-CODEPAGE statement,
INPUT function,
PROMPT-FOR statement,
SET statement,
UPDATE statement