DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Why Doesn't "find" work in VBS?

I'm trying to write a VBS module that will
detect when the data in a channel crosses
some threshold. As an example, I include
a line to check when channel 56 becomes
greater than 5.0

Here is the VBS line that checks for this:

FirstValue = find( Ch(56) > 5.0, 1 )

When ever I execute this script, DIAdem displays
an error dialog with this message:

Error in (Row:52, Column:9):

Error message from DIAdem OCMD-interface:

Invalid return value of the DIAdem kernel !

What does this mean? Why doesn't the "find" function
work? What other means can I use to do this operation?
0 Kudos
Message 1 of 2
(4,144 Views)
Hi jbrandim,

The first parameter in the find() function is a string, so when you use this function with VBS syntax, you need to enclose it in double quotes:

FirstValue = find("Ch(56) > 5.0", 1)

Additionally, you can also call this function as a Formula Calculator function, since it is in fact a DIAdem function and not a VBS function:

Call FormulaCalc("L1:= find(Ch(56) > 5.0, 1)")
FirstValue = L1

The cryptic error message is an artifact of the translation process between VBScript and the DIAdem find function. DIAdem automatically maps the return value of the find function, which is an integer, to the variant variable "FirstValue", as well as the input parameters. The mapping process from Variant to string in the first find() parameter failed, and
that led to the error message you received.
0 Kudos
Message 2 of 2
(4,144 Views)