VSNTRANS_TEXT

This procedure applies a translate table, specified by TTABLE_TYPE, to the source text and places the result into DEST. The same array can be used for both the source and destination text.

There are five translate table types available. These types include the following:

  • Numeric to alternate digits

  • Alternate digits to numeric

  • Lowercase to uppercase

  • Uppercase to lowercase

  • Escapement direction for each character

Example

This example translates a string in lowercase letters to uppercase letters using the CanadaEBCDIC ccsversion. The MultiLingual System Administration, Operations, and Programming Guide can be used to determine that the ccsversion number for CanadaEBCDIC is 74. This number can also be retrieved by calling VALIDATE_NAME_RETURN_NUM with the name CanadaEBCDIC.

BEGIN

 $ INCLUDE INTL="SYMBOL/INTL/ALGOL/PROPERTIES." 10000000 - 49999999

  DEFINE SOURCE_START = 0 #
       ,DEST_START = 0 #;

  FILE OUT(KIND=DISK,UNITS=CHARACTERS,FILEUSE=IO,FILETYPE=0,NEWFILE,
           MAXRECSIZE=80,TITLE="OUT/ALGOL/VSNTRANS_TEXT.");
  EBCDIC ARRAY SOURCE[0:6]
             ,DEST[0:6];
  INTEGER VSN_NUM
        ,TRANS_LEN
        ,RESULT;
  REPLACE SOURCE BY "pæn";
  VSN_NUM := 74;
  TRANS_LEN := 4;
  RESULT := VSNTRANS_TEXT(VSN_NUM, SOURCE, SOURCE_START, DEST,
            DEST_START, TRANS_LEN, CS_LOWTOUPCASEV);
  WRITE(OUT,<"RESULT = ",J4>,RESULT);
  IF RESULT EQL CS_DATAOKV THEN
     WRITE(OUT,<"DEST   = ",A7>,DEST);
  CLOSE(OUT,LOCK);
END.

Output

RESULT = 1
DEST = PÆN

In this call, the parameters have the following meanings:

VSN_NUM is an integer passed to the procedure. It contains the number of the ccsversion to be used. The ccsversion contains the rules for translation of text. Refer to the MultiLingual System Administration, Operations, and Programming Guide for a list of the ccsversion numbers. The values allowed for VSN_NUM and the meanings of the values are as follows:

Value

Meaning

Greater than or equal to 0

Use the specified ccsversion number.

–2

Use the system default ccsversion. If the system default ccsversion is not available, an error is returned.

SOURCE is an EBCDIC array passed to the procedure. It contains the data to translate.

SOURCE_START is an integer passed to the procedure. It contains the byte offset (0 relative) of SOURCE where translation starts.

DEST is an EBCDIC array returned by the procedure. It contains the translated text. DEST must be at least as large as DEST_START and TRANS_LEN.

DEST_START is an integer returned by the procedure. It indicates the starting offset location where translated text should be placed.

TRANS_LEN is an integer passed to the procedure. It contains the number of characters to translate, beginning at SOURCE_START.

CS_LOWTOUPCASEV represents an integer that requests the translation of all lowercase characters to uppercase. It is one of five options:

Value

Sample Data Name

Meaning

5

CS_NUMTOALTDIGV

Translate numbers 0 through 9 to alternate digits specified in the ccsversion.

6

CS_ALTDIGTONUMV

Translate alternate digits to numbers 0 through 9.

7

CS_LOWTOUPCASEV

Translate all characters from lowercase to uppercase.

8

CS_UPTOLOWCASEV

Translate all characters from uppercase to lowercase.

9

CS_ESCMENTPERCHARV

Translate a character to its escapement value.

A ccsversion is not required to have a definition for each of these tables. Some of the tables are optional. Options 5, 6, 7, and 8 are not required. A result of CS_DATA_NOT_FOUNDV (4002) might be returned if the table has not been defined for the ccsversion. The input text remains the unchanged.

RESULT is an integer returned by the procedure. It indicates whether or not an error occurred during the execution of the procedure. An explanation of the error result values and messages can be found at the end of this section. The values returned by this procedure include:

CS_ARRAY_TOO_SMALLV (3001)

CS_DATAOKV (1)

CS_BAD_ARRAY_DESCRIPTIONV (3000)

CS_FAULTV (1001)

CS_BAD_DATA_LENV (3002)

CS_FILE_ACCESS_ERRORV (1000)

CS_BAD_TYPE_CODEV (3006)

CS_NO_NUM_FOUNDV (3003)

CS_DATA_NOT_FOUNDV (4002)

CS_SOFTERRV (1002)