Jump to content
  • 0

Script | run program wait for response, get filepath


kojak

Question

Hello @attila

Can you add an option into script to run a program and which will wait for response? I am using Tool.start for starting Python script which is sending some data over virtual COM port and I need to process response from this script in order to decide how to continue.

And one more request - can you add an option for ability to show open/save file dialog? This can be used for defining filename of script about which I wroted above and for defining filenames for save/export images/data.

Thank you

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

Hi @kojak

I added Script function for the next version for synchronous execution, save/open file/directory dialog

With the currently released software you can dump the app output to a file and use Tool.getText

var file = File("C:/temp/"+Tool.getText("File:", "log.txt"))
file.deleteFile()
if(!Tool.start("cmd.exe", ["/c", "ping 192.168.0.1 >> "+file.getPath()])) throw "error"
while(wait() && !file.exist()); // wait for the file to be created
wait(5) // additional wait for the app to finish writing, it depends on the app
print("File", file.read())

image.png.4b96210eb82b1a4ab22165e18487d00f.png

Link to comment
Share on other sites

Hi @kojak

In WF v3.8.5 you can find new Script functions:
Tool.getSaveFile(caption, path, filter) Opens a file dialog and returns the file path. The filter has the following format: "Text (*.txt);;CSV (*.csv)"
Tool.getOpenFile(caption, path, filter) Opens a file dialog and returns an existing file path.
Tool.getDirectory(caption, path) 
Returns an existing directory.
https://forum.digilentinc.com/forum/8-scopes-instruments/

Link to comment
Share on other sites

Hi @attila

this is great. I also tried exec function but it looks as this function have fixed timeout to 10 s and it is waiting for this timeout although the called program has already finished execution. I am expecting that you are working on that.

Thank you.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...