Previous | Contents | Index |
The UPDATE statement replaces a record in a file with a record in the record buffer. The UPDATE statement is valid on sequential, relative, and indexed files.
UPDATE #4%, COUNT 32 |
The VAL function converts a numeric string to a floating-point value.
It is recommended that you use the DECIMAL, REAL, and INTEGER functions to convert numeric strings to numeric data types. |
Str-exp can contain the ASCII digits 0 to 9, uppercase E, a plus sign (+), a minus sign (-), and a period (.).
DECLARE REAL real_num real_num = VAL("990.32") PRINT real_num |
Output
990.32 |
The VAL% function converts a numeric string to an integer.
It is recommended that you use the DECIMAL, REAL, and INTEGER functions to convert numeric strings to numeric data types. |
Str-exp can contain the ASCII digits 0 to 9, a plus sign (+), or a minus sign (-).
DECLARE INTEGER ret_int ret_int = VAL%("789") PRINT ret_int |
Output
789 |
VMSSTATUS returns the underlying OpenVMS condition code when control is transferred to a BASIC error handler.
None
PROGRAM WHEN ERROR USE global_handler . . . END WHEN . . . HANDLER global_handler final_status% = VMSSTATUS END HANDLER END PROGRAM final_status% |
The WAIT statement specifies the number of seconds the program waits for terminal input before signaling an error.
Int-exp must be from 0 to 255; if it is greater than 255, BASIC assumes a value of 255.
10 DECLARE STRING your_name WAIT 60 INPUT "You have sixty seconds to type your name";your_name WAIT 0 |
Output
You have sixty seconds to type your name? %BAS-F-KEYWAIEXH, Keyboard wait exhausted -BAS-I-ON_CHAFIL, on channel 0 for file SYS$INPUT:.; at user PC 00000644 -RMS-W-TMO, timeout period expired -BAS-I-FROLINMOD, from line 10 in module WAIT %TRACE-F-TRACEBACK, symbolic stack dump follows module name routine name line rel PC abs PC 00007334 00007334 ----- above condition handler called with exception 001A807C: %BAS-F-KEYWAIEXH, keyboard wait exhausted -BAS-I-ON_CHAFIL, on channel 0 for file SYS$INPUT:.; at user PC 00000644 -RMS-W-TMO, timeout period expired ----- end of exception message 00011618 00011618 0000F02F 0000F02F 0000E3F6 0000E3F6 0001387A 0001387A WAIT$MAIN WAIT$MAIN 3 00000044 00000644 |
The WHEN ERROR statement marks the beginning of a WHEN ERROR construct. The WHEN ERROR construct contains a protected region and can include an attached handler or identify a detached handler.
!With an attached handler PROGRAM salary DECLARE REAL hourly_rate, no_of_hours, weekly_pay WHEN ERROR IN INPUT "Enter your hourly rate";hourly_rate INPUT "Enter the number of hours you worked this week";no_of_hours weekly_pay = no_of_hours * hourly_rate PRINT "Your pay for this week is";weekly_pay USE SELECT ERR CASE = 50 PRINT "Invalid data" RETRY CASE ELSE EXIT HANDLER END SELECT END WHEN END PROGRAM |
Output
Enter your hourly rate? 35.00 Enter the number of hours you worked this week? 45 Your pay for this week is 1575 |
!With a detached handler PROGRAM salary DECLARE REAL hourly_rate, no_of_hours, weekly_pay WHEN ERROR USE patch_work INPUT "Enter your hourly rate";hourly_rate INPUT "Enter the number of hours you worked this week";no_of_hours weekly_pay = no_of_hours * hourly_rate PRINT "Your pay for this week is";weekly_pay END WHEN HANDLER patch_work SELECT ERR CASE = 50 PRINT "Invalid data" RETRY CASE ELSE EXIT HANDLER END SELECT END HANDLER END PROGRAM |
Output
Enter your hourly rate? Nineteen dollars and fifty cents Invalid data Enter your hourly rate? 19.50 Enter the number of hours you worked this week? 40 Your pay for this week is 780 |
The WHILE statement marks the beginning of a WHILE loop or modifies the execution of another statement.
A NEXT statement must end the WHILE loop.
!Conditional WHILE X < 100 X = X + SQR(X) NEXT |
!Statement Modifier X% = X% + 1% WHILE X% < 100% |
The XLATE$ function translates one string to another by referencing a table string you supply.
DECLARE STRING A, table, source A = "abcdefghijklmnopqrstuvwxyz" table = STRING$(65, 0) + A LINPUT " Type a string of uppercase letters"; source PRINT XLATE$(source, table) |
Output
Type a string of uppercase letters? ABCDEFG abcdefg |
ASCII is a 7-bit character code with an optional parity bit (8) added for many devices. Programs normally use seven bits internally with the eighth bit being zero; the extra bit is either stripped (on input) or added by a device driver (on output) so the program will operate with either parity- or nonparity-generating devices. The eighth bit is reserved for future standardization.
The International Reference Version (IRV) of ISO Standard 646 is identical to the IRV in CCITT Recommendation V.3 (International alphabet No. 5). The character sets are the same as ASCII except that the ASCII dollar sign (hexadecimal 24) is the international currency sign (###).
ISO Standard 646 and CCITT V.3 also specify the structure for national character sets, of which ASCII is the U.S. national set. Certain specific characters are reserved for national use. Table A-1 contains the values and symbols.
Hexadecimal Value | IRV | ASCII |
---|---|---|
23 | # | # |
24 | ### | $ (General currency symbol vs. dollar sign) |
40 | @ | @ |
5B | [ | [ |
5C | \ | \ |
5D | ] | ] |
5E | ^ | ^ |
60 | ` | ` |
7B | { | { |
7C | | | | |
7D | } | } |
7E | ~ | Tilde |
ISO Standard 646 and CCITT Recommendation V.3 (International Alphabet No. 5) are identical to ASCII except that the number sign (23) is represented as ## instead of #, and certain characters are reserved for national use. Table A-2 list the ASCII codes.
Decimal Code |
8-Bit Hexadecimal Code |
Character | Remarks |
---|---|---|---|
0 | 00 | NUL | Null (tape feed) |
1 | 01 | SOH | Start of heading (^A) |
2 | 02 | STX | Start of text (end of address, ^B) |
3 | 03 | ETX | End of text (^C) |
4 | 04 | EOT | End of transmission (shuts off the TWX machine ^D) |
5 | 05 | ENQ | Enquiry (WRU, ^E) |
6 | 06 | ACK | Acknowledge (RU, ^F) |
7 | 07 | BEL | Bell (^G) |
8 | 08 | BS | Backspace (^H) |
9 | 09 | HT | Horizontal tabulation (^I) |
10 | 0A | LF | Line feed (^J) |
11 | 0B | VT | Vertical tabulation (^K) |
12 | 0C | FF | Form feed (page, ^L) |
13 | 0D | CR | Carriage return (^M) |
14 | 0E | SO | Shift out (^N) |
15 | 0F | SI | Shift in (^O) |
16 | 10 | DLE | Data link escape (^P) |
17 | 11 | DC1 | Device control 1 (^Q) |
18 | 12 | DC2 | Device control 2 (^R) |
19 | 13 | DC3 | Device control 3 (^S) |
20 | 14 | DC4 | Device control 4 (^T) |
21 | 15 | NAK | Negative acknowledge (ERR, ^U) |
22 | 16 | SYN | Synchronous idle (^V) |
23 | 17 | ETB | End-of-transmission block (^W) |
24 | 18 | CAN | Cancel (^X) |
25 | 19 | EM | End of medium (^Y) |
26 | 1A | SUB | Substitute (^Z) |
27 | 1B | ESC | Escape (prefix of escape sequence) |
28 | 1C | FS | File separator |
29 | 1D | GS | Group separator |
30 | 1E | RS | Record separator |
31 | 1F | US | Unit separator |
32 | 20 | SP | Space |
33 | 21 | ! | Exclamation point |
34 | 22 | " | Double quotation mark |
35 | 23 | # | Number sign |
36 | 24 | $ | Dollar sign |
37 | 25 | % | Percent sign |
38 | 26 | & | Ampersand |
39 | 27 | ' | Apostrophe |
40 | 28 | ( | Left (open) parenthesis |
41 | 29 | ) | Right (close) parenthesis |
42 | 2A | * | Asterisk |
43 | 2B | + | Plus sign |
44 | 2C | , | Comma |
45 | 2D | -- | Minus sign, hyphen |
46 | 2E | . | Period (decimal point) |
47 | 2F | / | Slash (slant) |
48 | 30 | 0 | Zero |
49 | 31 | 1 | One |
50 | 32 | 2 | Two |
51 | 33 | 3 | Three |
52 | 34 | 4 | Four |
53 | 35 | 5 | Five |
54 | 36 | 6 | Six |
55 | 37 | 7 | Seven |
56 | 38 | 8 | Eight |
57 | 39 | 9 | Nine |
58 | 3A | : | Colon |
59 | 3B | ; | Semicolon |
60 | 3C | < | Less than (left angle bracket) |
61 | 3D | = | Equal sign |
62 | 3E | > | Greater than (right angle bracket) |
63 | 3F | ? | Question mark |
64 | 40 | @ | Commercial at |
65 | 41 | A | Uppercase A |
66 | 42 | B | Uppercase B |
67 | 43 | C | Uppercase C |
68 | 44 | D | Uppercase D |
69 | 45 | E | Uppercase E |
70 | 46 | F | Uppercase F |
71 | 47 | G | Uppercase G |
72 | 48 | H | Uppercase H |
73 | 49 | I | Uppercase I |
74 | 4A | J | Uppercase J |
75 | 4B | K | Uppercase K |
76 | 4C | L | Uppercase L |
77 | 4D | M | Uppercase M |
78 | 4E | N | Uppercase N |
79 | 4F | O | Uppercase O |
80 | 50 | P | Uppercase P |
81 | 51 | Q | Uppercase Q |
82 | 52 | R | Uppercase R |
83 | 53 | S | Uppercase S |
84 | 54 | T | Uppercase T |
85 | 55 | U | Uppercase U |
86 | 56 | V | Uppercase V |
87 | 57 | W | Uppercase W |
88 | 58 | X | Uppercase X |
89 | 59 | Y | Uppercase Y |
90 | 5A | Z | Uppercase Z |
91 | 5B | [ | Left square bracket |
92 | 5C | \ | Backslash (reverse slant) |
93 | 5D | ] | Right square bracket |
94 | 5E | ^ | Circumflex (caret) |
95 | 5F | _ | Underscore (underline) |
96 | 60 | ` | Grave accent |
97 | 61 | a | Lowercase a |
98 | 62 | b | Lowercase b |
99 | 63 | c | Lowercase c |
100 | 64 | d | Lowercase d |
101 | 65 | e | Lowercase e |
102 | 66 | f | Lowercase f |
103 | 67 | g | Lowercase g |
104 | 68 | h | Lowercase h |
105 | 69 | i | Lowercase i |
106 | 6A | j | Lowercase j |
107 | 6B | k | Lowercase k |
108 | 6C | l | Lowercase l |
109 | 6D | m | Lowercase m |
110 | 6E | n | Lowercase n |
111 | 6F | o | Lowercase o |
112 | 70 | p | Lowercase p |
113 | 71 | q | Lowercase q |
114 | 72 | r | Lowercase r |
115 | 73 | s | Lowercase s |
116 | 74 | t | Lowercase t |
117 | 75 | u | Lowercase u |
118 | 76 | v | Lowercase v |
119 | 77 | w | Lowercase w |
120 | 78 | x | Lowercase x |
121 | 79 | y | Lowercase y |
122 | 7A | z | Lowercase z |
123 | 7B | { | Left brace |
124 | 7C | | | Vertical line |
125 | 7D | } | Right brace |
126 | 7E | ~ | Tilde |
127 | 7F | DEL | Delete (rubout) |
Previous | Next | Contents | Index |