Subroutine to Convert Special Characters

FOCUS provides subroutines that operate on one or more arguments and return a single value as the result.  The subroutine CTRAN enables you to convert one character in an alphanumeric field to another character.  To use this subroutine, you need to know the decimal equivalent of the characters in internal machine representation.  Refer to the character charts listed in your FOCUS documentation for printable EBCDIC characters and their decimal equivalents.

 

In the example below, the character '&' is converted to '@' in values for the field, AN:WORKLOC.  The conversion is required because '&' is a special character reserved by FOCUS for implied prompting.  

 

ex an

define file an adD

AN:WORKLOC/A8 = CTRAN(8,AN:WORKLOC,80,124,'A8');

end

 

The syntax for the CTRAN subroutine is:  

CTRAN(Inlen, infield, decfrm, decto, output)

 

Where:

inlen  = integer, is the length in characters of the input string

infield = alphanumeric field,  is the input string

decfrm = integer, is the decimal value of the character to be translated

decto = integer, is the decimal ACSII or EBCDIC value of the character to be used as a substitute for DECFRM

output = alphanumeric, is the format of the resulting output string enclosed in single quotation marks

 

For more information on subroutines, refer to your FOCUS documentation.