Previous | Contents | Index |
Example 3
MAP (OWNERKEYS) STRING owner_id = 6, dog_reg_no = 7, & last_name = 25, first_name = 20 OPEN "OWNERS.IND" FOR OUTPUT AS FILE #1, & ORGANIZATION INDEXED, & PRIMARY KEY (owner_id), & ALTERNATE KEY (last_name) DUPLICATES CHANGES, & ALTERNATE (dog_reg_no) DESCENDING, & MAP OWNERKEYS |
The MAP statement describes the three string variables used as index keys in the file OWNERS.IND. The OPEN statement declares an indexed file with two alternate keys in addition to the primary key. The alternate key dog_reg_no is a DESCENDING key; the other keys are ASCENDING by default.
The OPTION statement allows you to set compilation qualifiers such as default data type, size, and scale factor. You can also set compilation conditions such as severity of run-time errors to handle, constant type checking, subscript checking, overflow checking, decimal rounding, and setup in a source program. The options you set affect only the program module in which the OPTION statement occurs.
None
FUNCTION REAL DOUBLE monthly_payment, & (DOUBLE interest_rate, & LONG no_of_payments, & DOUBLE principle) OPTION TYPE = REAL, & SIZE = (REAL DOUBLE, INTEGER LONG), & SCALE = 4 |
The PLACE$ function explicitly changes the precision of a numeric string. PLACE$ returns a numeric string, truncated or rounded, according to the value of an integer argument you supply.
Int-exp | Effect | Value Returned |
---|---|---|
-5 | Rounded to 100,000s and truncated | 1 |
-4 | Rounded to 10,000s and truncated | 12 |
-3 | Rounded to 1000s and truncated | 123 |
-2 | Rounded to 100s and truncated | 1235 |
-1 | Rounded to 10s and truncated | 12346 |
0 | Rounded to units and truncated | 123457 |
1 | Rounded to tenths and truncated | 123456.7 |
2 | Rounded to hundredths and truncated | 123456.65 |
3 | Rounded to thousandths and truncated | 123456.654 |
4 | Rounded to ten-thousandths and truncated | 123456.6543 |
5 | Rounded to hundred-thousandths and truncated | 123456.65432 |
9,995 | Truncated to 100,000s | 1 |
9,996 | Truncated to 10,000s | 12 |
9,997 | Truncated to 1000s | 123 |
9,998 | Truncated to 100s | 1234 |
9,999 | Truncated to 10s | 12345 |
10,000 | Truncated to units | 123456 |
10,001 | Truncated to tenths | 12345.6 |
10,002 | Truncated to hundredths | 123456.65 |
10,003 | Truncated to thousandths | 123456.654 |
10,004 | Truncated to ten-thousandths | 123456.6543 |
10,005 | Truncated to hundred-thousandths | 123456.65432 |
DECLARE STRING str_exp, str_var str_exp = "9999.9999" str_var = PLACE$(str_exp,3) PRINT str_var |
Output
10000 |
The POS function searches for a substring within a string and returns the substring's starting character position.
DECLARE STRING main_str, & sub_str DECLARE INTEGER first_char main_str = "ABCDEFG" sub_str = "DEF" first_char = POS(main_str, sub_str, 1) PRINT first_char |
Output
4 |
The PRINT statement transfers program data to a terminal or a terminal-format file.
PRINT "Name",,"Address and ";"City" |
Name Address and City |
PRINT "name "; "age", "height "; "weight" |
Output
name age height weight |
Previous | Next | Contents | Index |