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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.