DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptCMDReset

Hello all!

 

A question about the command ScriptCMDReset.

If I use it at the beginning of the script, it should reset all global variables which were defined during current DIADEM session. Then it should be able to declare new global variables, or "re-declare" the old some.


In DIADEM 2011 it worked in this way. In 2012 the same command resets also the variables declared after the command.

Call ScriptCMDReset()
Call GlobalDim("MyTime")
MyTime = "today"

The goal is to use the variable "MyTime" in a comment box in the REPORT.

Without the first line it runs successful. But for the case I have many such variables, it would be necessary to reset they all...

 

Does anybody know the solution?

0 Kudos
Message 1 of 4
(5,966 Views)

Hi Dia,

 

I've recently seen evidence that the ScriptCmdReset command executes asynchronously-- meaning the script that calls it does not wait to call the next line until the ScriptCmdReset command is done, such that new variables declared immediately afterward could still be reset if the ScriptCmdReset command wasn't quite done.

 

Have you tried putting your variable declarations in one VBScript file and using ScriptCmdRemove to undo those variable declarations?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 4
(5,949 Views)

Hello Brad!

 

No, ScriptCMDRemove doesn't help me, because - placed at the end of script - it removes all variables I need to transfer to Report.

 

Probably an explanation helps. What I do:

1) declare global variables (approx. 20, most of they as array)

2) calculate several values from my data channels (e.g. maximum of channel A, value of channel B at time point X, and so on)

3) assign these values to individual global variables

4) update the REPORT table

 

For example, the one of the variables is z1(i).

For each i (e.g. from 1 to 10) the variable z1(i) contain the value of the channel number "i" at time point Time1.

Then in the REPORT table I have a column with content @@z1(d2TabRow)@@.

After PicUpdate the current values (from the loadad data set) are tabled.

 

This principle is applied for z1(i) to z20(i). So I have a lot of variables to fill a table (typical size 10 x 20).

 

For the next data set I probably don't need all these variables. But without RESET they stay active, with "old" values assigned, and would come out in the table.

 

Currently I disable the ScriptCMDReset command at all. But it seems to be not the best way.

 

0 Kudos
Message 3 of 4
(5,945 Views)

Hi Dia,

 

I'm going to suggest you use a different approach to solve this need.  We can get global variables to work for you, but I've got what I consider to be a superior alternative to offer.  It sounds like you have M array variables that each contain the values of one particular property for all the N channels of interest.  So you've got M array variables that are each N values long.  I recommend instead that you assign M properties to each of the N channels of interest.  It's much easier to reference channel properties than it is global array variables in REPORT, and as soon as you delete those channels or switch to looking at new channels, there is no need to "reset" the arrays, because you're using properties ATTACHED to the channels.  Also, if you save the data channels after the analysis, these properties save with them and can be searched by the DataFinder, and they reload into the Data Portal the next time you load the saved data file.

 

If you're displaying all the N values of the arrays in a REPORT table with M columns, then I recommend you additionally create a "Table" group with M channels that are N values long and assign all those values to the channel values and reference these "Table" channels in the REPORT table.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 4 of 4
(5,943 Views)