Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Nymphodora), 972 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Calling a command line program from Zorro and receiving output? #471630
03/12/18 04:05
03/12/18 04:05
Joined: Sep 2017
Posts: 235
H
Hredot Offline OP
Member
Hredot  Offline OP
Member
H

Joined: Sep 2017
Posts: 235
Can Zorro call a command line program from within a script and receive the program output as a string, or a numeric value?
If yes, how can this be done?

Last edited by Hredot; 03/12/18 04:06.
Re: Calling a command line program from Zorro and receiving output? [Re: Hredot] #471637
03/12/18 12:01
03/12/18 12:01
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Depends on how the program produces output. The simplest way would be through a file.

Re: Calling a command line program from Zorro and receiving output? [Re: jcl] #471640
03/12/18 13:27
03/12/18 13:27
Joined: Sep 2017
Posts: 235
H
Hredot Offline OP
Member
Hredot  Offline OP
Member
H

Joined: Sep 2017
Posts: 235
The external program could write to a file, or do a cout to console. There is a C function "popen" in stdio that could receive such a stream, but I'm not sure if stdio is available in Zorro.

Perhaps you could give a short code snippet on how to call a command line command from Zorro as an example?

Re: Calling a command line program from Zorro and receiving output? [Re: Hredot] #471645
03/12/18 14:26
03/12/18 14:26
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
You can make a DLL that exports any functions you need, such as _popen and its brethren.

That said, I wouldn't use _popen(). I'd write a DLL that uses Boost Process to launch a child process and Boost Asio to communicate with its stdin & stdout - or perhaps with a pipe.

Or just do the file method. That's the five-minute solution. laugh

EDIT - Honorable mention goes to the Windows API. Some of this stuff is actually included in Zorro's windows.h header.

Last edited by AndrewAMD; 03/14/18 15:34.
Re: Calling a command line program from Zorro and receiving output? [Re: AndrewAMD] #471646
03/12/18 14:51
03/12/18 14:51
Joined: Sep 2017
Posts: 235
H
Hredot Offline OP
Member
Hredot  Offline OP
Member
H

Joined: Sep 2017
Posts: 235
Thanks for the suggestions! Yeah, I'm fine with the file method, still curious about the simplest code to execute a command line from Zorro. Is a custom dll the only way?

Re: Calling a command line program from Zorro and receiving output? [Re: Hredot] #471647
03/12/18 15:00
03/12/18 15:00
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Code:
exec("C:\\Directory\\Program","",1);


Re: Calling a command line program from Zorro and receiving output? [Re: Petra] #471649
03/12/18 15:18
03/12/18 15:18
Joined: Sep 2017
Posts: 235
H
Hredot Offline OP
Member
Hredot  Offline OP
Member
H

Joined: Sep 2017
Posts: 235
Thank you Petra, this is perfect!


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1