$Sock_Tran_In

From m204wiki
Jump to navigation Jump to search

Translate string from remote's character set

Note: Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for $Sock_Tran_In is the TranIn method.

$Sock_Tran_In translates a string, from the character set of the remote, to the local internal character set (EBCDIC). It is a bit different from other $Sock functions:

  • The socket number is the second argument, not the first.
  • Although it references a socket number, and it can cause a jump to the ONRESET label or request cancellation and can set the last error information, it does not return any error indication.

Syntax

%string = $Sock_Tran_In(string, sockNum)

Syntax terms

%string A string that is to contain the translation of the input string into the local character set.
string The string to be translated.
sockNum The socket number, which has associated with it the translation table used by $Sock_Tran_In.

Usage notes

  • $Sock_Tran_In continues with the next statement if ONRESET CONTINUE, CANCELC, or LABELC is in effect for the socket. It always returns the translated string; it never returns an error indicator.
  • Typically the $Sock_Tran_In function is used to translate into EBCDIC strings that are received from non-mainframe sources that use other character mapping schemes, like ASCII or non-English character sets.

Example

In the following example, parsed lines are received into the %s variable, then translated, and printed in EBCDIC. The translate table used is the input table defined by the XTAB parameter of the socket.

%old = $Sock_Set(%socket, 'BINARY') Repeat %len = $Sock_RecvPrs(%socket, %s) If %len Le 0 Then Loop End End If %xlate = $Sock_Tran_In(%s, %socket) Print %xlate End Repeat %old = $Sock_Set(%socket, 'BINARY', %old)