From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to update a global Variable in a running SUD

Hallo zusammen,

ich versuche etwas einfaches wie eine berechnung im Dialog.
Und das Ergebnis in einem Textfeld anzeigen lassen.
Ähnlich wie ein ganz einfacher Taschenrechner.

Mit einer globalen Variable gebe ich den Wert an das Script weiter und lasse die Berechnung laufen. Danach wird der berechnete wert in eine andere globale Variable (Ausgabewert) geschrieben.
Das funktioniert auch, weil wenn ich das Dialogfenster schließe gibt mir eine MSGBOX den richtigen berechneten Wert aus.

Wenn ich jetzt aber Ausgabewert in einem Textfeld im Dialogfenster direkt anzeigen will, zeigt es mir immer nur den wert, den die Ausgabewert Variable beim Start des Dialogfensters hatte und verändert diesen nicht, bis ich das Dialogfenster wieder schließe.
Jetzt hatte ich schon im Dialogeditor eine zusätzliche Variable erstellt, die nur den Wert der Ausgabewert Variable im Textfeld anzeigen soll.
Das ganze hat auch einmal funktioniert, aber jetzt meldet Diadem immer, dass die zusätzliche Variable nicht an Diadem übergeben wurde.
Und so bald ich diese aber im Script deklariere, wird sie im Dialogfenster nicht mehr aktualisiert.

Was mache ich falsch?
Kann mir bitte jemand helfen?

 

 
 
 
Hello everybody,

I try something simple like a calculation in dialogue.
And display the result in a text box.
Similar to a very simple calculator.

With a global variable, I pass the value to the script and let the calculation run. Then the calculated value is written to another global variable (output value).
This works, too, because when I close the dialog, an MSGBOX gives me the correct calculated value.

However, if I now want to display the output value directly in a text field in the dialog box, it only shows me the value that the output value variable had at the start of the dialog window and does not change it until I close the dialog box again.
Now I had already created an additional variable in the dialog editor, which should only display the value of the output value variable in the text field.
The whole thing worked once too, but now Diadem always announces that the additional variable has not been given to Diadem.
And as soon as I declare it in the script, it will not be updated in the dialog box.

What am I doing wrong?
Can someone help me please?
0 Kudos
Message 1 of 5
(2,586 Views)

Hi Chris.Fydi

 

I assume that you do not refresh the text in the dialog box. After you set the text of the control you have to refresh it. Have a look in the help, e.g.

http://zone.ni.com/reference/en-XX/help/370858P-01/sudref/methods/sud_method_refresh_tostaticctrlrt/

 

Hope that helps.

Winfried

0 Kudos
Message 2 of 5
(2,572 Views)

Hello Winfried,

I have already tried this method.
It also works, as long as you do the calculation in the script of the dialog box and then the result is displayed directly in the text box.
But as soon as you let the calculation work as a function in another script and only call the result in a global variable, the value in the dialog box remains the same. Although in the background the global variable has the changed value.
I just do not get it refreshed.

 

thanks for trying

Chris

0 Kudos
Message 3 of 5
(2,569 Views)

Hi Chris,

 

It would be easier to find the bug if you could post your SUD file.

 

If you use global variable like R1 they have to be declared in SUD. Press Ctlr + B and then OK.

 

I attached a small dialog box (DIAdem 2018 SUD-format as Zip file) that shows two solution. One with the global variable R1 and one with local variables. In general I would prefer the solution with local variables.

 

Winfried

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

okay,
maybe you can find the bug.
the Test_Dialog.VBS ist the starting script.
The rest you can see it by yourself.
I'm very interested to know the problem, because i try to make me some procedures.
So i thank you very much.

0 Kudos
Message 5 of 5
(2,548 Views)