Page 1 of 2

How pass parameters to exe

Posted: Fri Jun 19, 2015 12:21 am
by JosepM
Hi,

I have a little utility that perfom an update to one database but I need to call it from the windows task manager. How can pass some parameter to the app? is posible?
I need pass a value or string.

Salut,
Josep M

Re: How pass parameters to exe

Posted: Sat Jun 20, 2015 6:54 pm
by zaxos

Code: Select all

launch theParameter with "yourPath/YourApp.exe"
OR

Code: Select all

get shell("explorer"&&quote&"yourPath/YourApp.exe theParameter"&quote)

Re: How pass parameters to exe

Posted: Mon Jul 20, 2015 8:21 pm
by JosepM
Hi,

But I need call from the windows task manager.
Any help about how call it from cmd window?

Re: How pass parameters to exe

Posted: Tue Jul 21, 2015 3:54 pm
by MaxV
zaxos is right, shell() function is what you need, for example:

Code: Select all

put shell("dir")

Re: How pass parameters to exe

Posted: Tue Jul 21, 2015 5:52 pm
by JosepM
Hi,

Nop. I need call the .exe outside Livecode, I want schelude a task from the Windows task manager and I can't use "put xXXX", isn't?

Re: How pass parameters to exe

Posted: Tue Jul 21, 2015 6:36 pm
by Klaus
Hi Josep,

that depends on your database EXE! :D

Most of the time these command line tools have a build-in help that you can call in the DOS prompt like:
name_of_your_db.exe /?

Or maybe:
name_of_your_db.exe -h


Best

Klaus

Re: How pass parameters to exe

Posted: Tue Jul 21, 2015 8:59 pm
by JosepM
Hallo Klaus,

Yes. But I don't know how pass the parameter to the application and how handle it from livecode.

I have a livecode an app that perform some actions when the user click on the buttons. I need execute the app with parameter to auto-execute the actions.

myapp.exe -auto

From livecode if I get the parameter "auto", the app must perform the actions and quit as unattended mode.

Salut,
Josep M

Re: How pass parameters to exe

Posted: Tue Jul 21, 2015 9:17 pm
by FourthWorld
You can obtain the arguments passed to a LiveCode app with the global variables $1, $2, etc. You can get the number of such arguments with $#.

In a future version this will be even easier:
http://quality.runrev.com/show_bug.cgi?id=12108

Re: How pass parameters to exe

Posted: Tue Jul 21, 2015 10:51 pm
by JosepM
Hi,

So from DOS command line myapp.exe myfirstparam mysecondparam

And from Livecode...

on preopenstack
global $1,$2
put $1 into tParamOne
put $2 into tParamTwo

... do something

end preopenstack

This way?

Salut,
Josep M

Re: How pass parameters to exe

Posted: Tue Jul 21, 2015 10:56 pm
by FourthWorld
Yep. And if you want the app to run without a UI, you can add -ui as the first of those arguments and the engine will boot faster with less RAM, bypassing all UI initialization, e.g.:

Code: Select all

myapp.exe -ui arg1 arg2

Re: How pass parameters to exe

Posted: Tue Jul 21, 2015 11:33 pm
by JosepM
Hi,

Nice :) Exist any other parameters? like -ui ?

The params are separated by comma or space from DOS command? or -param1 -param2 ?

On the Macosx terminal is the same?

Salut,
Josep M

Re: How pass parameters to exe

Posted: Tue Jul 21, 2015 11:36 pm
by FourthWorld
Args passed to an app are not normally separated by commas. I've corrected my example above to remove the errant comma that had been there.

Re: How pass parameters to exe

Posted: Wed Jul 22, 2015 1:21 am
by JosepM
Thanks :)

Salut,
Josep M

Re: How pass parameters to exe

Posted: Thu Jul 30, 2015 10:16 am
by JosepM
Hi,

Works perfect! but now I want exit the app when finish. I use the quit command but the app still reside on memory and don't auto-quit.
What I'm doing wrong?

On preopenstack I get the params.
On openstack if exist any param I execute the actions and quit the app.

I tryed the same from the preopenstack without success.

UPDATE: I tryed also lock messages and quit, but not success, the app remain on memory...

Salut,
Josep M

Re: How pass parameters to exe

Posted: Thu Jul 30, 2015 1:44 pm
by AxWald
Hi,
JosepM wrote:Works perfect! but now I want exit the app when finish. I use the quit command but the app still reside on memory and don't auto-quit.
Had similar problems with using -ui, the stack would not close properly

Solved it with calling the stack in VB with "vbhidden", but that's not always possible.
Other idea would be to check $# in preopenstack, and if > 1 (means there are cmd line arguments), set the visible of the stack to false.

Seems it has to do with visual actions in the stack, for instance:

Code: Select all

put $1 into field OneField
So that the engine tries to update the gfx of the field, but fails since it has no gfx stuff loaded ...
Not sure, maybe someone of the pros has more insight ;-)

Have fun!

PS: I find it useful to have a flag in stacks that have an auto-quit feature - I use such in the openstack script:

Code: Select all

if the shiftkey is down then put false into autorun else put true into autorun
Where autorun is a global that is checked before the "quit" cmd. Then start it with Shift pressed and it will stay alive, for better usability ;-)