PreviousNextIndex

SET statement

Requests input, and then puts the data in the screen buffer frame and in the specified fields or variables. The SET statement is a combination of these statements:

Data movement

Syntax

SET 
  [ STREAM stream | STREAM-HANDLE handle ] 
  [ UNLESS-HIDDEN ] 
  [  
    {  field [ view-as-phrase ] [ format-phrase ] } 
         [ WHEN expression ] 
      | TEXT ( field [ format-phrase ] ... )  
      | field = expression  
      | constant [ AT n | TO n ] 
      | ^ 
      | SPACE [ ( n ) ] 
      | SKIP [ ( n ) ] 
  ] ... 
  [ GO-ON (key-label ... ) ] 
  [ frame-phrase ] 
  [ editing-phrase ] 
  [ NO-ERROR ] 

SET [ STREAM stream | STREAM-HANDLE handle ] [ UNLESS-HIDDEN ] 
       record [ EXCEPT field ... ] [ frame-phrase ]  
    [ NO-ERROR ] 

STREAM stream
STREAM-HANDLE handle
UNLESS-HIDDEN
field
view-as-phrase
format-phrase
WHEN expression
TEXT
field = expression
constant AT n
constant TO n
^
SPACE [ ( n ) ]
SKIP [ ( n ) ]
GO-ON ( keylabel . . . )
frame-phrase
editing-phrase
record
NO-ERROR
EXCEPT field
Examples

The r-set.p procedure reads each Item record, displays the ItemNum and lets the user enter information for the ItemName, OnHand, Allocated, and Price fields. When you run this procedure, notice that it does not display existing values for the ItemName, OnHand, Allocated, and Price fields.

r-set.p
FOR EACH Item: 
  DISPLAY Item.ItemNum. 
  SET Item.ItemName Item.OnHand Item.Allocated Item.Price. 
END. 

On each iteration of the block, the FOR EACH statement reads a single record into the Item record buffer. The DISPLAY statement moves the ItemNum from the record buffer to the screen buffer where you can see it. The SET statement prompts for data, stores the data in screen buffers, and moves the data to the record buffer, overwriting whatever is already there. Therefore, even though the ItemName, OnHand, Allocated, and Price fields are put into the Item record buffer by the FOR EACH statement, you never see the values for those fields.

The r-set2.p procedure displays the CustNum, Name, and CreditLimit for a Customer and lets you change the CreditLimit field. The HELP option in the SET statement displays help information at the bottom of the screen when you are changing the CreditLimit. The VALIDATE option in the SET statement makes sure that the CreditLimit value is greater than 0. If it is not, VALIDATE displays the message “Invalid credit limit.”

r-set2.p
FOR EACH Customer: 
  DISPLAY Customer.CustNum Customer.Name Customer.CreditLimit. 
  SET Customer.Name Customer.CreditLimit 
    VALIDATE(Customer.CreditLimit > 0, "Invalid credit limit.") 
    HELP "Enter a positive credit-limit.". 
  REPEAT: 
    CREATE Order. 
    Order.CustNum = Customer.CustNum. 
    SET Order.OrderNum Order.ShipDate VALIDATE(Order.ShipDate > TODAY, 
      "Ship date too early."). 
  END. 
END. 

After you modify CreditLimit, the procedure creates an Order for the Customer and assigns the Customer.CustNum value to the CustNum field in the Order record. The SET statement lets you enter information for the OrderNum and ShipDate fields. The VALIDATE option in the SET statement makes sure that the Ship Date is greater than TODAY.

Notes
See also

DEFINE STREAM statement, EDITING phrase, Format phrase, Frame phrase, PROMPT-FOR statement, Stream object handle, UPDATE statement


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex