| Author |
Topic  |
|
|
tib
Switzerland
105 Posts |
Posted - 11/12/2003 : 11:32:57 AM
|
Hi, I want to start a DOS batch file from a project with the path %X. run -e %XBatch.bat Only if I started the Origin project by double clicking then the batch file will be started from directory %X. However, when I start Origin and load the project the command starts the program in the Origin directory %Y. I tried fdlog.path$=%X but without success. Any ideas how I can set the DOS window start directory? Thanks, Tilman.
|
|
|
Mike Buess
USA
3037 Posts |
Posted - 11/12/2003 : 5:39:42 PM
|
Hi Tilman,
You can't change the working directory from LabTalk, but you can from Origin C. I'm not positive that this will do what you need, but it might be worth trying...
# OC function int ChgDir(string strPath) { return _chwd(strPath); // change working directory to strPath }
# LabTalk usage if( ChgDir(%X)==0 ) run -e Batch.bat;
(Now you don't need the full path in the run argument.)
...You might as well do it all in Origin C
# OC function void Launch(string strApp) { string strPath = GetFilePath(strApp); // file path string strFile = GetFileName(strApp); // file name if( _chwd(strPath)==0 ) ExecuteApp(strFile,""); }
# LT usage Launch "%XBatch.bat";
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 11/12/2003 6:57:11 PM |
 |
|
|
tib
Switzerland
105 Posts |
Posted - 11/13/2003 : 06:23:42 AM
|
Hi Mike, thanks, I would have preferred the pure C solution. BUT it doesn't work. First the command _chwd should be _chdir. And OriginC seems not know the command ExecuteApp. I also couldn't find it in the help.
Your first example works only if I replace _chwd with _chdir
Tilman.
Edited by - tib on 11/13/2003 06:47:24 AM |
 |
|
|
Mike Buess
USA
3037 Posts |
Posted - 11/13/2003 : 07:31:55 AM
|
Sorry, mixed up the function name with the name of the example given in the help file.
ExecuteApp is Origin 7.5.
Mike Buess Origin WebRing Member |
 |
|
|
srmcarneir
Brazil
33 Posts |
Posted - 12/18/2003 : 1:50:20 PM
|
Hi,
I had several problems with the calling of batch files from a LabTalk script and sometimes the same script does not work the same way in different machines. Concerning your example I guess I was luckier by inserting the character '\' between the string variable %B of the path and the batch file name:
run -e %B\BatchFile.bat;
Good Luck!
Ricardo Carneiro |
 |
|
|
Mike Buess
USA
3037 Posts |
Posted - 12/18/2003 : 2:27:39 PM
|
Hi Ricardo,
Whether or not you need the final '\' depends on how the path was generated. Most LabTalk commands that return paths automatically append '\'. Examples... %B=fdlog.path$, %B=%Y and %B=%X. (Although %X is empty until the project is saved.)
Mike Buess Origin WebRing Member |
 |
|
| |
Topic  |
|