Progress
Language Reference


SET Statement

Interfaces
OS
SpeedScript
All
All
No

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 ]
[ 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] [UNLESS-HIDDEN]
       record [EXCEPT field...] [frame-phrase] 
    [NO-ERROR] 

STREAM stream

Specifies the name of a stream. If you do not name a stream, Progress uses the unnamed stream. See the DEFINE STREAM Statement reference entry in this book and the chapter on alternate I/O sources in the Progress Programming Handbook for more information on streams.

UNLESS-HIDDEN

Restricts SET to fields whose HIDDEN attribute is FALSE.

field

Represents the name of the field or variable whose value you want to store in the screen buffer and in the field or variable.

In the case of array fields, array elements with constant subscripts are treated as any other field. Array fields with no subscripts are expanded as though you typed in the implicit elements. See the DISPLAY Statement reference entry for information on how Progress handles array fields with expressions as subscripts.

view-as-phrase

Specifies the widget used to represent the field. For more information on view-as-phrase, see the VIEW-AS Phrase reference entry.

format-phrase

Specifies one or more frame attributes for a field, variable, or expression. For more information on format-phrase, see the Format Phrase reference entry.

WHEN expression

Sets the field only when expression has a value of TRUE. An expression is a field name, variable name, or expression whose value is logical.

TEXT

Defines a group of character fields or variables (including array elements) to use automatic word wrap. The TEXT option works with character fields only. When you insert data in the middle of a TEXT field, Progress wraps data that follows into the next TEXT field, if necessary. If you delete data from the middle of a TEXT field, Progress wraps data that follows into the empty area. If you enter more characters than the format for the field allows, Progress discards the extra characters. The character fields must be in the x(n) format.

A blank in the first column of a line marks the beginning of a paragraph. Lines within a paragraph are treated as a group and will not wrap into other paragraphs.

Table 39 lists the keys you can use within a TEXT field, and their actions.

Table 39: Key Actions in a TEXT Field
Key
Action
APPEND-LINE
Combines the line the cursor is in with the next line.
BACK-TAB
Moves the cursor to the previous TEXT field.
BREAK-LINE
Breaks the current line into two lines beginning with the character the cursor is on.
BACKSPACE
Moves the cursor one position to the left and deletes the character at that position. If the cursor is at the beginning of a line, BACKSPACE moves the cursor to the end of the previous line.
CLEAR
Clears the current field and all fields in the TEXT group that follow.
DELETE-LINE
Deletes the line the cursor is in.
NEW-LINE
Inserts a blank line below the line the cursor is in.
RECALL
Clears fields in the TEXT group and returns initial data values for the group.
RETURN
In overstrike mode, moves to the next field in the TEXT group on the screen. In insert mode, the line breaks at the cursor and the cursor is positioned at the beginning of the new line.
TAB
Moves to the field after the TEXT group on the screen. If there is no other field, the cursor moves to the beginning of the TEXT group.

In this procedure, the s-com, or Order Comments field is a TEXT field. Run the procedure and enter text in the field to see how the TEXT option works.

r-text.p
DEFINE VARIABLE s-com AS CHARACTER FORMAT "x(40)" EXTENT 5.

FORM "Shipped   :" order.ship-date AT 13 SKIP
     "Misc Info :" order.instructions AT 13 SKIP(1)
     "Order Comments :" s-com AT 1
WITH FRAME o-com CENTERED NO-LABELS TITLE "Shipping Information".

FOR EACH customer, EACH order OF customer:
    DISPLAY cust.cust-num cust.name order.order-num order.order-date
           order.promise-date WITH FRAME order-hdr CENTERED.
    UPDATE ship-date instructions TEXT(s-com) WITH FRAME o-com.
    s-com = "".
END. 

field = expression

Indicates that the value of field is determined by evaluating the expression rather than having it entered on the screen or from a file. An assignment statement is embedded within the SET statement.

constant AT n

A constant value that you want to display in the frame. The n is the column in which you want to start the display.

constant TO n

A constant value that you want to display in the frame. The n is the column in which you want to end the display.

^

Tells Progress to ignore an input field when input is being read from a file. Also, the following statement reads a line from an input file and ignores that line.

SET ^ 

This is an efficient way to skip over lines.

SPACE [ ( n ) ]

Identifies the number (n) of blank spaces to insert after the expression on the display. The n can be 0. If the number of spaces you specify is more than the spaces left on the current line of the frame, Progress starts a new line and discards any extra spaces. If you do not use this option or do not use n, Progress inserts one space between items in the frame.

SKIP [ ( n ) ]

Identifies the number (n) of blank lines to be inserted after the expression is displayed. The n can be 0. If you do not use this option, a line is not skipped between expressions only if they do not fit on one line. If you use the SKIP option, but do not specify n, or if n is 0, a new line is started unless it is already at the beginning of a new line.

GO-ON ( keylabel . . . )

Tells Progress to take the GO action when the user presses any of the keys listed. The keys you list are used in addition to keys that perform the GO action by default or because of ON statements. When you list a key label in the GO-ON option, you use the keyboard label of that key. For example, if you want Progress to take the GO action when the user presses F1, you use the statement GO-ON(F1). If you list more than one key, separate them with spaces, not commas, as in GO-ON( F1 RETURN ).

frame-phrase

Specifies the overall layout and processing properties of a frame. For more information on frame-phrase, see the Frame Phrase reference entry.

editing-phrase

Identifies processing to take place as each keystroke is entered. This is the syntax for the editing-phrase.

SYNTAX
[ label: ] EDITING: statement ... END. 

For more information on editing-phrase, see the EDITING Phrase reference entry.

record

Represents the name of a record buffer. All of the fields in the record, except those with the data type RECID and ROWID, are processed exactly as if you set each individually. The record you name must contain at least one field.

To use SET with a record in a table defined for multiple databases, you must qualify the record’s table name with the database name. See the Record Phrase reference entry for more information.

NO-ERROR

Specifies that any errors that occur in the attempt to set the value are suppressed. After the SET statement completes, you can check the ERROR-STATUS system handle for information on any errors that occurred.

EXCEPT field

Affects all fields except those fields listed in the EXCEPT phrase.

EXAMPLES

The r-set.p procedure reads each item record, displays the item-num and lets the user enter information for the item-name, on-hand, allocated, and price fields. When you run this procedure, notice that it does not display existing values for the item-name, on-hand, allocated, and price fields.

r-set.p
FOR EACH item:
  DISPLAY item-num.
  SET item-name on-hand allocated 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 item-num 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 item-name, on-hand, 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 cust-num, name, and credit-limit for a customer and lets you change the credit-limit field. The HELP option in the SET statement displays help information at the bottom of the screen when you are changing the credit-limit. The VALIDATE option in the SET statement makes sure that the credit-limit value is greater than 0. If it isn’t, VALIDATE displays the message “Invalid credit limit.”

r-set2.p
FOR EACH customer:
  DISPLAY cust-num name credit-limit.
  SET name credit-limit
    VALIDATE(credit-limit > 0, "Invalid credit limit.")
    HELP "Enter a positive credit-limit.".
  REPEAT:
    CREATE order.
    cust-num = customer.cust-num.
    SET order-num
      ship-date VALIDATE(ship-date > today,
      "Ship date too early.").
  END.
END. 

After you modify credit-limit, the procedure creates an order for the customer and assigns the customer.cust-num value to the cust-num field in the order record. The SET statement lets you enter information for the order-num and ship-date 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, UPDATE Statement


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