Class X3270is
Simplified x3270 interface class, usable as a DLL or via COM.
Implements
Inherited Members
Namespace: X3270is
Assembly: x3270is.dll
Syntax
public abstract class X3270is : IDisposable
Remarks
Abstract class, cannot be constructed directly.
Constructors
| Improve this Doc View SourceX3270is()
Initializes a new instance of the X3270is class.
Declaration
public X3270is()
Properties
| Improve this Doc View SourceClient
Gets or sets the TCP session to the emulator.
Declaration
protected TcpClient Client { get; set; }
Property Value
Type | Description |
---|---|
System.Net.Sockets.TcpClient |
Debug
Gets or sets a value indicating whether to log debug messages to System.Console.Error.
Declaration
[ComVisible(true)]
public bool Debug { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
DebugOutput
Gets debug output for the last action.
Declaration
[ComVisible(true)]
public string DebugOutput { get; }
Property Value
Type | Description |
---|---|
System.String |
StatusLine
Gets the most recent status line.
Declaration
[ComVisible(true)]
public string StatusLine { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceDispose()
Dispose the object.
Declaration
[ComVisible(true)]
public void Dispose()
Dispose(Boolean)
Dispose the object.
Declaration
[ComVisible(true)]
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | True if disposing. |
Log(String, Object[])
Log debugging information.
Declaration
protected void Log(string format, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | String format. |
System.Object[] | args | Message parameters. |
Quote(String)
Quote a parameter appropriately for the emulator.
Declaration
[ComVisible(true)]
public static string Quote(string param)
Parameters
Type | Name | Description |
---|---|---|
System.String | param | Parameter to quote. |
Returns
Type | Description |
---|---|
System.String | Quoted parameter. |
Remarks
From the original Xt Intrinsics manual: A quoted string may contain an embedded quotation mark if the quotation mark is preceded by a single backslash (). The three-character sequence ‘‘\"’’ is interpreted as ‘‘single backslash followed by end-of-string’’. This is simpler (and more subtle) than it seems.
Run(String, IEnumerable<String>)
Run an action, transparently formatting the arguments.
Declaration
[ComVisible(true)]
public string Run(string action, IEnumerable<string> args)
Parameters
Type | Name | Description |
---|---|---|
System.String | action | Action name. |
System.Collections.Generic.IEnumerable<System.String> | args | Action arguments. |
Returns
Type | Description |
---|---|
System.String | Result string, multiple lines separated by System.Environment.NewLine. |
Remarks
The emulator prompt is saved in StatusLine. Debug output (exact strings sent and received) is saved in DebugOutput.
Examples
// C#
using System.Linq;
using X3270is;
// ...
// Set up the connection.
var worker = new WorkerConnection();
// Query the cursor position.
var cursor = worker.Run("Query", "Cursor");
// Move the cursor over one column, and down one row.
var cursorSplit = cursor.Split(' ');
var arr = new string[2];
arr[0] = (int.Parse(cursorSplit[0]) + 1).ToString();
arr[1] = (int.Parse(cursorSplit[1]) + 1).ToString();
worker.Run("MoveCursor", arr);
// Move the cursor over one column, and down one row (too cleverly).
worker.Run("MoveCursor", cursor.Split(' ').Select(c => (int.Parse(c) + 1).ToString()))
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Control characters in text. |
System.InvalidOperationException | Object in wrong state. |
X3270isActionException | Action failed: emulator returned an error. |
X3270isDisconnectException | Lost emulator connection. |
Run(String, Object[])
Run an action, transparently formatting the arguments. For PowerShell, which uses untyped arrays by default.
Declaration
[ComVisible(true)]
public string Run(string action, object[] args)
Parameters
Type | Name | Description |
---|---|---|
System.String | action | Action name. |
System.Object[] | args | Action arguments. |
Returns
Type | Description |
---|---|
System.String | Result string, multiple lines separated by System.Environment.NewLine. |
Remarks
The emulator prompt is saved in StatusLine. Debug output (exact strings sent and received) is saved in DebugOutput.
Examples
# PowerShell
# Load the x3270 interface DLL.
Add-Type -Path "C:\Program Files\x3270is\x3270is.dll"
# Set up the connection.
$worker = New-Object -TypeName X3270is.WorkerConnection
# Query the cursor position.
$cursor = $worker.Run("Query", "Cursor")
$cursorSplit = $cursor.Split(" ")
$row = $cursorSplit[0] -as [int]
$column = $cursorSplit[1] -as [int]
# Move the cursor over one column, and down one row.
$a = @()
$a += $row + 1
$a += $column + 1
$worker.Run("MoveCursor", $a)
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Control characters in text. |
System.InvalidOperationException | Object in wrong state. |
X3270isActionException | Action failed: emulator returned an error. |
X3270isDisconnectException | Lost emulator connection. |
Run(String, String[])
Run an action, transparently formatting the arguments.
Declaration
[ComVisible(true)]
public string Run(string action, params string[] args)
Parameters
Type | Name | Description |
---|---|---|
System.String | action | Action name. |
System.String[] | args | Action arguments. |
Returns
Type | Description |
---|---|
System.String | Result string, multiple lines separated by System.Environment.NewLine. |
Remarks
The emulator prompt is saved in StatusLine. Debug output (exact strings sent and received) is saved in DebugOutput.
Examples
// C#
using X3270is;
// ...
// Set up the connection.
var worker = new WorkerConnection();
// Query the cursor position.
var cursor = worker.Run("Query", "Cursor");
var cursorSplit = cursor.Split(' ');
var row = int.Parse(cursorSplit[0]);
var column = int.Parse(cursorSplit[1]);
// Move the cursor over one column, and down one row.
worker.Run("MoveCursor", (row + 1).ToString(), (column + 1).ToString())
# PowerShell
# Load the x3270 interface DLL.
Add-Type -Path "C:\Program Files\x3270is\x3270is.dll"
# Set up the connection.
$worker = New-Object -TypeName X3270is.WorkerConnection
# Query the cursor position.
$cursor = $worker.Run("Query", "Cursor")
$cursorSplit = $cursor.Split(" ")
$row = $cursorSplit[0] -as [int]
$column = $cursorSplit[1] -as [int]
# Move the cursor over one column, and down one row.
$worker.Run("MoveCursor", ($row + 1).ToString(), ($column + 1).ToString())
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Control characters in text. |
System.InvalidOperationException | Object in wrong state. |
X3270isActionException | Action failed: emulator returned an error. |
X3270isDisconnectException | Lost emulator connection. |
RunJScriptArray(String, Object)
Run an action, transparently formatting the arguments. For JScript, which uses its own form of arrays and doesn't understand method overloading or variable/optional arguments.
Declaration
[ComVisible(true)]
public string RunJScriptArray(string action, object args)
Parameters
Type | Name | Description |
---|---|---|
System.String | action | Action name. |
System.Object | args | JScript array of arguments. |
Returns
Type | Description |
---|---|
System.String | Result string, multiple lines separated by System.Environment.NewLine. |
Remarks
The emulator prompt is saved in StatusLine. Debug output (exact strings sent and received) is saved in DebugOutput.
Examples
// JScript
// Create the connection to the emulator.
var worker = new ActiveXObject("X3270is.WorkerConnection");
// Query the cursor position.
var cursor = worker.RunJScriptArray("Query", new Array("Cursor"));
var cursorSplit = cursor.split(" ");
var row = parseInt(cursorSplit[0]);
var column = parseInt(cursorSplit[1]);
// Then move the cursor back over one column and down one row.
worker.RunJScriptArray("MoveCursor", new Array(row + 1, column + 1));
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Control characters in text. |
System.InvalidOperationException | Object in wrong state. |
X3270isActionException | Action failed: emulator returned an error. |
X3270isDisconnectException | Lost emulator connection. |
RunRaw(String)
Basic emulator I/O function. Given a correctly-formatted action and argument string, send it and return the reply.
Declaration
[ComVisible(true)]
public string RunRaw(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The action name and arguments to pass to the emulator. Must be formatted correctly. This method does no translation. |
Returns
Type | Description |
---|---|
System.String | Result string, multiple lines separated by System.Environment.NewLine. |
Remarks
The emulator prompt is saved in StatusLine. Debug output (exact strings sent and received) is saved in DebugOutput.
Examples
// C#
using X3270is;
// ...
// Set up the connection.
var worker = new WorkerConnection();
// Query the cursor position.
var cursor = worker.RunRaw("Query(Cursor)"));
var cursorSplit = cursor.Split(' ');
var row = int.Parse(cursorSplit[0]);
var column = int.Parse(cursorSplit[1]);
// Move the cursor over one column, and down one row.
worker.RunRaw(string.Format("MoveCursor({0},{1})", row + 1, column + 1);
# PowerShell
# Load the x3270 interface DLL.
Add-Type -Path "C:\Program Files\x3270is\x3270is.dll"
# Set up the connection.
$worker = New-Object -TypeName X3270is.WorkerConnection
# Query the cursor position.
$cursor = $worker.RunRaw("Query(Cursor)")
$cursorSplit = $cursor.Split(" ")
$row = $cursorSplit[0] -as [int]
$column = $cursorSplit[1] -as [int]
# Move the cursor over one column, and down one row.
$worker.RunRaw([string]::Format("MoveCursor({0},{1})", $row + 1, $column + 1))
' VBScript
' Create the connection to the emulator.
set worker = CreateObject("X3270is.WorkerConnection")
' Query the cursor position.
cursor = worker.RunRaw("Query(Cursor)")
cursorSplit = Split(cursor, " ")
row = CInt(cursorSplit(0))
column = CInt(cursorSplit(1))
' Move the cursor over one column, and down one row.
r = worker.RunRaw("MoveCursor(" & CStr(row + 1) & "," & CStr(column + 1) & ")")
// JScript
// Create the connection to the emulator.
var worker = new ActiveXObject("X3270is.WorkerConnection");
// Query the cursor position.
var cursor = worker.RunJScriptArray("Query", new Array("Cursor"));
var cursorSplit = cursor.split(" ");
var row = parseInt(cursorSplit[0]);
var column = parseInt(cursorSplit[1]);
// Move the cursor over one column, and down one row.
worker.RunRaw("MoveCursor(" + (row + 1) + "," + (column + 1) + ")");
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Control characters in text. |
System.InvalidOperationException | Object in wrong state. |
X3270isActionException | Action failed: emulator returned an error. |
X3270isDisconnectException | Lost emulator connection. |
RunSafeArray(String, Object[])
Run an action, transparently formatting the arguments. For VBScript, which uses untyped (variant) arrays, and doesn't understand method overloading or variable/optional arguments, so it cannot use any of the forms of Run.
Declaration
[ComVisible(true)]
public string RunSafeArray(string action, object[] args)
Parameters
Type | Name | Description |
---|---|---|
System.String | action | Action name. |
System.Object[] | args | Action arguments. |
Returns
Type | Description |
---|---|
System.String | Result string, multiple lines separated by System.Environment.NewLine. |
Remarks
The emulator prompt is saved in StatusLine. Debug output (exact strings sent and received) is saved in DebugOutput.
Examples
' VBScript
' Create the connection to the emulator.
set worker = CreateObject("X3270is.WorkerConnection")
' Query the cursor position.
cursor = worker.RunSafeArray("Query", Array("Cursor"))
cursorSplit = Split(cursor, " ")
row = int(cursorSplit(0))
column = int(cursorSplit(1))
' Move the cursor over one column and down one row.
r = worker.RunSafeArray("MoveCursor", Array(row + 1, column + 1))
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Control characters in text. |
System.InvalidOperationException | Object in wrong state. |
X3270isActionException | Action failed: emulator returned an error. |
X3270isDisconnectException | Lost emulator connection. |
SetupEncoding()
Set up the encoding dynamically.
Declaration
protected void SetupEncoding()
SetupReaderWriter()
Set up the reader and writer.
Declaration
protected void SetupReaderWriter()