DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing arguments to script

Solved!
Go to solution

Hi,

 

I created a dialog which load folder files and when i click the button i run another script by StartScript(...) command

 

How could i pass my arguments to the script (the files paths)?

 

Thanks

0 Kudos
Message 1 of 12
(7,741 Views)

Hi OzShimon

 

All variables that a declared in the "Declaration part" are also available in subscripts. The "Declaration part" is the very top script part outside of any procedure. These variables are global variables.

 

They have to  defined with dim, but can be changed everywhere. Of course you can call subfunctions with parameters like "Call MySub(ParamOne, ParamTwo)"

 

Hope this helps

 

Winfried

0 Kudos
Message 2 of 12
(7,730 Views)

Hi Winfried,

 

That not what i meant.

 

For example:

 

 **My dialog contains one button and event click

the dialog code: 

 

Dim obj

Sub Button1_EventClick(ByRef This)

     obj= "Hello World"

     Call ScriptStart("C:\Users\Oz\Desktop\test.vbs")

End Sub

 

**the script code(test.vbs):

Call MsgBox(obj)

 

I want to pass the- obj parameter to the test.vbs script .

 

How i do it?

 

 

Thanks

 

0 Kudos
Message 3 of 12
(7,725 Views)

Hi OzShimon

 

Why do you use ScriptStart. You can use Scriptinclude instead. Then you can use parameters as well. Please look at

http://zone.ni.com/reference/en-XX/help/370858K-01/comoff/scriptinclude/

for the differences.

 

Winfried

 

0 Kudos
Message 4 of 12
(7,719 Views)
Solution
Accepted by topic author OzShimon

Hey OzShimon,

 

As long as you use a Diadem predefined global variables (T1,T2,....)  you would be fine. You can also define user variables (.VAS files) or even declare your  own global variables with : Call GlobalDim("Myname").

 

These variables will not be re-initialized until you restart the script engine. So just changing "obj" for T1 your test should work

 

'Dim obj

Sub Button1_EventClick(ByRef This)

     T1= "Hello World"

     Call ScriptStart("C:\Users\Oz\Desktop\test.vbs")

End Sub

 

**the script code(test.vbs):

Call MsgBox(T1)

 

Regards,

 

Javier

 

0 Kudos
Message 5 of 12
(7,715 Views)

Sorry for this second post but i missed to say that I totally agree with winner, using scripInclude seems to be the best option to pass parameters between script. However i giev you some info about the global variables cause migth be interesting if you want to pass info between dialog box...

 

Regards,

 

Javier

 

 

0 Kudos
Message 6 of 12
(7,705 Views)

Thanks to all of you,

 

I decided to use:  Call GlobalDim(....) because i need to passing parameters from dialog to script, but all the others options working .

0 Kudos
Message 7 of 12
(7,701 Views)

Hi,

 

i succeeded to declare user variables with Call GlobalDim("myVar") but how could i declare an array of strings with GlobalReDim ?

 

It's give me an error.

 

I tried: *Call GlobalReDim("myArray(2)") 

 

Thanks

0 Kudos
Message 8 of 12
(7,650 Views)

Hi,

 

i succeeded to declare user variables with Call GlobalDim("myVar") but how could i declare an array of strings with GlobalReDim ?

 

It's give me an error.

 

I tried: *Call GlobalReDim("myArray(2)") 

 

Thanks

0 Kudos
Message 9 of 12
(7,650 Views)

Try it out;

 

f Not ItemInfoGet("MyArray") Then Call GlobalDim("MyArray")
GlobalReDim "MyArray(20,20)"

 

 

Javier

0 Kudos
Message 10 of 12
(7,637 Views)