$Sock Tran Out: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
(Automatically generated page update)
 
Line 1: Line 1:
{{DISPLAYTITLE:$Sock_Tran_Out}}
{{DISPLAYTITLE:$Sock_Tran_Out}}
<span class="pageSubtitle">Translate string to remote's character set</span>
<span class="pageSubtitle">Translate string to remote's character set</span>
<p class="warn"><b>Note: </b>Most Sirius $functions have been deprecated in favor of Object Oriented
<p class="warn"><b>Note: </b>Many $functions have been deprecated in favor of Object Oriented
methods. The OO equivalent for <var>$Sock_Tran_Out</var> is the <var>[[TranOut (Socket function)|TranOut]]</var> method.</p>
methods. The OO equivalent for <var>$Sock_Tran_Out</var> is the <var>[[TranOut (Socket function)|TranOut]]</var> method.</p>



Latest revision as of 00:00, 21 September 2018

Translate string to remote's character set

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

$Sock_Tran_Out translates a string, from the local internal character set ("EBCDIC"), to the character set of the remote. 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_Out(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_Out.

Usage notes

  • $Sock_Tran_Out 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, $Sock_Tran_Out is used to translate into ASCII strings from mainframe sources.

Examples

  1. In the following example, database fields are translated and sent to the remote:

    %old = $Sock_Set(%socket, 'BINARY') For Each record %xlate = $Sock_Tran_Out(DATA_FIELD, %socket) %rc = $Sock_SendLn(%socket, %xlate) End For %old = $Sock_Set(%socket, 'BINARY', %old)

  2. $Sock_Tran_Out can be useful if you wish to use a "normal" character in either the LINEND or PRSTOK parameter, since you must specify it in the character set used to communicate with the remote. For example, the following sets LINEND to a pair of plus sign (+) characters:

    Begin %socket = $Sock_Conn('SOCKEM') %s = $Sock_Tran_Out('++', %socket) %t = %SOCK_SET(%socket, 'LINEND', %s) ...

    The translate table used is the output table defined by the XTAB parameter of the socket.