AMT Help Files
Home AMT Admin Advanced Functions COM Module COM Connection Interface

COM Connection Interface

This section details the functions and properties of the Lion COM connection object. This object encapsulates the connection to AMT and the current screen (i.e. the last screen sent from the Application server to the client application).

Properties

Name Return type Access Description
ActiveFormName String Read/Write The name of the active form. If a new value is written; this will become the current active form and sent on the next transmit.
ApplicationName String Read The description of the application.
AverageResponseTime Integer Read The average response time of transactions.
Connected Boolean Read If set to "TRUE", the object is connected to the Application server.
Cursor String Read The name of the control item where the cursor is positioned.
DebugMode Boolean Read/Write Enables debug mode in the COM Module, which allows you to debug transactions from the COM Module in the AMT Debugger.
A username in the COM Module connection must be set with an identical username to the AMT Debugger username.
This property must be set before the OpenSession function is executed. The default value is false.
DefaultLanguage String Read The default language of the connected Application.
DisplayFieldCount Integer Read The number of layout controls of the current screen.
FieldCount Integer Read The number of fields of the current screen.
FilterHighlighters Boolean Read/Write Switch that determines whether the layout controls are returned with highlighters or not.
FormCount Integer Read The number of forms that the user can access by Page2Recall.
FormVersion String Read The form version.
GlobalError Boolean Read Will return True if error was set to True in the code of the application.
IgnoreReadOnly Boolean Read/Write If set to "True", ReadOnly status of controls will be ignored.
IPAddress String Read/Write The IP Address of the Application server or manager.
Language String Read/Write The value for SI-LANGUAGE.
LastError Responsecode Read The last error after executing a function.
ListCount Integer Read The number of listboxes of the current screen.
ListViewCount Integer Read The number of Listview controls on the current screen.
LogFileName String Read The name of the log file, if it is enabled.
LogLevel Loglevelcode Read/Write Contains the log level. 0 No logging, 1 Log errors, 2 Log all.
NoErrors Integer Read The number of errors in the error-buffer after a transaction.
PortNo Integer Read/Write The port number of the Application server or manager.
ResponseTime Integer Read The last response time of the screen transaction in milliseconds.
SaveSessionData Boolean Read/Write Controls if SessionData is saved or not saved by the Application server.
SparePort String Read/Write The port number of the Spare Application server or manager.
SpareServer String Read/Write The server name of the Spare Application server or manager.
StationName String Read Value that is stored in SI-INITIATOR.
StatusLine String Read The current status line.
Timeout Integer Read/Write The screen time-out in seconds. The default is 300 seconds.
UseAppManager Boolean Read/Write Use a manager or connect straight to the Application server (default is "FALSE").
Username String Read/Write The username of the client-connection. Default the Windows-user that uses the client program.
ZeroSuppress Boolean Read/Write If set to "True", numeric items will not have leading zeros.

Functions

Name Return type Parameters Description
Type Name
AssignStation Void String StationName Assigns the given station name to the Lion COM connection.
Clear Void - - Clears all fields of the current screen and all the cached screens.
CloseSession Void - - Closes the session to the Application server.
Commit Boolean - - Commits the open transactions of the Application server.
DisableLogging Void - - Disables the logging of transactions.
EnableLogging Boolean LogLevelCode LogLevel Enables the logging mechanism.
For the values of LogLevelCode, see COM Constants.
String FileName
   
