ComScript Connection Interface
This section details the functions and properties of the AMT-COBOL ComScript connection object. This object encapsulates the connection to AMT-COBOL and the AMT-COBOL batch/script utilities. Objects for the other ComScript interfaces can be created, after first calling connect() , by using the corresponding Create<Object> function before they can be used.
Properties
Name | Type | Access | Description |
AppId | Integer | Read only | Returns the application ID. |
ApplicationKind | String | Read/Write | Sets the Application Kind of the Application to enable the correct specific behaviour. This property replaces the MainframeOS property. |
ApplicationPath | String | Read only | Returns the Basepath of the application the ComScript Module is connected to. |
AppName | String | Read/Write |
The name of the application the ComScript Module will connect to when executing the Connect function. Note: When using the Job Interface, the <ComsScript Object>.AppName and the <Job Object>.AppName should be set to the same value in order to run jobs of the correct application. |
BatchId | Integer | Read only | If the script is started from another script this property returns the JobId of the script that started this script. |
Connected | Boolean | Read only | Returns the value True when the ComScript Module is connected to an application and False otherwise. |
CurrentDateTime | DateTime | Read only | Returns the "current" date and time, being either the use date as configured in the system database, or the real current date if none is set. |
Development | Boolean | Read only | Returns True when development has been set in the Configuration set in the Control Center used for this application. |
Environment | String | Read only | Returns the Environment string of the Base setup of this environment as entered in the Control Center. |
ErrorCode | Integer | Read only | The error code after a comscript operation. Zero means no error occurred. |
ErrorDescription | String | Read only | The error description after a comscript operation. Ok in case no error occurred. |
ExtractPath | String | Read only | Returns the extract path as set for the connected application. |
JobId | Integer | Read only | Returns the JobId of this script as shown in the list of available Jobs in the Control Center. |
JobName | String | Read/Write | Can be set to a name describing the script. It will be used in messages as source of the message for logging. It can be read back for use in the script. |
LoggingPath | String | Read only | Returns the logging path as set for the connected application |
PrintPath | String | Read only | Returns the print path as set for the connected application |
ProcessId | Integer | Read only | Returns the Windows process number of the script engine this script runs in. |
ReportPath | String | Read only | Returns the report path as set for the connected application |
ScriptPath | String | Read only | Returns the script path as set for the connected application |
Station | String | Read/Write | This property can be set to a name describing the station this script is run from. It is used when writing messages to the logs and when starting jobs. It can be read back for use in this script. |
StealthMode | Boolean | Read/Write | When set to true, no registration of the initiating process in the session table (AmtSysSession) will be performed on a subsequent Connect. |
SysIniFile | String | Read/Write | Sets the Sys.ini file to use. This needs to be set before setting the Application name to connect to and before the call to the function Connect() is made in order to use the correct Environment. |
SystemPath | String | Read only | Returns the path of the root of this Environment as set in the Base path in the Control Center. |
User | String | Read/Write | The user name to use for this ComScript Session. Defaults to the Username of the owner of the process that runs the script but can be set differently. |
Functions
Function name | Return type | Parameters Name Type |
Description | |
AddDefaultBackupDir | Void | BackupDir | String | Sets the backup directory for the print commands to use for printing to the default PROUT printer. |
AddDefaultBanner | Void | BannerFile | String | Sets the Banner file to use in print commands for the default PROUT printer. Should be given as absolute path\filename and can be overwritten in the Job and Print class objects. |
AddDefaultFormId | Void | FormId | String | Sets the Form Id to use for print commands for the default PROUT printer. Can be overwritten in the Job and Print class objects. When set the print files will be placed in a subdirectory named <FormId> inside the prints directory. This setting is overwritten when a Backup directory is set. |
AddDefaultPrintSetting | Void | PrintFile | String | Sets the default print settings for the printer with PrintId PROUT. These settings will be used as defaults when a Print Object is created and can be overwritten inside the Print Object. |
Printer | String | |||
DonotPrint | Boolean | |||
NumberOfCopies | Integer | |||
PrintBanner | Boolean | |||
NoDateSubDirectory | Boolean | |||
CobolDeleteEnvironmentValues | Boolean | BatchId | Integer | Removes environment values in COBOL applications set in scripts for the batch/job with the given batch ID. |
CobolGetEnvironmentValue | Boolean | Name | String | Used for migrated Micro Focus COBOL applications. Gets the environment value by reference in a String object of the given environment name. Returns true when the environment name is found. |
Value | Ref String | |||
CobolSetEnvironmentValue | Void | Name | String | Used for migrated Micro Focus COBOL applications. Sets the environment value for the given environment name. |
Value | String | |||
Connect | Void | None | Connect to the System Database set in the Sys.ini file referred to in the SysIniFile property and retrieve information for the application set in the AppName and ApplicationKind Properties. | |
CountJobs | Integer | JobNameMask | String | Returns the number of jobs running with the specified Job Name Mask. Mask characters are a % for any character or any number of characters and a _ (underscore) for a single any character. |
CreateAmtEmail | AmtEmail Object | None | Returns an object of the AmtEmail interface. | |
CreateDatabase |
Database Object |
None | Returns an object of the Database interface. | |
CreateFileObject | FileObject Object | None | Returns an object of the FileObject interface. | |
CreateFtp | FTP Object | None | Returns an object of the Ftp interface. | |
CreateJob | Job Object | None | Returns an object of the Job interface. | |
CreateJobAlive | JobAlive Object | None | Returns an object of the JobAlive interface. | |
CreateMessage | Message Object | None | |
Returns an object of the Message interface. |
CreatePath | Path Object | None | Returns an object of the Path interface. | |
CreatePrint | Print Object | None | |
Returns an object of the Print interface. |
CreateRemoteDatabase | Database Object | AliasName | String | Returns an object of the Database interface for the given alias name of the remote database, as set in the control center. |
CreateSort | Sort Object | None | |
Returns an object of the Sort interface. |
DeleteRecoverableProcessJobs | Void | AppId | Integer |
Deletes either all recoverable jobs, or a specific recoverable job, for the specified job name. Set ProcessJobId = 0 to delete all recoverable jobs. |
JobName | String | |||
ProcessJobId | Integer | |||
Dispose | Void | None | Disposes of all the static variables held in memory inside the ComScript Module and cleans up the session in the AmtSysSession table. Also disconnects from the FileControler when a FileObject was created before. Should be used at the end of every script. |
|
FindFinishedJobById | Job Object | RequestId | Integer | Returns a Job Object for the specified Request Id if the job has finished. |
FindRunningJob | Job Object | JobName | String | Returns a Job Object for the first found running job with the name specified in JobName. All the Job Objects properties will be filled with the values of the given job. |
FindRunningJobById | Job Object | RequestId | Integer | Returns a Job Object for the job with the given RequestId. All the Job Objects properties will be filled with the values of the given job. |
GetDefaultBackupDir |
String |
None |
Returns the backup directory set to use for the print commands for the default PROUT printer. |
|
GetDefaultBanner |
String |
None |
Returns the Banner file set to use for the print commands for the default PROUT printer. |
|
GetDefaultFormId |
String |
None |
Returns the Form Id set to use for the print commands for the default PROUT printer. |
|
GetJobId | Integer | AppId | Integer | Returns the JobId as defined in the Control Center for the with the given AppId, JobName and JobType (0 unspecified, 1 Script, 2 Batch, 3 Report and 4 Executable). When no job with the given name is found -1 will be returned. |
JobName | String | |||
JobTypeNumber | Integer | |||
GetJobs | List of Job Objects | None | Returns a list of Job Objects including their state. Get a list of all reports/programs that were picked up by the BatchController with the states: running, waiting & queued. In essence all jobs which are not finished. A list of jobs that are queued to be processed by the BatchController can be gotten by using the GetQueuedJobs function. |
|
GetMySelf |
Job Object |
None |
Returns a Job Object for the running Script itself. |
|
GetQueuedJobs | List of Job Objects | None | Returns a list of Job Objects that are queued to be processed by the BatchController. A list of jobs that has been processed by the BatchController can be gotten by using the GetJobs function. | |
GetRecoverableProcessJobs | Integer Array | AppId | Integer | Returns an array containing the process job IDs of all recoverable jobs for the specified job name. |
JobName | String | |||
JobIdbyJobName | Integer | JobName | String | Returns the JobId as defined in the Control Center for the with the given JobName and JobType (0 unspecified, 1 Script, 2 Batch, 3 Report and 4 Executable). When no job with the given name is found -1 will be returned. |
JobType | Integer | |||
KillAll |
Integer |
ReportsOnly |
Boolean |
Create a request to kill all running jobs. When ReportsOnly is set to True only Reports will be killed, otherwise all jobs. Returned is the Id of the kill request. |
RemoveNonPrintedFiles | Void | BatchId | Integer | Removes all non-printed entries of the given batch id from the completed prints section in the control center. |
StopAll |
Integer |
ReportsOnly |
Boolean |
Create a request to stop all running jobs. The job will stop at the next sleep it encounters in the code. When ReportsOnly is set to True only Reports will be stopped, otherwise all jobs. Returned is the Id of the stop request. |
Before creating objects of other ComScipt interfaces (e.g. the message interface), a connection to the system database should be established using the Connect() function. |
Example
PowerShell
# First load the ComScript Module dll
Add-Type -Path 'D:\AMT\AmtTools\ComScript\ComScript.dll'
# Then create a ComScript Module object
$ComScr = New-Object Asysco.Amt.Scripting.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\Lion\Sys.ini"
$ComScr.AppName= "Test"
$ComScr.Station= "NB1128"
$ComScr.JobName= "ComScriptExample"
$ComScr.Connect()
if ($ComScr.Connected) {
Write-Host "Connected"
}else {
Write-Host "NOT Connected"
}
# Finally release the variables and clean up the session.
$ComScr.Dispose()