NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to open a file dialog and return selected/new file as variable?

Solved!
Go to solution

Hello,

i am using this expression to open a filedialog and return the selected path.

 

RunState.Engine.DisplayFileDialog("test","ok","c:\\",StationGlobals.S1,StationGlobals.S2,0,"",4100,"")

 

How can i enter a new filename in the selected path and return this value into the globals?

 

Thanks

0 Kudos
Message 1 of 7
(3,931 Views)

Hi,

 

 You can use the TestStand API by calling an ActiveX step:

 

Automation Server: TestStand <version> API

Object Reference: Runstate.Engine

Object Class: Engine (IEngine)

Call Method: DisplayOpenFileDialog

 

The step parameters are self explanatory, but you can return the path using "absolutePath" to a local variable.

 

I hope this helps,

Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)

Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor

Message 2 of 7
(3,925 Views)

Hi Charlie,

thanks for your answer.

I think while you wrote the answer i modified my question.

Now i am also doing what you described.. only problem is: how to select a new file (that not exists in dialog).

0 Kudos
Message 3 of 7
(3,917 Views)

Hi,

 

change the win32flags parameter to the following:

 

win32Flags: 4100+WinFileDlg_CREATEPROMPT

 

Regards,

Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)

Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor

Message 4 of 7
(3,910 Views)
Solution
Accepted by topic author OnlyOne

Works fine.

Thanks. I changed now the 4100 to 0 after reading  the help file:
http://zone.ni.com/reference/en-XX/help/370052G-01/tsapiref/reftopics/windowsfiledialogflags/

 

Another question is:

The function returns the path in a string array. For example c:\test\sub\new\file.txt

How can i replace ALL \ with \\?

 

best regards

0 Kudos
Message 5 of 7
(3,885 Views)

Solved: SearchAndReplace

 

0 Kudos
Message 6 of 7
(3,862 Views)

Just a few details.

 

Automation Server: NI TestStand 2016 SP1 API 

It took me just about forever to find this.

 

Call Method needs to be selected on the drop down, too.

0 Kudos
Message 7 of 7
(3,761 Views)