FormName String Integer Index Returns the name of the screen that the user can call with Page2Recall. See also the FormCount property.
FormText String - - Returns all the field names and values as a single string separated by '@@'.
GetDisplayField Lion Field Object Integer Index Returns a display field given by index.
If no field is found, returns null.
GetError String Integer ErrorNo Gets the error message from the error message buffer of the given error number.
GetFieldbyIndex Lion Field Object Integer Index Returns the Lion Field object, asked by the index.
If no field is found, returns null.
GetFieldbyName Lion Field Object String FieldName Returns the Lion Field object, asked by field name.
If no field is found, returns null.
This function is for fields without occurrences. For fields with two dimension occurrences, both horizontal and vertical, use the function GetOccurrenceField. For fields with occurrences of a single dimension, use the function GetRepeatingField.
GetFieldValue String String FieldName Returns the value of the field given by field name.
GetListboxFile Lion List Object String Name This function can be used to get a Lion List object from a fillbox when there is no listbox is defined on the screen.
If no file is found, returns null.
The Name parameter is used to pass the Filename as set in your application. See: Fillbox.
GetListbyIndex Lion List Object Integer Index Returns the Lion List object, on index-basis. See also the ListCount property.
If no list field is found, returns null.
GetListbyName Lion List Object String ListName Gets the listbox contents of <List name>. The resulting object is a Lion List object. The field must be defined as Listbox or Combobox.
If no list field is found, returns null.
GetListViewbyIndex Lion Listview Object Integer Index Returns the Lion ListView object, on index-basis. See also the ListViewCount property.
If no listview field is found, returns null.
GetListViewbyName Lion Listview Object String ListViewName Gets the listview contents of <ListView name>. The resulting object is a Lion ListView object.
If no listview field is found, returns null.
GetOccurrenceField Lion Field Object String FieldName Returns the Lion Field of a copy-from part, given by the name of the field and both the Horizontal and vertical indexes of the occurrence.
If no field is found, returns null.
This function is for fields with two dimension occurrences, both horizontal and vertical. For fields with occurrences of a single dimension, use the function GetRepeatingField.
Integer IndexHorizontal
Integer IndexVertical
GetRepeatingField Lion Field Object String FieldName Returns the Lion Field of a copy-from part, given by the name of the field and the index the occurrence.
If no field is found, returns null.
This function is for fields with a single dimension occurrence, either horizontal or vertical. For fields with occurrences with two dimensions use the function GetOccurrenceField.
Integer Index
   
OpenSession ResponseCode - - Opens a session to the Application server.
Page2Recall Boolean String Formname Tries a page2recall from the specified form name. If this succeeds then the function returns "TRUE", otherwise it returns "FALSE".
Rollback Boolean - - Rolls back the updates of the Application server.
SetFieldValue Void String FieldName Sets the value of the field given by fieldname.
String Value
   
StartTransaction Boolean - - Starts a logical transaction on the Application server. NOTE: If you use this function, you have to commit or rollback the transaction yourself. Otherwise all records updated stay locked.
Transmit ResponseCode - - Transmits the current active form to the Application server.
VersionNumber String - - Returns the full AMT version number, including also the patch- and fix number.
WriteToLog Void String MsgText Writes the specified message to the log file of the Lion COM module.
XMLText String - - Create an XML version of the form (not supported).

Events

The "Lion COM connection Events" is an event interface, which means that the Lion COM connection can raise events.

Name Description
OnBye Event that is raised when the Application server executes RECALL(BYE). The connection with the Application server will be closed.
OnErrorResponse Event that is raised when somewhere an error occurs. The error message can be questioned with NoErrors and GetError.
OnFormResponse Event that is raised when the Application server returns its message to the COM module. All fields and listboxes are filled at that moment.
OnSessionClosed Event that is raised when the connection between the Application server and COM module is closed.

 

Example

PowerShell

# Import the COMModule
Add-Type -Path 'D:\AMT\AmtTools\ComModule\Asysco.Amt.LionCommodule.dll'

# Create an AmtComConnection object
$LionApp = New-Object Asysco.Amt.LionClient.ComModule.AmtLionComConnection

# The URL to connect to
$LionApp.IPAddress = 'NB1286'
$LionApp.PortNo = 40305
$LionApp.UseAppManager = $true
$LionApp.UserName = "AMT-User"

# Try to connect
if ($LionApp.OpenSession() -eq 1) {
   Write-Host 'Connected.'
} else {
   Write-Host 'Connection Failed.'
}


# Try to switch forms
if ($LionApp.Page2Recall('CUSTOMER') -ne 1) {
    write-host 'Form switch failed: '
    write-host $LionApp.GetError(0)
    $LionApp.CloseSession()
    Exit
}

# Create objects of form fields and set a value
$Customer_CustNO = $LionApp.GetFieldbyName('CUST-NO')
$Customer_CustNO.Value = Read-Host "Enter a customer number."

$Customer_ButtonAction = $LionApp.GetFieldbyName('BUTTON-ACTION')
$Customer_ButtonAction.Value = 'I'

# Transmit to send the values
$LionApp.Transmit()

# Evaluate result
if ($LionApp.StatusLine -ne 'INQUIRY REQUEST') {
    write-host $LionApp.StatusLine
} else {
    $Customer_FirstName = $LionApp.GetFieldbyIndex(1)
    $Customer_LastName = $LionApp.GetFieldbyIndex(2)
   
    Write-host "Customer: "$Customer_FirstName.Value $Customer_Lastname.Value
}

# Close the session
$LionApp.CloseSession()

Contents

 Go to top