Execute Script Text - interfacing Igor with Contin
samullin
I just sent this to the email list, but I am not sure if the forums and the list share the same audience.
I am working to interface Igor with a couple of old programs called CONTIN and DISCRETE. In particular, I am using Contin to fit distribution functions to exponential decay data. I can run the program through the Windows command line, using text files as inputs and outputs, with commands like the following:
chdir /d f:\ContinAnalysis\test
contin.exe continDataOutput.txt
My Igor program at present can turn data vs time data into a continDataInput.txt file, and read the results back out of a continDataOutput.txt. The only aspect I'm missing to fully automate this is to run the program from the command line using ExecuteScriptText. However, I have had absolutely no luck with this function - even when paying particular attention to escape characters, including passing the command in quotes as "\"command goes here\"". It looks like there is some promise to use batch files, but I haven't been able to figure out how to write a batch file with the appropriate format either.
Any help would be greatly appreciated!
Regards,
Scott
"Thank you all for the help. I got it to work using some of Jim's advice, along with some code I found on Igor Exchange. The trick was to use the full-paths. I couldn't get it to run all of the commands in a single input, but making a batch file worked out well.
The newest problem I ran into was that after I run PathInfo, the s_path string is in the colon-separated format. I tried several different things, then ended up kludging it with replaceString. I'm happy with it."
The code I used from Igor Exchange is based on the ExecuteWinCmd function by harneit http://www.igorexchange.com/node/938
My code is below:
Function ExecuteContin(inputName, outputName, pathStr)<br />
string inputName, outputName, pathStr<br />
<br />
pathStr = replaceString(":", pathStr, "\\")<br />
pathStr = replaceString(pathStr[0] , pathStr, pathStr[0]+":")<br />
print "pathStr now equals " + pathStr<br />
<br />
string IPUFpath = SpecialDirPath("Igor Pro User Files",0,1,0) // guaranteed writeable path in IP6<br />
string batchFileName = "ExecuteContin.bat"<br />
variable refNum<br />
<br />
NewPath/O/Q IgorProUserFiles, IPUFpath<br />
Open/P=IgorProUserFiles refNum as batchFileName // overwrites previous batchfile<br />
<br />
string exeStr, inStr, outStr<br />
exeStr = pathStr + "contin.exe"<br />
inStr = pathStr + inputName<br />
outStr = pathStr + outputName<br />
string cmdStr = exeStr + "<" + inStr + ">" + outStr<br />
fprintf refnum, "cmd/c \"%s\"", cmdstr<br />
Close refnum<br />
<br />
ExecuteScriptText/B "\"" + IPUFpath + "\\" + batchFileName + "\""<br />
<br />
End</span>
February 25, 2010 at 05:54 pm - Permalink