DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

a message box with variable information

Hello,

 

I am wondering, if vbs has an option to create a message box which will show different text´s depending on the value of my variables.

I know I can create multiple message boxes which will be shown in the selected cases (for example an If-command). But I have some more variables and that would result in a lot of message boxes.

If I could choose one text for one variable depending on it´s value and then independently choose another text depending on another variables value and so on...and display all that in one message box ,that would really help me.

 

a small example:

I have 5 variables: a, b, c, d, e

during my script some variables value is changed

at the end there is a message box which which summaries all what happend:

for example 0 variables have been changed, the message box should say:

     0 variables have been changed.

for example 1 variable has been changed, the message box should say:

      variable a changed

and so on, the problem is I have a lot of variables, which would result in a huge number of message boxes

 

thanks in advance

 

 

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

Hi question1234,

 

There is no built in message box in VBScript or DIAdem that tracks the changes of variable states.  You can build a display such as you describe by tracking those changes yourself.  You'd need to store the initial values of all your variables at the beginning of the script and then compare the current state of all your variables at the end of your script.  Please let us know if you need help with either the variable state caching, the variable state comparison, or the building of a display to show the number of changed states among your set of variables.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

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

Hello,

 

the main problem I face is that the text, which I want to be displayed in the message box is depending on the state of the variable. I simply don´t know how to build one display which will show a text depending on whether the variable was changed during the script or not. My problem is not the comparisson of the variables, I can do that.

 

the simplest way do so (but it doesn´t work) would be some if-conditions in the message box itself

example

Call MsgBoxDisp:

If variable1atthestart = variable1attheend then

"variable1 was not changed"

else

"variable1 was changed"

 

If variable2atthestart = variable2attheend then

"variable2 was not changed"

else

"variable2 was changed"

 

and so on, but you can´t write if-conditions into a msg box

and I also don´t want several message boxes showing off

 

hope this will help you understand my problem

 

kindest regards

 

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

Hi question1234,

 

How about something like this?

 

 

If variable1atthestart <> variable1attheend Then VarStr = VarStr & vbCRLF & "variable1"
If variable2atthestart <> variable2attheend Then VarStr = VarStr & vbCRLF & "variable2"
If variable3atthestart <> variable3attheend Then VarStr = VarStr & vbCRLF & "variable3"
If variable4atthestart <> variable4attheend Then VarStr = VarStr & vbCRLF & "variable4"

ChangedVariables = Split(VarStr, vbCRLF)
ChangedVarCount = UBound(ChangedVariables)
Msg = "0 variables changed"
If ChangedVarCount > 0 Then Msg = ChangedVarCount & " variables changed" & vbCRLF & String(25, "-") & VarStr
MsgBox Msg

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

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