System Services Functions

This page discusses:

DebuggerBreak

Function used to stop the debugger

Signature

DebuggerBreak()

DisableErrors

Function used to deactivate all the script lines following errors. Errors that occur in an EKL script after you called DisableErrors is stored in a list.

Signature

DisableErrors([iDisableErrors : Boolean, iDisableWarnings : Boolean, iDisableInformations : Boolean])

Arguments

Name Input / Output Required? Type Comment
iDisableErrors In No Boolean Let you disable information messages only.
iDisableWarnings In No Boolean Let you disable warning messages only.
iDisableInformations In No Boolean Let you disable error messages only.

Example

let resourceToFind(Feature)
let resourceName(String)
let listOfErrors(List)
[…]
DisableErrors()
resourceToFind = AccessResource(resourceName, "Feature")
listOfErrors = EnableErrors()

if resourceToFind == NULL
{
                /* Treat the case where the resource was not found */
                […]
}

EnableErrors

Function used to re-activate errors and retrieve those that occurred after you called DisableErrors. It returns a list containing EvaluationError objects corresponding to the errors raised by DisableErrors.

Signature

EnableErrors() : List

ReturnType

List

Example

let resourceToFind(Feature)
let resourceName(String)
let listOfErrors(List)
[…]
DisableErrors()
resourceToFind = AccessResource(resourceName, "Feature")
listOfErrors = EnableErrors()

if resourceToFind == NULL
{
                /* Treat the case where the resource was not found */
                […]
}

GetSystemInfo

Lets you display information related to the execution environment of an EKL script thus enabling the generation of accurate reports.

Signature

GetSystemInfo(iInfoName : String) : String

Arguments

Name Input / Output Required? Type Comment
iInfoName In Yes String -

ReturnType

String

The function returns the following information:

iName Returned information
HostName Name of the computer on which the script is executed
UserName Name of the user currently logged
CATIAVersion Used version of CATIA
OSName Name of the current computer’s operating system
OSVersion Version of the current computer’s operating system
ServerURL URL of the currently connected server
CurrentTime Current time of the execution computer

Example

Notify("User: #",GetSystemInfo("UserName"))
Notify("Current host: #",GetSystemInfo("HostName"))
Notify("OS: # - version #", GetSystemInfo("OSName"), GetSystemInfo("OSVersion"))
Notify("CATIA Version: #", GetSystemInfo("CATIAVersion"))
Notify("Connected Server : #",GetSystemInfo("ServerURL"))
Notify("Current Time : #",GetSystemInfo("CurrentTime"))

The result of the above example is the following:

IsSet

Lets you check if an EKL variable is set or lets you unset it. This function is especially useful in KML or in reusable functions.

Signature

IsSet(iParamToCheck : ObjectType) : Boolean
Note: This function lets you check if the input value is set.
Unset(iParamToCheck : ObjectType) : Boolean
Note: This function lets you unset the given value.

Arguments

Name Input / Output Required? Type Comment
iParamToCheck In Yes ObjectType -

ReturnType

Boolean

Example

  1. Create a knowledge action.
  2. Enter the following script:
    Let a(Integer)
    a = 10
    if IsSet(a) == TRUE
    {
    	Unset(a)
    	If IsSet(a) == FALSE
    	{
    		Message("OK")
       }
    }
  3. Execute the action and check that it displays "OK".

OpenTextFile

This function is used to open, close, and write in a text file and read a text file.

Signature

OpenTextFile(TextFilePath : String, TextFileMode : String) : TextFile

Arguments

Name Input / Output Required? Type Comment
TextFilePath In Yes String Physical path of the file on disk.
TextFileMode In Yes String Three different possible modes:
  • w to write in the file and to create it if it does not exist.
  • a to add text at the end of the file.
  • r to read the file.

ReturnType

TextFile

Example 1: Open Function

To open a file in write mode:

let file (TextFile)
set file = OpenTextFile("e:\tmp\TextFile1.txt","w")

To add lines at the end of the file:

set file = OpenTextFile("e:\tmp\TextFile1.txt","a")

To read a file:

set file = OpenTextFile("e:\tmp\TextFile1.txt","r")

Example 2: Close Function

This function lets you close a text file. It must be called at the end of the execution to free the memory.

let file (TextFile)
set file = OpenTextFile("e:\tmp\TextFile1.txt","w")
...
file->Close()

Example 3: Write Function

This function lets you write in a text file. It replaces the whole text in the file if it was opened in “w” mode; Or it adds the string at the end of the file if it was opened in “a” mode.

let file (TextFile)
let buffer (String)
set file = OpenTextFile("e:\tmp\TextFile1.txt","w")
buffer = "Hello" 
file->Write(buffer)

The function can also use a given format to write parameters values in the file. In this case, it has two input arguments: the format string and a list of parameters. The convention is “#” for a parameter value and “|” for a line feed. All parameter types are allowed. One writes the unit if any.
let parms (List)
parms.Append(` Representation316411704 --- IN_WORK\Integer.1` )
parms.Append(` Representation316411704 --- IN_WORK\Real.1` )
parms.Append(` Representation316411704 --- IN_WORK\String.1` )
parms.Append(` Representation316411704 --- IN_WORK\Length.1` )

set file = OpenTextFile("e:\tmp\TextFile1.txt","w")
buffer = "Integer = # Real = # |String = #|Length = #" 
file->Write(buffer,parms)

/*Then the text file will contain the values of the parameters with the unit:*/

Integer = 5 Real = 10.23
String = Hello
Length = 22mm

Example 4: Read Function

This function lets you read in a text file.

let file (TextFile)
let buffer (String)
set file = OpenTextFile("e:\tmp\TextFile1.txt","r")
set buffer = file->Read()

SessionUniqueIndex

Function used to generate an index in EKL. When executing a script, a unique index is required to name a feature for example. The function returns a unique index for each value of iIndexIdentifier, starting at value 1. The value of the index is incremented at each call.

Signature

SessionUniqueIndex(iIdentifier : String) : Integer

Arguments

Name Input / Output Required? Type Comment
iIdentifier In Yes String

ReturnType

Integer

clock

This function returns the processor time consumed by the program. To compute the processing time of a program, the value returned by clock must be compared to a value returned by a previous call to the same function.

Signature

clock() : Integer

ReturnType

Integer

Example

let tic, tac (integer)
tic = clock()
let i (integer)
i = 1
for i while i <= 55555
{
	i = i + 1
}
tac = clock()
Notify("It took me # milliseconds to run this script.", tac-tic)