AscA not working as expected in execute()

Recommended Posts

Manually entering


works (it pushes all the ASCII codes in as consecutive channel points), but if I place it in an execute(), it seems to build the script string with only the ASCII value for the first character, rather than AscA(strArg) evaluating to a numeric array (as if I used Asc())

execute(ChannelName + ".Addvalue(" + AscA(strArg) + ")")

Evaluate does the same thing -- treats the AscA() as if the string were only one character.

Link to comment
Share on other sites

Actually the problem isn't with asca().  The problem is that string concatenation doesn't support arrays.  So even:

? "array: " + {1,2,3} + " end array"

will print:

array: 1 end array

The problem is that DAQFactory doesn't really know how you want to present the array.  Do you want a comma delimited list?  With brackets or without?  Space after the comma?  Etc.  Plus, beginners often really only want [0], especially when using channels, but forget to do so.  So:

"My Value: " + myChannel

will do the same as:

"My Value: " + myChannel[0]

So, in your case, what you really need to do is keep the asca() in the quotes:

execute(ChannelName + ".AddValue(asca(" + strArg + "))")

that way the concatenation doesn't involve the array.  

But then, why are you pulling out strArg anyway?  Remember, execute() runs in the scope of the call script, so you should be able to reference strArg from within the string:

execute(ChannelName = ".AddValue(asca(strArg))")


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.