DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

array variables in DIAdem dialogbox

Hi,
 
i am writing a script, in which user selects channels via a dialogbox i prepared and the selected channels are processed afterwards.
I dont have any problems transffering the single values(variants) from  dialogbox to main script. but when i try to access the array, in which the selected channel numbers are stored, the array seems to be 0 length.
 
in Menu Edit>Variables i tried different types of DIAdem variables but didnt succeed.
 
My goal is to transfer the channel numbers selected by user to main script via an array. Then this array will be an input for a function in the main script.
 
 
thanks in advance
 
kaan
0 Kudos
Message 1 of 8
(7,030 Views)

Hi kaan,

Your variable options (VAS file, OdsValAlloc, GlobalDim) depend on your DIAdem version, but the general approach is the same.  You need a global DIAdem array variable declared in your VBScript, then you can fill that same global DIAdem array variable in the SUDialog and read the results afterwards in your VBScript.  For the OdsValAlloc and GlobalDim array variables you would be able to resize the array in the SUDialog as well, but if you do so with the GlobalDim array variable make sure to use the "Preserve" option, as in:

ReDim Preserve VarName(31)

Ask if you need more info,
Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 2 of 8
(7,010 Views)

Hi,

I have a problem resizing a global array variable, when i resize the array, the values that i assigned before are lost.

The following code demonstrates it

Dim H : H = 0

Globaldim "iArray"
Globalredim "iArray("&H&")"

iArray(0) = 0
msgbox iArray(0)                      'You see the value "0" in the messagebox

H = 1
Globalredim "iArray("&H&")"    'Can not use keyword "Preserve"
iArray(1) = 1

msgbox iArray(0)    'The content is lost !!!! no values shown
msgbox iArray(1)    'The value '1' appears on messagebox

Thanks in advance

Kaan

 

0 Kudos
Message 3 of 8
(6,931 Views)
Hello!
 
@Brad: As far as I know is there no preserve option in GlobalReDim! From my point of view is this out of all reason for a NEW function Smiley Mad
 
@kaan: With GlobalDim the only simple solution I see is to define an array wich is large enough and ignore the empty values in your function. I personally don't like this at all! We use dynamic DIAdem variables wich were not integrated in DIAdem and are only available with our DIAdem extension DLL. Another aproach is to wrap the array in a class and create an instance of this and store it in a GlobalDim variable.
 
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 4 of 8
(6,924 Views)
Hello!
 
Sorry to all I'm wrong!!!
 
Write
 
Globalredim "Preserve iArray("&H&")"    'Can not use keyword "Preserve"
in line 10
 
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 5 of 8
(6,922 Views)
Hi Matthias,
 
Thanks a lot for your answer, it is more than helpful !!
 
it is a pity though that it is not explained in DIAdem help file .
 
cheers
 
Kaan
0 Kudos
Message 6 of 8
(6,917 Views)
Hi,
 
While trying to size/resize a global array i am receiving the following error:
" DIADEM OCMD-Object : This array is fixed or temporarily locked: arrayname"
 
Does anybody know what is the reason behind this?
 
thanks in advance
 
kaan
0 Kudos
Message 7 of 8
(6,890 Views)

Hi Kaan,

How did you declare that array?  Did it resize once before, or never?  In general you should always declare an array as a scaler, then resize it to an array when you need it, this gives you the most flexibility to resize it again later:

GlobalDim "ArrayVar"
GlobalReDim "ArrayVar(5)"
ArrayVar(3) = "Foo"
GlobalReDim "Preserve ArrayVar(10)"
ArrayVar(10) = "Foo2"

Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 8 of 8
(6,868 Views)