TBL() Function - String Table Conversion

Syntax

TBL(string,string{,ERR=lineref})
TBL(string,TBL=lineref{,ERR=lineref})

Description

The TBL() function performs the string translation described in the TABLE verb. The first argument is the string to translate. The second argument, which specifies the translation table, may be either another string or a TBL=lineref reference. If the table is in a string, the string must be at least one byte long. If TBL= is used, it must refer to a TABLE statement.

In the example below, the TABLE statement has a table in which the characters "a" ($61$) through "z" ($7A$) are replaced by the characters "A" ($41$) to "Z" ($5A$). The following code illustrates the use of a table specified in a TABLE statement.

Examples

0010 A$="AaBbCcDdEeFfGgHhIi"
0020 B$=TBL(A$,TBL=1000)
0030 print A$,'lf',B$
0040 STOP
1000 TABLE 7F 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14
1000:15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C
1000:2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44
1000:45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C
1000:5D 5E 5F 60 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54
1000:55 56 57 58 59 5A 7B 7C 7D 7E 7F
>RUN
AaBbCcDdEeFfGgHhIi
AABBCCDDEEFFGGHHII
>READY

 

To use the table as a string in the first form of the TBL function, the conversion table must be specified as a hexadecimal string. The following code illustrates using the lower to upper case conversion table as a hexadecimal string. Note that the same table is used in both examples.

 

0010 LET A$="AaBbCcDdEeFfGgHhIi"
0020 LET UP2LOW$=$7F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C
0020:1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404
0020:142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F604142434445
0020:464748494A4B4C4D4E4F505152535455565758595A7B7C7D7E7F$
0030 LET B$=TBL(A$,UP2LOW$)
0040 PRINT A$,'LF',B$
0050 STOP

>run
AaBbCcDdEeFfGgHhIi
AABBCCDDEEFFGGHHII

>READY


See Also

Functions - Alphabetical Listing