DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Script error when starting it using ActiveX API

Solved!
Go to solution

Hello,

 

I try to start DIADEM from C# application and clear the Data Portal.

 

This is the code I'm using in C# :

 

diadem.CmdExecuteSync("wndshow('shell','normal')");
diadem.CmdExecuteSync("ScriptStart('g:\\Build\\script2.VBS')");

 

The first command is ok, DIAdem is displayed.

The second one doesn't work, the following error occurs :

Error in <script2.VBS> (line: 1, Column: 1); Invalid character

 

I don't understand why because when I run it directly in DIAdem, the same script works.

Does someone have any idea about what's wrong ?

 

Maybe there is an other solution to do it.

 

What I want to do is to clear automatically the data portal when starting DIAdem.

For me it's stupid to display example data in the data portal each time the software is started.

I think NI should change that.

 

Thanks for the response.

 

CFOE

0 Kudos
Message 1 of 6
(6,487 Views)

Hello CFOE,

 

There is a much easier solution to this task:

 

In the NAVIGATOR go to the "Settings > Options > NAVIGATOR" menu.

Config.jpg

 

In the dialog that will appear, DELETE the file name "Example.TDM" from the "Default file" box and close the dialog with "OK".

NAVI.jpg

 

Next, go the the "Settings > Options > Save As ..." dialog.

Save Conf.jpg

 

Use the name "Desktop.DDD" to save the file. That's the default configuration file for DIAdem, and the next time you start DIAdem the NAVIGATOR will be empty since you have removed the "Example.TDM" file from the NAVIGATOR settings.

 

That is much easier than deleting things with a Script after DIAdem has already started.

 

Let me know if you have any additional questions,

 

     Otmar

Otmar D. Foehner
Message 2 of 6
(6,481 Views)

Hi CFOE,

 

Why does your path have "\\" characters in it instead of the more usual "\" character?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 3 of 6
(6,468 Views)

Hello Otmar,

 

The solution you to suggest is quite easy of course but it means that I have to modify manually the settings.

Where are currently developping a software that will be associated to DIAdem and it should be interesting for me to do it by script.

DIAdem is started by our software and the main reason to script the clear is that when i automates the mechanism, i'm sure that the first data that will be automatically loaded with my dataplugin are in an empty data portal.

 

Your method is interesting for a first step but when we install our software on many computers, it means that for each DIAdem we have to modify manually the properties. Futhermore I don't understand why my script doesn't works although it works in DIAdem.

 

Thanks for the help,

 

CFOE

0 Kudos
Message 4 of 6
(6,440 Views)

Hello Brad,

 

In .NET the '\' is an escape character so if i use it in a path i need to double the '\' and write it like this '\\'.

In C#, i can write it like this too diadem.CmdExecuteSync(@"ScriptStart('g:\Build\script2.VBS')");.

The '@' indicates that the following string is a path and each '\' should be understand like '\\'.

 

Futhermore the problem is not finding the script but executing it.

 

CFOE

0 Kudos
Message 5 of 6
(6,436 Views)
Solution
Accepted by topic author cfoe

Hi CFOE,

 

Many of our users and all of our sales engineers appreciate having an example data set to quickly show/try DIAdem features with.

 

If all you want to do is clear the Data Portal programmatically, you should be able to do that by passing just one command directly in the argument:

 

diadem.CmdExecuteSync("DataDelAll");

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 6 of 6
(6,359 Views)