Hi, In CrBasic there is any way to pass a comport address as a parameter of a function like this
function (portCom , ...)
serialopen (portCom, ....)
do something...
serialclose(portCom)
endfunction
Most instructions can use a variable for the comport. I suggest declaring that variable as type Long. The comport names are predefined constants with integer values.
I try like this
Function RS232_measurement(Port_Com as Long) and Function RS232_measurement(Optional Port_Com as Long = 1)
SerialOpen (Port_Com ,9600,0,1000,100)
...
end function
But the Crbasic return ComPort 0 illegal, parameter must be a constant integer
The "SerialOpen" instruction will not allow a variable for the ComPort parameter. Extract from CRBasic Help for the ComPort parameter for SerialOpen for the CR1000X :-
Type: Constant. For all instructions except SerialOpen, this parameter can also be a variable.