Loading Igor from a Batch File

darlingtona
Posts: 13
Joined: 2014-03-28
Location: Canada

Hello,

I'd like to create a windows batch file to do two things:
1) Launch Igor and open a particular experiment file.
2) Run a command in this experiment file.

So far I have this:
"C:\Program Files (x86)\Wavemetrics\Igor Pro Folder\Igor64.exe" "E:\Documents\Igor_Experiments\Experiment.pxp"
"C:\Program Files (x86)\Wavemetrics\Igor Pro Folder\Igor64.exe" /X "runFunction()"

When I run this file it launches Igor and opens the specified experiment but it doesn't run the function. Once I close the experiment file it immediately opens another instance of Igor and tries to run the command but can't because that command does not exist in the blank experiment file. Is there a way to get this to work? I know that I could put the command in the procedure window before any of the functions and it would be run when Igor launches but ideally I'd like to have two batch files for the users of my program to work with: one that would do what I've talked about above and one that would only open the experiment without running the function.

Any ideas are greatly appreciated!
Thank you!
Andrea


Posts: 807
Joined: 2007-03-01
Location: United States

What you describe is how batch files work and isn't due to Igor. The batch processor waits until one command is complete (and the program it calls has returned) before it moves on to execute the next line. Take a look at https://stackoverflow.com/questions/1449188/running-windows-batch-file-c... for a solution that may work for you.

An alternative approach would be to put runFunction() at the top of the built-in procedure window, as you mentioned. You could modify your runFunction() code a bit to test whether a key is pressed (eg. the Alt/Option key) and if it is then bail out. Otherwise runFunction() does whatever it normally does.


HJDrescher
Posts: 349
Joined: 2015-01-20
Location: Germany

Use the start command in the batch file:

start /b "" "C:\Program Files\Wavemetrics\Igor Pro 7 Folder\IgorBinaries_x64\Igor64.exe" /X "make test"
ping 127.0.0.1 /n 10 > nul
start /b "" "C:\Program Files\Wavemetrics\Igor Pro 7 Folder\IgorBinaries_x64\Igor64.exe" /X "display test"

The ping command is used to give Igor some time to start up. The number of pings (10) can be adjusted to your needs.

HJ

Note: Maybe this issue with batch files could be added to the manual in section "Calling Igor from Scripts"?


[ last edited December 20, 2017 - 07:27 ]
darlingtona
Posts: 13
Joined: 2014-03-28
Location: Canada

Thanks for the suggestions! I've added the start command to the batch file and that is working.

Thank you!


ajleenheer
Posts: 71
Joined: 2013-04-26
Location: United States

A cleaner alternative to "ping 127.0.0.1 /n 10 > nul" is the "timeout" command (works on Windows 7 at least):


start "C:\Program Files (x86)\Wavemetrics\Igor Pro Folder\Igor64.exe" "E:\Documents\Igor_Experiments\Experiment.pxp" &
timeout/t 20
"C:\Program Files (x86)\Wavemetrics\Igor Pro Folder\Igor64.exe" /X "runFunction()"


HJDrescher
Posts: 349
Joined: 2015-01-20
Location: Germany

On older systems it would be sleep. I wanted to avoid conditional batch files. ping works on any windows version (>3.1, I think).
HJ


[ last edited December 20, 2017 - 23:59 ]

Back to top