TranOut (Socket function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
 
(One intermediate revision by the same user not shown)
Line 12: Line 12:
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%str
<tr><th>%string
</th><td>String that is to contain the translation of the input string into the remote character set.
</th><td>String that is to contain the translation of the input string into the remote character set.
</td></tr>
</td></tr>
Line 38: Line 38:


==Examples==
==Examples==
<ul>
<ol>
<li>In the following example, database fields only are translated and sent to the remote.
<li>In the following example, database fields only are translated and sent to the remote.
<p class="code">%sock is Object <var>Socket</var>
<p class="code">%sock is Object <var>Socket</var>
Line 59: Line 59:
   ...
   ...
</p>
</p>
</ul>
</ol>


{{Template:Socket:TranOut footer}}
{{Template:Socket:TranOut footer}}

Latest revision as of 19:13, 11 June 2012

Translate an internal-encoded string to remote (Socket class)


This method translates an individual string, from the local internal character set (EBCDIC), to the character set of the remote. Designed for cases where translation needs to be selective, the TranOut function has an effect similar to its equivalent $function, $Sock_Tran_Out.

Syntax

%string = socket:TranOut( string)

Syntax terms

%string String that is to contain the translation of the input string into the remote character set.
socket A variable or an expression that is a reference to a Socket object.
string The string that is to be translated to the remote character set.

Usage notes

  • The translate table TranOut uses is the input table defined by the XTAB parameter of the socket.
  • The TranOut method can cause a jump to the ONRESET label or request cancellation, and it can set the last error information, but it does not return any error indication.
  • The TranOut method 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, TranOut is used to translate from EBCDIC strings that are sent to non-mainframe sources that use other character mapping schemes, like ASCII or non-English character sets.

Examples

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

    %sock is Object Socket %sock = New %old = %sock:Set('BINARY') For Each Record %xlate = %sock:TranOut(DATA_FIELD) %rc = %sock:SendWithLineEnd(%xlate) End For %old = %sock:Set('BINARY', %old)

  2. TranOut can be useful if you want to use a "normal" character as either the LINEND or PRSTOK value (see Set) for communication with the remote. In the following example, LINEND is set to a pair of plus sign (+) characters:

    Begin %sock is Object Socket %sock = New('SOCKEM') %s = %sock:TranOut('++') %t = %sock:Set('LINEND', %s) ...