From Br Wiki
Jump to: navigation, search
TRANSLATE=<file ref>

The "TRANSLATE=file-ref" parameter indicates that character translation is required for all input or output of C, V, G, N, ZD or PIC strings. The file-ref must identify either a 256- or 512-byte file. The first 256 bytes are used as an input translation table.

This optional parameter allows the translation of data to or from another collating sequence. Internally, all computers represent letters of the alphabet, punctuation marks and even digits according to an arbitrary numbering scheme. Today, the common coding schemes is ASCII (American Standard Code for Information Interchange). In the past, EBCDIC (Extended Binary Coded Decimal Interchange Code) was used, especially for main frames. Probably the most common use of the TRANSLATE= capability is translating files between ASCII and EBCDIC.

An example of the difference between ASCII and EBCDIC is that the uppercase letters A, B and C are represented by 65, 66 and 67 respectively in ASCII; but in EBCDIC, they are 193, 194 and 195. Also, in ASCII, the blank or space character is represented by the number 32 while in EBCDIC it is number 64. Although all systems that currently run Business Rules the ASCII coding scheme, some older computer systems use EBCDIC.

Used in Open statements: Display, Internal, external, and communications.

The translate table is made up of 256 characters starting with the replacement value for CHR$(0), and ending with CHR$(255).

See also the XLATE$ internal function.

Sample Programs to create "TRANSLATE" tables:

  • This program created a TRANSLATE table that will only allow "Common Characters", and filter out unwanted symbols. Tihs is commonly used when importing data from Electronic Data files.
00100   DIM Tbl$*512,Edi_Xlate$*512
00110   LET Edi_Xlate$ = Rpt$(" ", 32)&" !"&Chr$(34)&"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~*"&Rpt$(" ", 128)
00120   LET Edi_Xlate$(11:11)=Chr$(10) : LET Edi_Xlate$(14:14)=Chr$(13)
00130   LET Tbl$=Edi_Xlate$&Edi_Xlate$
00150   WRITE #1,USING 160: Tbl$
00160   FORM Pos 1,C 512
00170   CLOSE #1:
00180   END