BASIC Moves Development Studio
06/2005
Danaher Motion
42 Rev
E
M-SS-005-03l
Example of calling a C-function from MC-Basic:
Dim shared Str2global as string
Dim shared Str1global as string
Dim shared LongArray[100] as long
Dim shared d1 as double
program
' Use OLOAD to load the object file before loading the program
' that uses the C-Functions
' /* No Parameters */
' int CFUNC_LV(void)
?CFUNC_LV()
' double CFUNC_DV(double)
?CFUNC_DRD(1.2345)
' /* returns string */
char* CFUNC_SV(void)
?CFUNC_SV()
' /* No Parameters, not return value */
' void CFUNC_VV(void)
CFUNC_VV()
' /* Strings */
' char* CFUNC_SS(char* S)
Str2global=CFUNC_SS(Str1global)
' /* Arrays */
' double CFUNC_LARD(long *l);
d1=
cFunc_LARD(LongArray)
end program
Example of PROTO.PRO:
'No Parametrs
import_c CFUNC_LV() As Long
import_c CFUNC_DV() As Double
import_c CFUNC_SV() As String
import_c CFUNC_VV()
'A Single "By Value" Parameter
import_c CFUNC_LL(ByVal As Long) As Long
import_c CFUNC_DD(ByVal As Double) As Double
import_c CFUNC_SS(ByVal As String) As String
'A Single "By Reference" Parameter
import_c CFUNC_LRL(As Long) As Long
import_c CFUNC_DRD(As Double) As Double
import_c CFUNC_SRS(As String) As String
'Multiple "By Value" Parametrs
import_c CFUNC_LVALP(ByVal As double, ByVal As Long, ByVal As
String) As Long
import_c CFUNC_VVALP(ByVal As String, ByVal As double, ByVal AS
Long)
'Multiple "By Reference" Parameters
import_c CFUNC_DREFP(As String, As Long, As Double) As Double
import_c CFUNC_VREFP(As Long, As Double, As String)
' Mixed Parameters
import_c CFUNC_VMIXP(ByVal As Long,As Double,ByVal As String,As
String,As Long,ByVal As double) AS Long