delsquaredb Posted June 16, 2009 Share Posted June 16, 2009 Hi, I'm having difficulty passing the correct data type to a function. I want to pass an element in an array to the LJ eput function like so: deviceArr = {3, 7, 3, 4} index = 2 ePut(deviceArr[deviceArr[index], ...) when I do this I get the error: D0050:99:3004 LabJack: ID must be a scalar value, not an array or a string: Line 6 In C device[index] would be an int or whatever the data type of the array is but this seems not to be the case in daqfactory. How do I ensure that a scalar gets passed in? Thanks for the help. Link to comment Share on other sites More sharing options...
AzeoTech Posted June 16, 2009 Share Posted June 16, 2009 Actually, that is the case with DAQFactory. However, you are double indexing, and you forgot the closing ]. I think you want: ePut(deviceArr[index],....) Link to comment Share on other sites More sharing options...
delsquaredb Posted June 16, 2009 Author Share Posted June 16, 2009 Sorry for the typo, I meant it as you said: ePut(deviceArr[index],...) but, this still doesn't seem to work. I also added a typecast ePut((int)deviceArr[index],...) still no luck. Any Ideas? Link to comment Share on other sites More sharing options...
delsquaredb Posted June 16, 2009 Author Share Posted June 16, 2009 Yes that was just a typo. I think i've got my problem figured out though, I guess it was a scope problem. I was using a "Define" in a user device that i defined elsewhere. I guess that doesn't work. Oops. Thanks. Link to comment Share on other sites More sharing options...
AzeoTech Posted June 16, 2009 Share Posted June 16, 2009 OK: 1) DAQFactory only has two types: numbers (double precision float) and strings. There is no "int" or anything like C, so type casting doesn't really apply. If you need to convert from a string to a number, use the strtodouble() function, and correspondingly the other way, use doubletostr() or format(). 2) Define's should probably be in a startup sequence. You don't know when a user device is going to get called. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.