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:
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 ] |
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 the AVM handles array fields with expressions as subscripts.
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, the AVM wraps data that follows into the next TEXT field, if necessary. If you delete data from the middle of a TEXT field, the AVM wraps data that follows into the empty area. If you enter more characters than the format for the field allows, the AVM 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.
The following table lists the keys you can use within a TEXT field, and their actions.
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 NO-UNDO FORMAT "x(40)" EXTENT 5. FORM "Shipped :" Order.ShipDate 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 NO-LOCK, EACH Order OF Customer: DISPLAY Customer.CustNum Customer.Name Order.OrderNum Order.OrderDate Order.PromiseDate WITH FRAME order-hdr CENTERED. UPDATE Order.ShipDate Order.Instructions TEXT(s-com) WITH FRAME o-com. s-com = "". END. |
Tells the AVM to ignore an input field when input is being read from a file. Thus, the following statement reads a line from an input file and ignores that line:
This is an efficient way to skip over lines.
Supported only for backward compatibility.
Identifies processing to take place as each keystroke is entered. This is the syntax for the editing-phrase:
For more information on editing-phrase, see the EDITING phrase reference entry.
Suppresses ABL errors or error messages that would otherwise occur and diverts them to the ERROR-STATUS system handle. If an error occurs, the action of the statement is not done and execution continues with the next statement. If the statement fails, any persistent side-effects of the statement are backed out. If the statement includes an expression that contains other executable elements, like methods, the work performed by these elements may or may not be done, depending on the order the AVM resolves the expression elements and the occurrence of the error.
To check for errors after a statement that uses the NO-ERROR option:
If the statement does not include the NO-ERROR option, you can use a CATCH end block to handle errors raised by the statement.
Some other important usage notes on the NO-ERROR option:
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
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.
When using SET to set fields, you must use table names that are different from field names to avoid ambiguous references. See the Record phrase reference entry for more information.