Skip to content

TABLE

Data Conversion Table

This directive defines a conversion table that is used to convert input or output data from one character set to another.

TABLE mask table
mask
is a single byte, expressed as two hexadecimal digits, that is used as one byte in the logical AND operation with the input byte.
table
is a sequence of bytes expressed as two hexadecimal digits that are used to specify the output for each input byte sequence position after the AND function with mask.

The TABLE directive need not appear in a lower program line number or label than the directive that references it.

Execution of the TABLE directive causes no change in the program and is treated as a remark when normal program flow executes this directive.

The only space allowed in the syntax for this statement is between TABLE and the mask byte.

There are a maximum of 256 data codes for possible conversion. A complete TABLE therefore requires 256 bytes (512 hexadecimal digits) for conversion specifications, but for many cases it is only necessary to define a portion of the table since many of the possible input codes are not used or can be filtered out.

The filtering of data to be converted is accomplished by the use of a mask which is used as one byte in a logical AND operation, with the other byte being the data to convert. The logical AND operation performs a bit-by-bit comparison of the mask to the data: if the mask bit is 1, the corresponding bit of the data byte is transmitted unchanged to the table; if the mask bit is 0, a 0 is transmitted to the table.

As each data byte is operated on by the logical AND with the mask byte, the resulting byte is treated as a binary number to determine which byte of the table is used to supply the translated code. For example, if the data byte is $D7$ (W or binary 1101 0111) and the mask byte is $7F$ (binary 0111 1111) then the result of the AND operation is $57$ (binary 0101 0111) which is equal to the decimal value 87. The 87th byte of the table (actually the 88th byte, since the first byte is 00) is, therefore, used as the character to represent the original data byte.

The TABLE definition is referred to in the I/O directives by the TBL= option that specifies the statement number of the TABLE statement to be used in the conversion.

When used with input directives, the table is applied before the record is scanned for delimiting characters. Thus, the delimiting or control characters, as well as the data, is translated before the system interprets the record. When used with the output directives, the translation is applied after the system adds the delimiting of control characters to the record. This is important since the delimiter for fields in a record when the RECORD clause is used on input and output is $8A$ (1000 1010 in binary). Any mask character should provide for the ability to continue this character into or out of the data being written or read in order to allow proper operation of the RECORD clause.

When applied to records of SORT or DIRECT files, the key values of the records are also translated.

This directive can be used in Thoroughbred Basic Run Mode only; a statement number must precede the directive.

TABLE FF 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13
14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B
2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43
44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B
5C 5D 5E 5F 60 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53
54 55 56 57 58 59 5A 7B 7C 7D 7E 7F 80 81 82 83 84 85 86 87 88 89 8A 8B
8C 8D 8E 8F 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3
A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB
BC BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0 D1 D2 D3
D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB
EC ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF

(Spaces are shown for clarity only and must not be included when entering the data. The only space allowed in this statement is between TABLE and the mask byte.)

This statement defines a TABLE for translating ASCII code with mixed upper and lower case letters to all upper case letters (note the sequence from 00-60 then 41-5A, then 7B-FF). All characters other than the 26 lower case letters are unchanged (see the ASCII code chart in Volume I). This table is designed to work regardless whether bit 8 is set to 0 or 1 by the system.

TBL function

From the Thoroughbred Basic Language Reference, Volume III: R–Z, version 8.9.1. Open this page in the PDF