DDE Functions

Return to Introduction  Previous page  Next page

TN3270 Plus can function as a Dynamic Data Exchange (DDE) server. This allows DDE client applications to communicate with TN3270 Plus.  For example, some users write Microsoft Excel macros to capture data from the TN3270 Plus terminal window and populate a spreadsheet. TN3270 Plus supports the following DDE functions:

Session Topic Functions

Use the session topic to send data to, and receive data from, a terminal session.

 

Connect

Service=tn3270,Topic=session name | session#session_number

Examples:

Connect Service=tn3270,Topic=mainframe
Connect Service=tn3270,Topic=session#3

 

Return Values

Success: A handle to the conversation.
Failure:  0

Execute

Item=close

closes the session.

 

Item=macro macroname

executes a macro.
macroname is the macro name.

 

Item=script filename

executes a script. 
filename is the full path to the script to be executed.

 

Return Values

Success: (HDDEDATA) DDE_FACK
Failure:    (HDDEDATA) DDE_FNOTPROCESSED

Request

Item=PS

returns the presentation space (screen image).

 

Item=Cursor

returns the cursor position (relative to 1).

 

Item=Rows

returns the number of rows in the presentation space.

 

Item=Columns

returns the number of columns in the presentation space.

 

Item=Emulator

returns the window handle of the TN3270 Plus window.

 

Item=Keyboard

returns "Locked" if the keyboard is locked or else it returns "Clear".

 

Item=OIA

returns the Operator Information Area (note that this is NOT in IBM format).

 

Item=Rnn

returns the nth row in the presentation space.

 

Item=Fnn

returns the nth field in the presentation space.

 

Item=FnnU

returns the nth unprotected field in the presentation space.

 

Item=FnnP

returns the nth protected field in the presentation space.

 

Item=Pnnn[F|Lmmm]

returns a portion of the presentation space.

P = Identifier for starting position

nnn = starting position on screen (relative to 1)

F = return entire field at the starting position

L = Identifier for length

mmm = length of data to return

Examples:

P560 returns screen data from position 560 to the end of the field.

P560F returns the entire field encompassing position 560.

P560L80 returns data from position 560 for a length of 80 characters.

 

Return Values

Success: A handle to the data being returned.
Failure:  0

Poke

Item=Keystroke

sends one or more keystrokes to TN3270 Plus (same format as WinHLLAPI). See the Keystroke Table for a list of all the keystrokes.

 

Item=Cursor

moves the cursor position (relative to 1).

 

Item=EscChar

sets the escape character for Item=Keystroke (default is '@').

 

Return Values

Success: (HDDEDATA) DDE_FACK
Failure:    (HDDEDATA) DDE_FNOTPROCESSED

Advise

Item=PS

sends the presentation space to the client whenever it is updated.

 

Item=Cursor

sends the cursor position to the client whenever it is updated.

 

Return Values

Success: (HDDEDATA) TRUE
Failure:     (HDDEDATA) FALSE

       

System Topic Functions

Use the system topic to send instructions to the TN3270 Plus application.

 

Connect Service=tn3270,Topic=system


Return Values

Success: A handle to the conversation.
Failure:  0

Execute

Item=connect session

connects to a session.
session is the name of the session.

 

Item=close session

closes a session.
session is the name of the session.

 

Item=key keyname

sends a menu key.
keyname is the name of the menu key.

 

Item=script filename

executes a script.
filename is the full path to the script to be executed.


Return Values

Success: (HDDEDATA) DDE_FACK
Failure:    (HDDEDATA) DDE_FNOTPROCESSED

Request

Item=activesession

returns the session number of the currently active session.


Item=sessions

returns the total number of active sessions.

Tnrun.exe

The tnrun.exe program can execute DDE functions from an external script or program (e.g. Windows Script). The command line format is:

tnrun.exe topic command item

tnrun.exe topic request {/e environment_variable_name | /c} item

Parameters that contain spaces must be enclosed in double quotes.

Where:

topic

command

item

SYSTEM

connect | start

session_name

SYSTEM

disconnect | close

session_name

SYSTEM

key

keyname

SYSTEM

script

filename

session_name

disconnect | close

 

session_name

key

keyname

session_name

macro

macroname

session_name

poke cursor

cursor_address

session_name

poke EscChar

escape_character

session_name

poke keystroke

keystroke

session_name

script

filename

 

/e environment_variable_namefor DDE requests the returned data is placed in the specified environment variable.
/c for DDE requests the returned data is placed on the clipboard in text format.

Examples:

tnrun.exe SYSTEM connect mainframe

(Start the TN3270 Plus session "mainframe".)

tnrun.exe mainframe disconnect

(Disconnect the TN3270 Plus "mainframe" session.)

tnrun.exe mainframe macro login

(Run the "login" macro on session mainframe")

tnrun.exe iSeries keystroke @E

(Send the enter key to the "iSeries" session.)

tnrun.exe "PRD A" script "c:\scripts\Log me in"

(Run the "Log me in" script in session "PRD A".)

tnrun.exe mainframe request /c PS

(Copy the mainframe session presentation space to the clipboard.)

               

Sample Call to Tnrun.exe using VBScript

' CallTnrun.vbs

' Language: VBScript using the Windows Script Host

' When the objShell.Run command parameter contains double quotes within the parameter,

' substitute each double quote in the parameter with two double quotes.

dim objShell

set objShell = WScript.CreateObject("WScript.Shell")

objShell.Run """c:\Program Files (x86)\SDI\TN3270 Plus\tnrun.exe"" SYSTEM connect mainframe"

objShell.Run """c:\Program Files (x86)\SDI\TN3270 Plus\tnrun.exe"" mainframe macro login"

 

Sample Programs

Sample programs are available for download from the Customer Downloads web page.

 


TN3270 Plus is continually being improved. To learn more about the latest enhancements, please review our Version History web page.