AMT Help Files

Using the ComScript Module

Shown below is a simple example of how to connect to an application and to run a Report of the application. The example is described in the languages VBScript and Powershell.

VBScript

Connect to the System Database by setting the ComScript module to use the correct AMT Environment, the Application to use and creating the connection.

ComScr.SysIniFile = "D:\Amt\AmtLionDoc\Sys.ini"
ComScr.AppName = "CUSTOMER_MANAGEMENT"
ComScr.Station = "NB1220"
ComScr.JobName = "Script Example"
     
Call ComScr.Connect

Create an Object of the Message Interface to be able to write log messages to the system database. The written messages will show in the Messages section of the Control and Application Center.

Set Msg = ComScr.CreateMessage()
Call Msg.AddMsgInformation("Connected.")

Create an object of the Job Interface to be able to run jobs of the application.

Set Job = ComScr.CreateJob()

Start the report CUSTOMER_LABELS.

Job.User = "PDV"
Job.UserGroup = "Admins"
Job.JobName = "Print_Customer_Labels"
Job.Wait = True
RequestId = Job.AddJobRequest("CUSTOMER_LABELS", 3)

Check if an error occurred and log if so.

If Job.ErrorCode <> 0 Then
    Call Msg.AddMsgInformation("ErrorCode is: " & Job.ErrorCode)
    Call Msg.AddMsgInformation("ErrorDescription is: " & Job.ErrorDescription)
Else
    Call Msg.AddMsgInformation("Printing Labels succeeded.")
End If

All the possible Objects, their properties, functions and procedures can be found in the other sections of
the ComScript Module (See 'See also').

Powershell

Connect to the System Database by setting the ComScript module to use the correct AMT Environment, the Application to use and creating the connection.

$ComScr.SysIniFile = "D:\Amt\AmtLionDoc\Sys.ini"
$ComScr.AppName = "CUSTOMER_MANAGEMENT"
$ComScr.Station = "NB1220"
$ComScr.JobName = "Script Example"

$ComScr.Connect()

 

Create an Object of the Message Interface to be able to write log messages to the system database. The written messages will show in the Messages section of the Control and Application Center.

$Msg = $ComScr.CreateMessage()
$Msg.AddMsgInformation("Connected.")

 

Create an object of the Job Interface to be able to run jobs of the application.

$Job = $ComScr.CreateJob()

 

Start the report CUSTOMER_LABELS.

$Job.User = "PDV"
$Job.UserGroup = "Admins"
$Job.JobName = "Print_Customer_Labels"
$Job.Wait = $true
$RequestId = $Job.AddJobRequest("CUSTOMER_LABELS", 3)

 

Check if an error occurred and log if so.

if ($Job.ErrorCode -ne 0) {
    $Msg.AddMsgInformation("ErrorCode is: " + $Job.ErrorCode)
    $Msg.AddMsgInformation("ErrorDescription is: " + $Job.ErrorDescription)
} else {
    $Msg.AddMsgInformation("Printing Labels succeeded.")
}

 

All the possible Objects, their properties, functions and procedures can be found in the other sections of
the ComScript Module (See 'See also').

C# (.NET)

Although the ComScript Module is meant to be used by scripts it can also be used in C# .NET programs. The examples shown are when used in a Console Program within the Main() method.

Apart from the reference to the module as described in Loading the ComScript Module, an object of the type ComScript has to be created first.

ComScript comScr = new ComScript();

 

Connect to the System Database by setting the ComScript module to use the correct AMT Environment, the Application to use and creating the connection.

comScr.SysIniFile = "D:\\Amt\\AmtLionDoc\\Sys.ini";
comScr.AppName = "CUSTOMER_MANAGEMENT";
comScr.Station = "NB1220";
comScr.JobName = "Script Example";

comScr.Connect();

 

Create an Object of the Message Interface to be able to write log messages to the system database. The written messages will show in the Messages section of the Control and Application Center.

Message msg = (Message)comScr.CreateMessage();
msg.AddMsgInformation("Connected.");

 

Create an object of the Job Interface to be able to run jobs of the application.

Job job = (Job)comScr.CreateJob();

 

Start the report CUSTOMER_LABELS.

job.User = "PDV";
job.UserGroup = "Admins";
job.JobName = "Print_Customer_Labels";
job.Wait = true;
int requestId = job.AddJobRequest("CUSTOMER_LABELS", 3);

 

Check if an error occurred and log if so.

if (job.ErrorCode != 0) {
    msg.AddMsgInformation("ErrorCode is: " + job.ErrorCode);
    msg.AddMsgInformation("ErrorDescription is: " + job.ErrorDescription);
} else {
    msg.AddMsgInformation("Printing Labels succeeded.");
}

 

All the possible Objects, their properties, functions and procedures can be found in the other sections of
the ComScript Module (See 'See also').