Moves data previously placed in the screen buffer by a data input statement or moves data specified within the ASSIGN statement by an expression to the corresponding fields and variables in the record buffer.
DATA MOVEMENT
SYNTAX
[
FRAME frame|
BROWSE browse]
fieldThe 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 or browse name (frame) if field is specified as an input widget in more than one frame.
expression
An expression that results in an assigned value to the named field. In this case, Progress determines the field value from the expression rather than from the screen buffer.
Interfaces OS SpeedScript
All All Yes
Record buffer Screen buffer
Database
ASSIGN
{
[ [
INPUT]
FRAME frame|
BROWSE browse]
{
field[
= expression] } [
WHEN expression]
} ... [
NO-ERROR]
ASSIGN
{
record[
EXCEPT field... ] } [
NO-ERROR]
WHEN expression
Moves data to the record buffer only when the expression used in the WHEN option has a value of TRUE. Here, expression is a field name, variable name, or expression whose value is logical.
NO-ERROR
Specifies that any errors that occur as a result of the assignment are suppressed. After the ASSIGN statement completes, you can check the ERROR-STATUS system handle for information on any errors that might have occurred. If an error occurs, the assignment is canceled and any changes to field values within the assignment are undone. If the assignment occurs within a transaction, any changes to variables, work table fields, and temporary table fields are also undone, unless you define the variable or field with the NO-UNDO option.
record
The record buffer name with the fields set, from the corresponding values in the screen buffer. Naming a record is a shorthand way to list each field in that record individually.
To use ASSIGN with a record in a file defined for multiple databases, you might have to qualify the record’s filename with the database name. See the Record Phrase reference entry for more information.
EXCEPT field
All fields in the record buffer are affected except for those listed. Separate field names with a space.
EXAMPLES
The following procedure prompts you for a customer number and retrieves the customer record if one exists, or creates a new one if it does not exist. If it creates a new record, the value for the cust-num field is ASSIGNed from the value you entered in response to the PROMPT–FOR statement.
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 Progress re-indexes records at the end of any statement that changes an index field value, and because order-num and line-num are used jointly in one index, this technique does not generate an index until both values change.
NOTES
• 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.
• During data entry, a validation expression defined for the field in the database or in a Format phrase executes only if the widget associated with the field receives input focus.
Use the VALIDATE( ) method to execute a validation expression defined for a field regardless of whether it receives input focus or not.
• Use an ASSIGN statement after a PROMPT–FOR statement or to write changes from an enabled field to the database. ASSIGN moves the value from the screen buffer into the field or variable.
• Use the PROMPT–FOR statement to receive one or more index fields from the user, and you use the FIND statement to find a record matching those index values. If no record is found, use the CREATE statement to create a new record and use the ASSIGN statement to assign the values the user supplied to the new record.
• You cannot use the SET statement in place of the PROMPT–FOR statement. The SET statement prompts the user for input and then assigns that input to the record in the buffer.
However, if there is not a record available, SET cannot assign the values.
• 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, Progress 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.
• If an ASSIGN statement references a field or variable that is used in more than one frame, it uses the value in the frame most recently introduced in the procedure.
• If you type blanks into a field that has never displayed data, the ENTERED function returns FALSE and the SET or ASSIGN statement does not update the underlying field or variable. Also, if Progress marks a field as entered, and the PROMPT–FOR statement prompts for the field again and you do not enter any data, Progress no longer considers the field entered.
• If you use a single, qualified identifier with the ASSIGN statement, the Compiler interprets the reference as dbname.filename. If the Compiler cannot resolve the reference as dbname.filename, it tries to resolve it as filename.fieldname.
• Many assignments within a single ASSIGN statement are more efficient than multiple ASSIGN statements. It saves r-code size and improves performance.
• The ASSIGN statement, when used in database fields, causes all related database ASSIGN triggers to execute in the order in which the fields were assigned. The ASSIGN triggers execute after all the assignments have taken place. If an ASSIGN trigger fails (or executes a RETURN statement with the ERROR option), all of the database changes are undone.
See the Progress Programming Handbook for more information on database triggers.
SEE ALSO
= Assignment Operator, INPUT Function, PROMPT-FOR Statement, SET Statement, UPDATE Statement
AT Phrase
The AT phrase of the Format phrase allows explicit positioning of frame objects, either by row and column or by pixels. The AT phrase of the Frame phrase allows explicit positioning of frames with windows or parent frames.
SYNTAX
n
The column, measured in character units. This option is not supported for the Frame phrase. You cannot use the alignment options with this syntax. If you use this option, Progress chooses the row based on the previous widget and form item layout of the frame.
For information on form items, see the DEFINE FRAME Statement or FORM Statement.
COLUMN column
The column, measured in character units.
Interfaces OS SpeedScript
All All Yes
AT
{
COLUMN column|
COLUMN-OF reference-point}
{
ROW row|
ROW-OF reference-point}
[
COLON-ALIGNED|
LEFT-ALIGNED|
RIGHT-ALIGNED]
AT
{
X x|
X-OF reference-point}
{
Y y|
Y-OF reference-point}
[
COLON-ALIGNED|
LEFT-ALIGNED|
RIGHT-ALIGNED]
AT n
COLUMN-OF reference-point
Indicates the column position of the field relative to another field-level widget previously defined in the frame. This option is not supported for the Frame phrase. This is the syntax for reference-point.
In this syntax, widget is a reference to a field-level widget previously defined in the frame, and offset is a positive decimal value. For example, if widget is positioned at COLUMN 10, then COLUMN-OF widget + 2.5 positions the field at column 12.5.
X x
The X pixel coordinate.
X-OF reference-point
Indicates the X co-ordinate of the field relative to another field-level widget previously defined in the frame. This option is not supported for the Frame phrase. The co-ordinate is expressed as the co-ordinate of a widget previously defined in the frame, plus or minus an offset. The offset must be either a constant or preprocessor constant and must be a positive integer.
ROW row
The row, measured in character units.
ROW-OF reference-point
Indicates the row of the field relative to another field-level widget previously defined in the frame. This option is not supported for the Frame phrase. The row is expressed as the row of a widget previously defined in the frame, plus or minus an offset. The offset must be either a constant or preprocessor constant and must be a positive decimal value.
Y y
The Y pixel coordinate.
SYNTAX
widget
[ {
+|
-}
offset]
Y-OF reference-point
Indicates the Y co-ordinate of the field relative to another field-level widget previously defined in the frame. This option is not supported for the Frame phrase. The co-ordinate is expressed as the co-ordinate of a widget previously defined in the frame, plus or minus an offset. The offset must be either a constant or preprocessor constant and must be a positive integer.
COLON-ALIGNED | LEFT-ALIGNED | RIGHT-ALIGNED
Specifies whether to align the left edge of the field, right edge of the field, or the colon of the field label, with the specified position. This option can only be used in combination with the ROW and COLUMN options. This option is not supported for the Frame phrase.
EXAMPLES
The following example uses the AT phrase to position fields within a frame.
r-at.p
DEFINE FRAME order-info
order.cust-num AT ROW 2 COLUMN 8 customer.name AT ROW 2 COLUMN 18 order.order-num AT ROW 2 COLUMN 50 order.order-date AT ROW 2 COLUMN 65 WITH TITLE "Order Information".
FOR EACH order NO-LOCK BREAK BY order.cust-num WITH FRAME order-info:
IF FIRST-OF(order.cust-num) THEN DO:
FIND customer OF order NO-LOCK.
DISPLAY order.cust-num customer.name.
END.
DISPLAY order.order-num order.order-date.
END.
The following example uses relative positioning to position fields relative to the cust-num field.
NOTES
• The AT phrase does not left justify the data. It simply specifies the position of the data area. If the data is right justified it may appear to be farther right than you expect.
• If you position a child frame completely outside the virtual area of its parent frame, Progress raises ERROR at run time when the frame is realized.
• SpeedScript — You can position objects by row or column, not by pixels.
SEE ALSO
DEFINE FRAME Statement, FORM Statement, Frame Phrase r-at1.p
DEFINE FRAME order-info
order.cust-num AT X 50 Y 14
customer.name AT X-OF order.cust-num + 100 Y 14 order.order-num AT X-OF order.cust-num + 225 Y 14 order.order-date AT X-OF order.cust-num + 320 Y 14 WITH TITLE "Order Information" NO-LABELS.
FOR EACH order NO-LOCK
BREAK BY order.cust-num WITH FRAME order-info:
IF FIRST-OF(order.cust-num) THEN DO:
FIND customer OF order NO-LOCK.
DISPLAY order.cust-num customer.name.
END.
DISPLAY order.order-num order.order-date.
END.