The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 DOS batch file starting from project directory
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

tib

Switzerland
105 Posts

Posted - 11/12/2003 :  11:32:57 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

tib

Switzerland
105 Posts

Posted - 11/13/2003 :  06:23:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/13/2003 :  07:31:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

srmcarneir

Brazil
33 Posts

Posted - 12/18/2003 :  1:50:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 12/18/2003 :  2:27:39 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000