Options
Referencing device via variable
Currently I have a button event with a line of code like this:
Is it possible to call the device (dvScaler) as a variable (I know it's a device variable, but I'd like to reference it by char)
Note, this does compile, but throws a warning about char to integer, but will not execute properly
SEND_STRING dvScaler, "StringtoSend"
Is it possible to call the device (dvScaler) as a variable (I know it's a device variable, but I'd like to reference it by char)
dvScaler = 5001:6:1 CHAR cDeviceName = 'dvScaler' SEND_STRING cDeviceName, "StringtoSend"
Note, this does compile, but throws a warning about char to integer, but will not execute properly
Comments
What could you possibly gain if you could do this?
That should not compile, in my opinion. You are violating type rules -- twice.
First, you are trying to assign a character variable as if it were an array. Probably what you want to do is:
define_variable
CHAR cDeviceName[] = 'dvScaler'
That will remove the warning that you are seeing, but it will throw another when you get to your send_string because it is expecting a structure of type device and you are giving it an array of type character. I don't know why the compiler doesn't choke and puke at this. I can only assume that there is some allowance for old Axcess code where there was no type device and the compiler was expecting a single byte integer.
The moral of this story is that you have to obey typing rules if you are going to get the system to do what you want. send_string and send_command expect an argument of type device so that's what you must give. You can name the variable anything you want, but it must be of type device which is a structure with a device number, port, and system -- all integers.
If you want your send_string to work as written, try this instead:
assuming that "stringtosend" works out to be some string.
It'd just be nice to have access to that while in NetLinx:
In Telnet: In NetLinx: