Progress
Language Reference


ASSIGN Statement

Interfaces
OS
SpeedScript
All
All
Yes

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

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 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.

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.

r-asgn.p
REPEAT:
  PROMPT-FOR customer.cust-num.
  FIND customer USING cust-num NO-ERROR.
  IF NOT AVAILABLE customer 
  THEN DO:
    CREATE customer.
    ASSIGN cust-num.
  END. 
  UPDATE customer WITH 2 COLUMNS.
END. 

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.

r-asgn2.p
DEFINE VARIABLE neword LIKE order-line.order-num
    LABEL "New Order".
DEFINE VARIABLE newordli LIKE order-line.line-num
    LABEL "New Order Line".
REPEAT:
  PROMPT-FOR order-line.order-num line-num.
  FIND order-line USING order-line.order-num AND line-num.
  SET neword newordli.
  FIND order WHERE order.order-num = neword.
  ASSIGN order-line.order-num = neword
    order-line.line-num = newordli.
END. 

NOTES

SEE ALSO

= Assignment Operator, INPUT Function, PROMPT-FOR Statement, SET Statement, UPDATE Statement


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095