TranOut (Socket function)

From m204wiki
Revision as of 02:07, 15 November 2011 by JAL2 (talk | contribs) (→‎Syntax terms)
Jump to navigation Jump to search

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

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