|
|
HP Data Entry and Forms Management System (VPLUS) Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 4 Advanced Forms DesignSET |
|
Used to move data either by setting the current field to a value or by moving data between fields. Also performs automatic formatting.
When data is moved between constants, fields, and save fields, certain restrictions apply and certain conversions may take place. These depend entirely upon the data types of the source and destination. In general, any field, save field, or constant can be converted to a character type field, but numeric and date fields accept only data of a similar type. DIG fields accept only positive sources. If a source is $EMPTY, the destination is set to all blanks. Table 4-9 “Conversion During Data Movement” shows the conversion that is performed when data is moved between fields. To set the current field to the value of another field, a save field, a constant, an arithmetic expression, or a value in a list located through an index, use the following SET statement:
In general, any source value can be moved to a character type field. Numeric and date fields accept only data of similar type. If the field type is DIG, the source must be a positive value (see Table 4-7 “Automatic Formatting for Numeric Data”). By default, all fields are initialized to blanks in the initialization phase (refer to "Phases" at end of this section for more information on phases.) You can specify a particular initial value for any field by including an initial value in the Field Menu field attributes. More elaborate initialization can be done with this subset of the SET statement. When you assign an initial value to a field in the Field Menu, you can specify only a constant. The constant is entered exactly like user input at a terminal. (Remember that input in FORMSPEC is NATIVE-3000; if a native language is specified, data is converted at run-time. Refer to Section 8.) When you assign a value through the SET statement, you have more flexibility. The values assigned are dynamic in that they may depend on values in other fields or in save fields, or they may be derived from an arithmetic expression, or through an indexed retrieval. If you do assign a constant through the SET statement, it must follow the rules for constants described earlier in this section. That is, a character string must be surrounded by quotes, a date string by exclamation points. Also, a date constant must be in the order MDY regardless of its destination format. If a source field is of date type (MDY, YMD, DMY), the current field must be defined to be 8 bytes long to allow for internal delimiters. Some examples using the SET TO source statement follow.
To move data to a field or a save field from another field or save field, or to move a constant, an arithmetic expression, or a value retrieved from a list to a particular field, use the following versions of the SET statement:
When a source is not included, whatever value is in the current field is moved to the specified destination. (The current field is the field in which the SET statement appears.)
In general, automatic formatting performed during data movement is governed by the data type of the destination. The following discussion illustrates data movement for various data types. Refer to Table 4-9 “Conversion During Data Movement” for a summary of the conversion performed during data movement. If the destination is a character field, data moved to it does not change its relative position. If the source is too large for the destination, the data is truncated on the right when it is moved. If the source has fewer characters, the destination is padded with blanks on the right. Table 4-6 Automatic Formatting for Character Data
When data is moved between numeric fields, the following formatting is performed:
The result is then placed, right justified, as shown in Table 4-8 “Automatic Formatting for Dates”, in the destination field. With Native Language Support, decimal and thousands indicators are language-dependent in the NUM[n] and IMP[n] fields. When data is moved between fields and automatic formatting occurs for data entered in any field, recognition, removal or insertion of these decimal and thousands indicators also depends upon the local custom for the native language specified for the forms file. The optional decimal symbols in constants will be local custom-dependent. For more information on Native Language Support, see Section 8. Table 4-7 Automatic Formatting for Numeric Data
Any date, regardless of the format of the source, is moved to the destination as dd/dd/dd, as shown in Table 4-8 “Automatic Formatting for Dates” Thus, if a date is going to be placed into a field using a SET command, the field must be at least eight characters long. The order depends on whether the destination is specified as MDY, DMY, or YMD. With Native Language Support, conversion from alphabetic months to the numeric destination month is language dependent. For more information on Native Language Support, see Section 8. Table 4-8 Automatic Formatting for Dates
Table 4-9 Conversion During Data Movement
Besides the explicit formatting described below, data is formatted whenever it is moved between fields according to the rules for automatic formatting. If you want data entered by the user to be formatted automatically, you can specify the following version of the SET statement.
For example, you may want to ensure that a monetary value is always right justified with a decimal point inserted preceding two decimal positions. To do this, define the field as type NUM2 and then use the SET statement to force data entered in this field to be formatted. The Field Menu in Figure 4-3 “Field Menu with a SET Statement” illustrates this use of SET.
|
|