CitectVBA Programming Reference > CitectVBA Function Reference > Procedural Statements > CicodeCallOpen

CicodeCallOpen

The CicodeCallOpen function is used to call a Cicode function from CitectVBA. It is used to initiate and execute a call to the Cicode function and returns an integer value representing either an error code or the success of this CitectVBA function making the call.

Note: This CitectVBA function does not return the actual return-value of the Cicode function being called. You can obtain that return value by using the associated CicodeCallReturn function.

UNINTENDED EQUIPMENT OPERATION

Do not nest the CicodeCallOpen and CicodeCallReturn functions. Nesting these functions can lead to unintended equipment operation when your program is run.

Failure to follow these instructions can result in death, serious injury, or equipment damage.

For details, see Calling Cicode from CitectVBA.

Syntax

ReturnValue = CicodeCallOpen(FunctName, ArgList)

ReturnValue:

The return value for the function in the range of 0 to 3.

FunctName:

The name of the Cicode function being called.

Arglist:

A variable length comma separated argument list of all the arguments to be passed to the Cicode function being opened (dependant upon which Cicode function is being called and the arguments that Cicode function requires). The argument list should not be enclosed within brackets, although when using variable names as arguments, those variable arguments within the list need to be individually enclosed within brackets to force the passing of the variable to Cicode by value.

Return Value

CicodeCallOpen returns a integer data type containing a value in the range of 0 to 3:

Related Functions

CicodeCallReturn

Example

In the following example, a CitectVBA variable is enclosed in brackets to force the passing of the variable by value. See Passing variables Byref and Byval.

Dim vntRet as Variant
' declare modular variant variable to store function results
Function TestCicode() As Integer
' declare local variables
Dim intRet As Integer
Dim strReply as String
Dim intMaxScale as Integer
' copy current tag value to variable
' uses the project variable tag named MAX_SCALE
intMaxScale = MAX_SCALE
' call Cicode function
' for example: TrnSetScale( AN, Pen, Percent, Scale)
intRet = CicodeCallOpen( "TrnSetScale", 53, -1, 100, (IntMaxScale) )
' Note the syntax used:
' - brackets around the CitectVBA function argument list.
' (This is only necessary when the CitectVBA function is preceded by an equals (=) sign .)
' - double quotes around the Cicode function name
' - no brackets around the Cicode function argument list
' - brackets around individual variable arguments
' test results
If intRet = 0 Then
'
' insert code for successful completion here
'
vntRet = CicodeCallReturn()
strReply = "CicodeCallOpen Function successfully called"
Else
'
' insert code for unsuccessful completion here
'
Select Case intRet
Case = 1
' assign return comment for this case
strReply = "CicodeCallOpen Function call error (unsuccessful)"
Case = 2
' assign return comment for this case
strReply = "Cicode Function not found"
Case = 3
' assign return comment for this case
strReply = "Wrong number of arguments "_
& "in Cicode CallOpen function call"
Case Else
' assign return comment for this case
strReply = "Unknown error"
End Select
End If
' display return comment for your information
MsgBox strReply
' assign return value for this function
TestCicode = intRet
End Function