Database Translation Tables
Database translation tables convert character strings during database input or output. This makes it possible to display characters stored in the database that are normally not visible (such as typesetting codes), or to store a key entered in a field as another string.
For example, typesetting or control codes that would
not normally be visible on the terminal screen, can be converted to visible markers. Thus, ^27 can
be converted to the string “<ESC
>” for display.
You can define simple combinations of letters for
complex strings that are used frequently. For example, the string “=newhead=
” can
be translated into the string needed to clear the screen, move down four lines, and generate a new
heading number.
To use translation tables during DBMS input and output:
- Specify the keyboard translation tables that will be used for read and write in your form-level definitions.
- Specify that database I/O translation is required. Do this in the field interface definition of individual fields.
If you request translation for a field, Uniface scans the data for the field as it is retrieved. If Uniface encounters a source string from the specified table, it converts the source string to the target string before the data enters the external structure. The opposite operation occurs as the field is stored.
To convert character strings, you must use keyboard translation tables for storing, and device translation tables for displaying or printing.
For example, to store an ASCII value 128 as an ASCII
value 224, first set
$DEF_CHARSET=PC
(since these are PC character values). Then,
determine the Uniface character values for these ASCII values using the character sets tables. In
this case, the Uniface values are 1.^071 (Font 1, value 071) and 4.^097 (Font 4, value 097),
respectively. Set this conversion up in the keyboard translation table.
The keyboard translation table is set up in the following syntax:
source target
This means that this entry would look like this:
^1.^071 ^4.097
Then, if you would like to continue to display ASCII character 128, instead of the stored value 224, place the following line in the device translation table:
^196^097 ^193^071
The actual translation is done between Uniface internal characters, and not between the ASCII characters. The incoming character is translated into a Uniface value as it is received, and the outgoing character is translated from a Uniface character into the correct display character as it is displayed. This is done automatically by Uniface.
Most people never use database translation tables. If you need to use them, remember that they are affected by the value of $VARIATION. Consequently, ensure that the current library always contains a valid database translation table when it is in use.
Note: Any characters not included in a source string are not translated, that is, they are lost.
3GLs and General Variables
Uniface uses the following 3GL routines to transport data to and from 3GL programs via general variables ($1-$99):
UFGET
UGETREGS
UFPUT
UPUTREGS
Data is presented according to the character set selected during installation. Be aware that defining a different character set at the entity level can cause discrepancies.
For example, assume that Uniface is running on an
IBM machine and that the IBM RT character set was defined at installation time as the character set
to use. One entity is stored in the DEC character set. In this case, UFGET
would
present data from this entity in the DEC character set, but UPUTREGS
would assume
that the data was being presented in the IBM RT character set. This can cause problems when special
characters are used.