TranOut (Socket function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
Line 1: Line 1:
 
{{Template:Socket:TranOut subtitle}}
<span class="pageSubtitle"><section begin=dpl_desc/><section end=dpl_desc/></span>
[[Category:Socket methods|TranOut function]]
<p>
<var>TranOut</var> is a member of the <var>[[Socket class|Socket]]</var> class.
</p>


This method translates an individual string,
This method translates an individual string,
Line 13: Line 8:


==Syntax==
==Syntax==
<p class="syntax">%str = %socko:TranOut(string)
{{Template:Socket:TranOut syntax}}
</p>
 
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%str
<tr><th>%str
Line 64: Line 60:
</p>
</p>
</ul>
</ul>
{{Template:Socket:TranOut footer}}

Revision as of 23:21, 14 November 2011

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

%str String that is to contain the translation of the input string into the remote character set.
%socko 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

  • 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)

  • 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) ...