program lochas(input ,output); (* lochas: look at characters in a file Tom Schneider NCI/FCRDC Bldg 469. Room 144 P.O. Box B Frederick, MD 21702-1201 (301) 846-5581 (-5532 for messages) network address: toms@ncifcrf.gov National Cancer Institute Laboratory of Mathematical Biology 1992 *) label 1; (* end of program *) const (* begin module version *) version = 1.05; (* of lochas.p 1993 January 6 origin 1993 Jan 4 *) (* end module version *) (* begin module describe.lochas *) (* name lochas: look at characters in a file synopsis lochas(input: in, output: out) files input: a file output: identification of ascii characters in the file each line contains: the first three characters: the ordinal of the character blank (ie " ") dash (ie "-") the character or a blank in special cases dash (ie "-") blank (ie " ") 6 characters: the number of the character in the file blank (ie " ") the remainder contains one of: NULL - a null character found BLANK - a blank character was found HIGH ORDER BIT REMOVED - the character had its high order bit set. To print it, this was removed. or END OF LINE which indicates that an end of line condition was found. This is counted as a single character. description The program allows one to inspect the characters in a file. examples documentation see also author Thomas Dana Schneider bugs technical notes *) (* end module describe.lochas *) procedure printchar(var f: text; c: integer); (* print then name of the character c to file f. From the Unix manual for ascii: | 0 NUL| 1 SOH| 2 STX| 3 ETX| 4 EOT| 5 ENQ| 6 ACK| 7 BEL| | 8 BS | 9 HT | 10 NL | 11 VT | 12 NP | 13 CR | 14 SO | 15 SI | | 16 DLE| 17 DC1| 18 DC2| 19 DC3| 20 DC4| 21 NAK| 22 SYN| 23 ETB| | 24 CAN| 25 EM | 26 SUB| 27 ESC| 28 FS | 29 GS | 30 RS | 31 US | | 32 SP | 33 ! | 34 " | 35 # | 36 $ | 37 % | 38 & | 39 ' | | 40 ( | 41 ) | 42 * | 43 + | 44 , | 45 - | 46 . | 47 / | | 48 0 | 49 1 | 50 2 | 51 3 | 52 4 | 53 5 | 54 6 | 55 7 | | 56 8 | 57 9 | 58 : | 59 ; | 60 < | 61 = | 62 > | 63 ? | | 64 @ | 65 A | 66 B | 67 C | 68 D | 69 E | 70 F | 71 G | | 72 H | 73 I | 74 J | 75 K | 76 L | 77 M | 78 N | 79 O | | 80 P | 81 Q | 82 R | 83 S | 84 T | 85 U | 86 V | 87 W | | 88 X | 89 Y | 90 Z | 91 [ | 92 \ | 93 ] | 94 ^ | 95 _ | | 96 ` | 97 a | 98 b | 99 c |100 d |101 e |102 f |103 g | |104 h |105 i |106 j |107 k |108 l |109 m |110 n |111 o | |112 p |113 q |114 r |115 s |116 t |117 u |118 v |119 w | |120 x |121 y |122 z |123 { |124 | |125 } |126 ~ |127 DEL| *) begin case c of 0: write(f,'NUL'); 1: write(f,'SOH'); 2: write(f,'STX'); 3: write(f,'ETX'); 4: write(f,'EOT'); 5: write(f,'ENQ'); 6: write(f,'ACK'); 7: write(f,'BEL'); 8: write(f,'BS '); 9: write(f,'HT '); 10: write(f,'NL '); 11: write(f,'VT '); 12: write(f,'NP '); 13: write(f,'CR '); 14: write(f,'SO '); 15: write(f,'SI '); 16: write(f,'DLE'); 17: write(f,'DC1'); 18: write(f,'DC2'); 19: write(f,'DC3'); 20: write(f,'DC4'); 21: write(f,'NAK'); 22: write(f,'SYN'); 23: write(f,'ETB'); 24: write(f,'CAN'); 25: write(f,'EM '); 26: write(f,'SUB'); 27: write(f,'ESC'); 28: write(f,'FS '); 29: write(f,'GS '); 30: write(f,'RS '); 31: write(f,'US '); 32: write(f,'SP '); 33: write(f,' ! '); 34: write(f,' " '); 35: write(f,' # '); 36: write(f,' $ '); 37: write(f,' % '); 38: write(f,' & '); 39: write(f,' '' '); 40: write(f,' ( '); 41: write(f,' ) '); 42: write(f,' * '); 43: write(f,' + '); 44: write(f,' , '); 45: write(f,' - '); 46: write(f,' . '); 47: write(f,' / '); 48: write(f,' 0 '); 49: write(f,' 1 '); 50: write(f,' 2 '); 51: write(f,' 3 '); 52: write(f,' 4 '); 53: write(f,' 5 '); 54: write(f,' 6 '); 55: write(f,' 7 '); 56: write(f,' 8 '); 57: write(f,' 9 '); 58: write(f,' : '); 59: write(f,' ; '); 60: write(f,' < '); 61: write(f,' = '); 62: write(f,' > '); 63: write(f,' ? '); 64: write(f,' @ '); 65: write(f,' A '); 66: write(f,' B '); 67: write(f,' C '); 68: write(f,' D '); 69: write(f,' E '); 70: write(f,' F '); 71: write(f,' G '); 72: write(f,' H '); 73: write(f,' I '); 74: write(f,' J '); 75: write(f,' K '); 76: write(f,' L '); 77: write(f,' M '); 78: write(f,' N '); 79: write(f,' O '); 80: write(f,' P '); 81: write(f,' Q '); 82: write(f,' R '); 83: write(f,' S '); 84: write(f,' T '); 85: write(f,' U '); 86: write(f,' V '); 87: write(f,' W '); 88: write(f,' X '); 89: write(f,' Y '); 90: write(f,' Z '); 91: write(f,' [ '); 92: write(f,' \ '); 93: write(f,' ] '); 94: write(f,' ^ '); 95: write(f,' _ '); 96: write(f,' ` '); 97: write(f,' a '); 98: write(f,' b '); 99: write(f,' c '); 100: write(f,' d '); 101: write(f,' e '); 102: write(f,' f '); 103: write(f,' g '); 104: write(f,' h '); 105: write(f,' i '); 106: write(f,' j '); 107: write(f,' k '); 108: write(f,' l '); 109: write(f,' m '); 110: write(f,' n '); 111: write(f,' o '); 112: write(f,' p '); 113: write(f,' q '); 114: write(f,' r '); 115: write(f,' s '); 116: write(f,' t '); 117: write(f,' u '); 118: write(f,' v '); 119: write(f,' w '); 120: write(f,' x '); 121: write(f,' y '); 122: write(f,' z '); 123: write(f,' { '); 124: write(f,' | '); 125: write(f,' } '); 126: write(f,' ~ '); 127: write(f,'DEL'); end; end; (* begin module lochas.themain *) procedure themain(var afile: text); (* the main procedure of the program *) var c: integer; (* ordinal of a character in afile *) count: integer; (* count of the characters found *) highorderbit: boolean; (* true if the character has its high order bit set *) begin writeln(output,'* lochas ',version:4:2); reset(afile); count := 0; while not eof(afile) do begin count := count + 1; if eoln(afile) then begin writeln(output,'END OF LINE'); readln(afile); end else begin c := ord(afile^); if c > 128 then begin c := c - 128; highorderbit := true; end else highorderbit := false; write(output,count:6); write(output,' '); write(output,c:3); write(output,' '); write(output,'|'); printchar(output,c); write(output,'|'); if c = 32 then write(output,' space'); if c = 0 then write(output,' null'); if highorderbit then write(output,' HIGH ORDER BIT REMOVED'); writeln(output); get(afile) end end; end; (* end module lochas.themain *) begin themain(input); 1: end.