DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot use Val function in a DataPlugin script

Solved!
Go to solution

I am trying to convert a text string (a binary number) into a number using the Val function in a DataPlugin script but DIAdem colors the Val term in red and the script produces an error stating "Variable is undefined: 'Val'"

 

Why is this occuring? Are certain functions not allowed in DataPlugin scripts?

 

Also, I seem unable to use debugging in my DataPlugin - if I try to add a variable to the Watch window, it never has any value even if I set a breakpoint on that line of the code. Should it be possible to debug DataPlugin scripts?

0 Kudos
Message 1 of 4
(4,225 Views)

The Val function is a DIAdem function and does not belong to VBS functions in general. As DataPlugins can be used with several NI products, it is not possible to use functions offered only by DIAdem in DataPlugins, e.g. LabVIEW does not offer this functions but your DataPlugin will work with LabVIEW as well as with DIAdem.

Maybe functions like CDbl or CLng can help you to convert your string into a number.

 

Debugging DataPlugins is a little bit tricky but possible. Here you can find some instructions how to debug DataPlugins:

http://digital.ni.com/public.nsf/allkb/C29CBAF07DB2B93786256F09002FE35B

 

0 Kudos
Message 2 of 4
(4,217 Views)
Solution
Accepted by topic author David Samuel

David,

 

regarding your question on "Val" I'd like to point you to the "File.Formatter.ParseString" function which is part of the API available to DataPlugins.

CDbl and CLng do a good job in general, but they are dependent of the locale settings of the PC. So "ParseString" is definitely more reliable.

 

Andreas

0 Kudos
Message 3 of 4
(4,195 Views)

Thanks Andreas - this seems like what I am after, so now I can force the data type to be whatever I want from the selections available.

0 Kudos
Message 4 of 4
(4,188 Views)