Shell, chain, run , I dont know

New to FreeBASIC? Post your questions here.
Post Reply
Topito216
Posts: 18
Joined: Dec 11, 2009 13:13
Location: Spain

Shell, chain, run , I dont know

Post by Topito216 »

Hello.

I have a program of mathematical adjust: "ajuste.exe".
In order to run it I have just to double click with mouse over the exe file. the program reads ascci data from file, calculate, shows result on screen and save results in a txt file. No problem, It works ok itself and I dont need to input nothing.

I want run it from a freebasic programa with chain comand.

Code: Select all

Chain ("C:/FreeBASIC/Proyectos/ajuste.exe")
sleep
Adjuste.exe starts but it dont read the input files that they are in the same directory that the executable.

I have tried exec comand but I dont know I need any arguments.

I cant understand what's failing with such easy command. I cant believe to find problems with that.

Best regards.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Post by MichaelW »

You could try:

Code: Select all

print Chain ("C:/FreeBASIC/Proyectos/ajuste.exe")
sleep
So you can see what Chain is returning.
Topito216
Posts: 18
Joined: Dec 11, 2009 13:13
Location: Spain

Post by Topito216 »

MichaelW wrote:You could try:

Code: Select all

print Chain ("C:/FreeBASIC/Proyectos/ajuste.exe")
sleep
So you can see what Chain is returning.

I did it.

The adjust.exe starts but without data. Show errors and the number retourned in console is: -1073741819


Thanks.
Topito216
Posts: 18
Joined: Dec 11, 2009 13:13
Location: Spain

More

Post by Topito216 »

I realized that if I double click over the main program bas (Chain ("C:/FreeBASIC/Proyectos/ajuste.exe"), it starts ok and works ok ajuste.exe. But it dont works if I compile and run the main program from FBedit that it's my IDE.
Thanks
fxm
Moderator
Posts: 12566
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Post by fxm »

Try:

Code: Select all

Dim path as String = Curdir
Chdir("C:/FreeBASIC/Proyectos")
Chain ("C:/FreeBASIC/Proyectos/ajuste.exe")
Chdir(path)
sleep
Topito216
Posts: 18
Joined: Dec 11, 2009 13:13
Location: Spain

ok

Post by Topito216 »

Thaks to both of you.

Now it works even from Fbedit.

I have learned one more thing.



Thanks.
fxm
Moderator
Posts: 12566
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: More

Post by fxm »

Topito216 wrote:I realized that if I double click over the main program bas (Chain ("C:/FreeBASIC/Proyectos/ajuste.exe"), it starts ok and works ok ajuste.exe. But it dont works if I compile and run the main program from FBedit that it's my IDE.
Thanks
Under FBedit, if you execute "Quick Run" at least once on a file.bas, the current directory is automatically changed to the directory of the file.bas.
Then, you can even "Compile" and "Run" the program, and the current directory remains set to the directory of the file.bas.

It is another method that my previous to change the current directory to the directory of the target file.bas.
Post Reply