Methods
-
Func Environ( iEnvString) As
-
Returns the value of an environment variable.
- Parameters:
-
- iEnvString
- The name of the environment variable
- Example:
-
This example retrieves the value of the PATH variable
in the Value string.
Value = CATIA.SystemService.Environ("PATH")
dd>
Func Evaluate( iScriptText, iLanguage, iFunctionName, iParameters) As
Evaluates a scripted function.
- Parameters:
-
- iScriptText
- The program text
dd>
- iLanguage
- The language the program is written in
dd>
- iFunctionName
- The name of the function to invoke
dd>
- iParameters
- An array of parameters for the function
dd>
- oResult
- The value returned by the function (if any)
- Example:
-
This example executes the function CATMain from the CodeToEvaluate string
Dim params()
Dim codeToEvaluate
CodeToEvaluate = "Sub CATMain()" & vbNewLine & _
"MsgBox " & chr(34) & "Hello World" & chr(34) & vbNewLine & _
"End Sub"
CATIA.SystemService.Evaluate CodeToEvaluate, CATVBScriptLanguage, "CATMain", params
dd>
Func ExecuteBackgroundProcessus( iExecutablePath) As
Executes an asynchronous process. This process is launched in background and
ExecuteBackgroundProcess doesn't wait for it to complete.
If the executable to run needs a specific environment to works correctly (for example
environment variables like PATH or LD_LIBRARY_PATH correctly set), this environment must
have been set in order to make this method succeed. If this executable needs to be launched
from a window, this method will fail.
- Parameters:
-
- iExecutablePath
- The path of the executable to run and its arguments
If the executable is not present in the PATH environment variable, you must specify its
complete absolute path. If this path contains blanks, you must enclose it with the simple
quote character ''' :
for example CATIA.SystemService.ExecuteBackgroundProcess "'C:\Program Files\myApp\myApp.exe' myArg".
dd>
- Returns:
- Non significative return code. It's never the asynchronous process return code
Example:
This example executes the command located at
and doesn't wait the end of its execution.
CATIA.SystemService.ExecuteBackgroundProcessus ""
dd>
Func ExecuteProcessus( iExecutablePath) As
Executes a synchronous process. If this process is succesfully launched,
ExecuteProcessus waits for it to terminate and returns the process return code.
If the executable to run needs a specific environment to works correctly (for example
environment variables like PATH or LD_LIBRARY_PATH correctly set), this environment must
have been set in order to make this method succeed. If this executable needs to be launched
from a window, this method will fail.
- Parameters:
-
- iExecutablePath
- The path of the executable to run and its arguments.
If the executable is not present in the PATH environment variable, you must specify its complete absolute path.
If this executable path contains blanks, you must enclose it with the simple quote character ''' to allow the implementation to follow the whole line to the MS call (otherwise only the last part will be sent to the MS call) :
Additionally, arguments with blank must be enclosed in double quote in Microsoft call (do not forget to espace double quote in VBA, with another double quote).
for example CATIA.SystemService.ExecuteProcessus("'""C:\Program Files\myApp\myApp.exe""' myArg1 '""myAr g2""'")
will start the command line "C:\Program Files\myApp\myApp.exe" myArg1 "myAr g2" on Microsoft OS.
On Windows, to run a batch file you must execute the command interpreter :
set the executable to cmd.exe
set the arguments to the following ones : /c plus the name of the batch file.
For example CATIA.SystemService.ExecuteProcessus "cmd.exe /c E:\MyBatchFile.bat"
On Windows, an argument that contains a blank must be doubly enclosed ; first with the single quote character then,
inside the single enclosing quote, with the double quote character.
For example CATIA.SystemService.ExecuteProcessus "cmd.exe /c '" & Chr$(34) & "E:\My Bat File.bat" & Chr$(34) & "'"
dd>
- Returns:
- The synchronous process return code
Example:
This example executes the command located at
waits for it to end, and returns its return code.
ReturnCode = CATIA.SystemService.ExecuteProcessus("")
dd>
Func ExecuteScript( iLibraryName, iType, iProgramName, iFunctionName, iParameters) As
Executes a scripted function.
- Parameters:
-
- iLibraryName
- The library in which the script is contained
dd>
- iLibraryType
- The type of the library
dd>
- iProgramName
- The name of the program in the library
dd>
- iFunctionName
- The name of the function to invoke
dd>
- iParameters
- An array of parameters for the function
dd>
- oResult
- The value returned by the function (if any)
- Example:
-
This example executes the function CATMain in the program Macro1.catvbs contained by Part1.CATPart
Dim params()
CATIA.SystemService.ExecuteScript"Part1.CATPart", catScriptLibraryTypeDocument, "Macro1.catvbs", "CATMain", params
dd>
Sub Print( iString)
Prints a string on stdout.
- Parameters:
-
- iString
- The string to print
- Example:
-
This example prints the string "Hello world!".
CATIA.SystemService.Print("Hello world!")
dd>