This section describes the functions and properties of the Lion COM connection object. This object encapsulates the connection to AMT and the current screen, which is the last screen sent from the application server to the client application.
| Name | Return type | Access | Description |
|---|---|---|---|
| ActiveFormName | String | Read/Write | Name of the active form. If you write a new value, it becomes the active form and is 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. The user name in the COM module connection must match the AMT debugger user name. Set this property before OpenSession 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 | Returns true if ERROR was set to true in the application code. |
| IgnoreReadOnly | Boolean | Read/Write | If set to "True", the ReadOnly status of controls is 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 whether SessionData is 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 timeout in seconds. The default is 300 seconds. |
| UseAppManager | Boolean | Read/Write | Use a manager or connect directly to the application server (default is "FALSE"). |
| Username | String | Read/Write | The user name of the client connection. The default is the Windows user who runs the client program. |
| ZeroSuppress | Boolean | Read/Write | If set to "True", numeric items do not include leading zeros. |
| 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 on 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 by index. If no field is found, returns null. |
| GetFieldbyName | Lion Field Object | String | FieldName |
Returns the Lion Field object by field name. If no field is found, returns null. This function is for fields without occurrences. For fields with two-dimensional occurrences, both horizontal and vertical, use the function GetOccurrenceField. For fields with single-dimensional occurrences, 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 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 by index. 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 by index. 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-dimensional 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 field name and the occurrence index. If no field is found, returns null. This function is for fields with a single-dimensional occurrence, either horizontal or vertical. For fields with two-dimensional occurrences, use the function GetOccurrenceField. |
| Integer | Index | |||
| OpenSession | ResponseCode | - | - | Opens a session to the application server. |
| Page2Recall | Boolean | String | Formname | Tries a Page2Recall for the specified form name. If successful, the function returns "TRUE"; otherwise, it returns "FALSE". |
| Rollback | Boolean | - | - | Rolls back updates on the application server. |
| SetFieldValue | Void | String | FieldName | Sets the value of the field specified by field name. |
| String | Value | |||
| StartTransaction | Boolean | - | - | Starts a logical transaction on the application server. Note: if you use this function, you must commit or roll back the transaction yourself. Otherwise, updated records remain locked. |
| Transmit | ResponseCode | - | - | Transmits the current active form to the application server. |
| VersionNumber | String | - | - | Returns the full AMT version number, including the patch and fix numbers. |
| WriteToLog | Void | String | MsgText | Writes the specified message to the log file of the Lion COM module. |
| XMLText | String | - | - | Creates an XML version of the form (not supported). |
The Lion COM connection events are exposed as an event interface, which means that the Lion COM connection can raise events.
| Name | Description |
|---|---|
| OnBye | Event raised when the application server executes RECALL(BYE). The connection to the application server is then closed. |
| OnErrorResponse | Event raised when an error occurs. You can query the error message by using NoErrors and GetError. |
| OnFormResponse | Event raised when the application server returns its message to the COM module. At that time, all fields and listboxes are filled. |
| OnSessionClosed | Event raised when the connection between the application server and COM module is closed. |
# Import the COM module
Add-Type -Path 'D:\AMT\AmtTools\ComModule\Asysco.Amt.LionCommodule.dll'
# Create an AmtComConnection object
$LionApp = New-Object Asysco.Amt.LionClient.ComModule.AmtLionComConnection
# Configure the connection
$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()