Quantcast
Channel: DIAdem topics
Viewing all articles
Browse latest Browse all 3196

Problems passing variable value to SUD

$
0
0

Hello,

 

I need some help understanding how to pass a variable to a SUD file. My main script sets the value of a variable (named KSTM) and it then uses SUDDlgShow to call a dialogue box. I need the sub script in the SUD file to be aware of the value of KSTM and act on it accordingly.

 

I've read about using transfer parameters, receiving them using GetArgument, and tried to understand the difference between ByRef and ByVal in case that's important. However, all I get is a range of error messages.

 

The value of KSTM does not need to be modified by the SUD file or passed back to the main script.

 

The code in the main script is:

 

KSTM = 1 Call SUDDlgShow("Parameters", SharedPath & "VBS\" & "Trans.sud", KSTM)

 

I would then like to use the minimum amount of code in my SUD file to read the value of KSTM and act on it:

 

Sub Dialog_EventInitialize(ByRef This) 'Created Event Handler If KSTM > 0 Then EditBox7.Enable = 1 R1 = 1 Else EditBox7.Enable = 0 R1 = 99 End If End Sub

 

The above sub script in the SUD file fails because it says the variable KSTM is undefined. This is odd because KSTM is defined in the main script and I'm passing it to the SUD file. I'd be concerned about using Dim inside the sub script because I don't want to delete the contents of KSTM. However, since everything I try fails to overcome this error I have to conclude that I need to redim KSTM in the sub script. However, do I redim it above the subscript or inside it?

 

If I put it inside the subscript then I can get the code to work but it's obviously not correct. The value of R1 is telling me that it doesn't matter what value KSTM has in the main script it isn't getting passed to the subscript.

 

If I then add a set statement and use Dialog.GetArgument with it, I get a new error message telling me "Object required: 'Dialog.GetArgument'. I don't understand why this is a problem as this line is identical to one used in another script that works fine!

 

I have been through this before here (https://forums.ni.com/t5/DIAdem/Variable-types-and-variable-use-in-SUD-files/m-p/4022490#M27259) but on this occasion I only want to pass a single variable value and I don't need to pass anything back. Clearly, I didn't understand it very well the first time around.

 

Any help gratefully received.

 

Thanks, Simon.

 

 

 

 


Viewing all articles
Browse latest Browse all 3196

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>