PreviousNextIndex

ASSIGN statement

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
expression
WHEN expression
NO-ERROR
record
EXCEPT field
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 CustNum field is ASSIGNed from the value you entered in response to the PROMPT-FOR statement.

r-asgn.p
REPEAT: 
  PROMPT-FOR Customer.CustNum. 
  FIND Customer USING Customer.CustNum NO-ERROR. 
  IF NOT AVAILABLE Customer THEN DO: 
    CREATE Customer. 
    ASSIGN Customer.CustNum. 
  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 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.

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 OrderLine.OrderNum OrderLine.LineNum. 
  FIND OrderLine USING OrderLine.OrderNum AND OrderLine.LineNum. 
  SET neword newordli. 
  FIND Order WHERE Order.OrderNum = neword. 
  ASSIGN  
    OrderLine.OrderNum = neword 
    OrderLine.LineNum  = newordli. 
END. 

Notes
See also

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


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex