Article 137575 of comp.os.vms: Path: nntpd.lkg.dec.com!crl.dec.com!crl.dec.com!caen!usenet.cis.ufl.edu!usenet.eel.ufl.edu!newsfeed.internetmci.com!in2.uu.net!ulowell.uml.edu!willow!welchb From: welchb@willow (Brendan Welch, W1LPG) Newsgroups: comp.os.vms Subject: Re: Stupid DCL question Date: 11 Jan 96 14:00:22 -0500 Organization: University of Massachusetts Lowell Lines: 204 Message-ID: <1996Jan11.140022.1@willow> References: NNTP-Posting-Host: willow.uml.edu In article , Stafford@Ultra1.Winona.msus.edu (John J. Stafford) writes: > > Using DCL, how do you get the ASCII value of a character? -- Brendan Welch, system analyst, UMass/Lowell, W1LPG, welchb@woods.uml.edu Another way, ( "using DCL, 8-)" ) is to create ASCII.HLP from the following text, and place it in the help library. Not copyrighted, as far as I know, but do not know where I picked it up. ======================================================================== American Standard Code for Information Interchange _________________________ | The ASCII Character Set | |_________________________| NOTES: D = decimal, H = hexadecimal, O = octal. CHARACTER = the printed alphanumeric character you wish to send (or decode); it generally corresponds to the keys of a typewriter keyboard. MNEMONICS is like CHARACTER, but is for non-printable commands. The symbol ^ means "hold down the control key while striking the character to the right of the ^"; for example ^Z means control-Z. In actual usage, the leftmost binary bit is ignored, since it is always zero; ASCII is a 7-bit code. This table can also serve as a poor-person's conversion table among the radices (base 2, 8, 10, 16) for the first 128 numbers. Please report any errors in this table to SYSTEM. BINARY D H O MNEMONICS BINARY D H O CHARACTER --------- - - - --------- --------- -- -- --- --------- 0000 0000 0 0 0 ^@ NUL | 0100 0000 64 40 100 @ 0000 0001 1 1 1 ^A SOH | 0100 0001 65 41 101 A 0000 0010 2 2 2 ^B STX | 0100 0010 66 42 102 B 0000 0011 3 3 3 ^C ETX | 0100 0011 67 43 103 C 0000 0100 4 4 4 ^D EOT | 0100 0100 68 44 104 D 0000 0101 5 5 5 ^E ENQ | 0100 0101 69 45 105 E 0000 0110 6 6 6 ^F ACK | 0100 0110 70 46 106 F 0000 0111 7 7 7 ^G BEL | 0100 0111 71 47 107 G 0000 1000 8 8 10 ^H BS | 0100 1000 72 48 110 H 0000 1001 9 9 11 ^I HT | 0100 1001 73 49 111 I 0000 1010 10 A 12 ^J LF | 0100 1010 74 4A 112 J 0000 1011 11 B 13 ^K VT | 0100 1011 75 4B 113 K 0000 1100 12 C 14 ^L FF or PAGE | 0100 1100 76 4C 114 L 0000 1101 13 D 15 ^M CR | 0100 1101 77 4D 115 M 0000 1110 14 E 16 ^N SO | 0100 1110 78 4E 116 N 0001 1111 15 F 17 ^O SI | 0100 1111 79 4F 117 O BINARY D H O MNEMONICS BINARY D H O CHARACTER --------- -- -- -- --------- --------- -- -- --- --------- 0001 0000 16 10 20 ^P DLE | 0101 0000 80 50 120 P 0001 0001 17 11 21 ^Q XON | 0101 0001 81 51 121 Q 0001 0010 18 12 22 ^R DC2 | 0101 0010 82 52 122 R 0001 0011 19 13 23 ^S XOFF | 0101 0011 83 53 123 S 0001 0100 20 14 24 ^T DC4 | 0101 0100 84 54 124 T 0001 0101 21 15 25 ^U NAK | 0101 0101 85 55 125 U 0001 0110 22 16 26 ^V SYN | 0101 0110 86 56 126 V 0001 0111 23 17 27 ^W ETB | 0101 0111 87 57 127 W 0001 1000 24 18 30 ^X CAN | 0101 1000 88 58 130 X 0001 1001 25 19 31 ^Y EM | 0101 1001 89 59 131 Y 0001 1010 26 1A 32 ^Z EOF or SUB | 0101 1010 90 5A 132 Z 0001 1011 27 1B 33 ^[ ESC | 0101 1011 91 5B 133 [ 0001 1100 28 1C 34 ^\ FS | 0101 1100 92 5C 134 \ 0001 1101 29 1D 35 ^] GS | 0101 1101 93 5D 135 ] 0001 1110 30 1E 36 ^^ RS | 0101 1110 94 5E 136 ^ 0001 1111 31 1F 37 ^_ US | 0101 1111 95 5F 137 _ BINARY D H O CHARACTER BINARY D H O CHARACTER --------- -- -- -- --------- --------- -- -- --- --------- 0010 0000 32 20 40 (space) | 0110 0000 96 60 140 ` 0010 0001 33 21 41 ! | 0110 0001 97 61 141 a 0010 0010 34 22 42 " | 0110 0010 98 62 142 b 0010 0011 35 23 43 # | 0110 0011 99 63 143 c 0010 0100 36 24 44 $ | 0110 0100 100 64 144 d 0010 0101 37 25 45 % | 0110 0101 101 65 145 e 0010 0110 38 26 46 & | 0110 0110 102 66 146 f 0010 0111 39 27 47 ' | 0110 0111 103 67 147 g 0010 1000 40 28 50 ( | 0110 1000 104 68 150 h 0010 1001 41 29 51 ) | 0110 1001 105 69 151 i 0010 1010 42 2A 52 * | 0110 1010 106 6A 152 j 0010 1011 43 2B 53 + | 0110 1011 107 6B 153 k 0010 1100 44 2C 54 , | 0110 1100 108 6C 154 l 0010 1101 45 2D 55 - | 0110 1101 109 6D 155 m 0010 1110 46 2E 56 . | 0110 1110 110 6E 156 n 0010 1111 47 2F 57 / | 0110 1111 111 6F 157 o BINARY D H O CHARACTER BINARY D H O CHARACTER --------- -- -- -- --------- --------- -- -- --- --------- 0011 0000 48 30 60 0 | 0111 0000 112 70 160 p 0011 0001 49 31 61 1 | 0111 0001 113 71 161 q 0011 0010 50 32 62 2 | 0111 0010 114 72 162 r 0011 0011 51 33 63 3 | 0111 0011 115 73 163 s 0011 0100 52 34 64 4 | 0111 0100 116 74 164 t 0011 0101 53 35 65 5 | 0111 0101 117 75 165 u 0011 0110 54 36 66 6 | 0111 0110 118 76 166 v 0011 0111 55 37 67 7 | 0111 0111 119 77 167 w 0011 1000 56 38 70 8 | 0111 1000 120 78 170 x 0011 1001 57 39 71 9 | 0111 1001 121 79 171 y 0011 1010 58 3A 72 : | 0111 1010 122 7A 172 z 0011 1011 59 3B 73 ; | 0111 1011 123 7B 173 { 0011 1100 60 3C 74 < | 0111 1100 124 7C 174 | 0011 1101 61 3D 75 = | 0111 1101 125 7D 175 } 0011 1110 62 3E 76 > | 0111 1110 126 7E 176 ~ 0011 1111 63 3F 77 ? | 0111 1111 127 7F 177 DEL FURTHER EXPLANATION OF CONTROL CHARACTERS: These characters go back to the days when the only form of digital communication was by teletype (originally in uppercase letters only), sending messages in a standard form (header, address, text). The "memory" of a teletype message was in the form of punched paper tape. The first 32 characters were non-printing characters, for CONTROL of the process; thus holding down the CONTROL key and pressing G would ring the bell at the distant station (BEL); control-F would send an acknowledgement of the call (ACK); device control #1 (DC1 or control-Q) would turn on a device, such as a printer, and DC3 (control-S) would turn it off. These control characters are still used, but can be confusing because they can be totally unseen (such as ringing the bell), or seen differently (a single control-H, which is vertical tab, or new page, or form feed can cause a large gap on screen or paper when printing). They can cause further confusion because they can be undectable when being received, or difficult to send (e.g. how do you send a carriage return, since pressing the RETURN key causes termination of the command in which you wish to embed it? how do you discuss control-Y, if pressing that character causes your program to abort?). SOME EXAMPLES ---- -------- Example #1; Inside the EDT editor: You can create a page-break character by actually pressing control-L; you will see the actual 12 characters "" on the screen, but will take up only 1 character in the file. If you $TYPE or $PRINT the file, it will move to the next page. But the above paragraph is mostly an exception. If you wanted to send control-H (backspace to beginning of line), the editor will (very logically) inmmediately move to the beginning of the line. Thus, the general way to insert a control character (for example, the escape key) is 1) look up the ascii number (decimal) in the above table for the desired key. 2) press the gold key (PF1 on the numeric keypad). 3) on the normal typewriter portion of the keyboard, press the number(s), such as 2 and 7 for the 27th character, the escape key. 4) press the gold key again. 5) press the "3" key on the numeric keypad, since when preceded by the gold key, this has become the "special insert" command. 6) for some characters, you will see the results spelled out, such as the 5 characters "" for the escape key. Example #2; Inside the Digital Command Language (DCL): Please note that the actual use of some control keys in real time can be helpful when at the "$" prompt. With the up-arrow, you can recall previous commands. Many people know that these can be editted with the use of the right-arrow, left-arrow, and delete keys; but they do not know that they can toggle between "insert" and "overstrike" mode by using control-A, or quickly jump to the beginning of a long command by using control-H. If for example, you want to refer to the bell character, $ringbell[0,7] = 7 ! the [0,7] is constant; the number to the right of the = ! sign just happens to be 7 in this particular case. $ write sys$output ringbell,ringbell,ringbell ! to ring the bell 3 times Inside the Basic language (compiled, not immediate mode): Example #3; An example when reading: linput #1, line$ ! read a line of data from unit # 1 c$ = mid$( line$, 10, 1) ! get the character in column 10 n = ascii( c$ ) ! get the ascii number of the character if n = 9 then .... ! see if the character is a TAB (ascii 9 (decimal), ! in table above. Inside the Basic language (compiled, not immediate mode): Example #4; Same example when reading, using the EDT editor; NOTE: THIS FUNDMENTAL IDEA OF USING THE EDITOR SHOULD WORK IN ANY COMPILED LANGUAGE: linput #1, line$ c$ = mid$( line$, 10, 1) if c$ = " (here, inside the editor, use PF1, 9, PF1, specialinsert key) " then ....... Inside the Basic language (compiled, not immediate mode): Example #5; An example when writing: bell$ = chr$( 7 ) ! generate the 7th character in table above, BEL. print bell$ ! ring the bell NOTE: This example is somewhat trivial, because it uses the "hard-wired" number 7; thus you might as well have used the gold-key method of the editor. But in general, the number 7 (or 9 in previous example) could be replaced by an integer variable dependent on the logic of the program, which of course is something the editor cannot do. Inside the Fortran language: Example #6; Same problem as example #3. See notes to examples #4 and #5. character*1 line(80) read (1,10) (line(j), j=1,80) 10 format( 80a1 ) if( line(10) .eq. char(9) ) .............. Example #7; Same problem as example #4. See notes to examples #4 and #5. character*1 bell bell = char(7) print *, bell Inside Pascal, C, etc. Volunteers please send examples to SYSTEM.