DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

call DIAdem custom function from Labview

Hello,

 

In Labview 8.6, I would like to call custom function "myFunction" developped in a DIAdem script.

 

I use Call ScriptCmdAdd(autoactpath & "Fonctions.vbs") where myFunction is in Fonction.vbs (myFunction become red in DIAdem, so recognise. It works inside DIAdem)

Then I use in Labview RunAutomationCommand.vi(MyFunction as parameter), but I get the undefined command "MyFunction" message error.

 

Is it possible to call specific custom DIAdem function from LV? How ? What I am doing wrong ?

 

Thanks in advance.

 

0 Kudos
Message 1 of 2
(3,897 Views)

Hi bull balls,

 

The trick here is that the DIAdem ActiveX servers require you to use "Autosequence" calling syntax, not VBScript calling syntax.  The way to call a VBScript UserFunction in an Autosequence is with the command "ScriptEvaluate".  Note that Autosequences can not pass parameters to functions, so your "MyFunction" UserFunction will need to rely exclusively on DIAdem global variables, file i/o, environment variables, etc. for information passing.  In the (LV 8.5.1) example I'm attaching I use DIAdem global variables because it's the easiest method.  Autosequence syntax also uses single quotes and ":=", so there are a number of places to stumble here.  I added the following "MyFunction" as a UserCommand in DIAdem:

 

Function MyFunction()

R1 = 3.141596

MyFunction = "Hello"

End Function ' MyFunction()

 

then called it in LabVIEW using the following string command passed to the "DIAdem Run Automation Command.vi":

 

T1:= ScriptEvaluate('MyFunction')

 

The "T1:=" assignment is NOT optional, although you can use any other DIAdem global string variable if you prefer.

 

Brad Turpin
DIAdem Product Support Engineer
National Instruments

 

0 Kudos
Message 2 of 2
(3,886 Views)