Recent

Author Topic: How to launch a GUI app with parameters  (Read 3660 times)

Raul_ES

  • Full Member
  • ***
  • Posts: 183
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
How to launch a GUI app with parameters
« on: January 23, 2018, 09:18:39 pm »
Hi,

Can someone please tell me your best way to add command line options to a GUI application and how to call this application with parameters from within another GUI aplication? (for any operating system)

Something like this:

MainA wants to launch ModuleB with the parameters "-customer_id=123443 -employee_id=12 -o open_latest_invoice" ? If no parameter is passed the the moduleB application will just go to a default empty page or simply print a message box "This app is a module. Goodbye".

regards,
Raúl

Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

Raul_ES

  • Full Member
  • ***
  • Posts: 183
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Re: How to launch a GUI app with parameters
« Reply #1 on: January 23, 2018, 09:21:41 pm »
Hi again,

I am just checking this post to see if I get a clue. Any suggestion or ideas are welcomed.

http://forum.lazarus.freepascal.org/index.php?topic=34172.0


thanks
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: How to launch a GUI app with parameters
« Reply #2 on: January 23, 2018, 09:23:05 pm »
ParamCount and ParamStr() will tell you if the application has commandline parameters.
Use TProcess/TProcessUTF8 to launc an application with commandline parameters.

Bart

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Raul_ES

  • Full Member
  • ***
  • Posts: 183
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Re: How to launch a GUI app with parameters
« Reply #4 on: January 24, 2018, 02:16:51 am »
Thank you Bart & Avra :-)

regards
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

Raul_ES

  • Full Member
  • ***
  • Posts: 183
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Re: How to launch a GUI app with parameters
« Reply #5 on: January 27, 2018, 08:53:13 pm »
Hi,

I have a bit of confusion here. Maybe I am concieving a wrong approach in the whole design and I am going in the wrong direction. Any advice or criticism is welcomed by the way. Please, check out the following situation.

Imagine a main program and a module (with an optional GUI) that accepts command line options. If no comand line option is specified the module will start with its own gui. If the main program launches the module with parameters it will then perform some automatic action that does not require user interaction (connect to a database, check a file in a web server, deploy an update, perform a backup, what ever) AND has to return an output to the main program.

i.e:
Main wants to launch Module with the parameters "-customer_id=123443 -employee_id=12 -password=ecrypted_whatever -latest_five_orders".

So the console output could be something like this:

"23514" "14/1/18" "340.56€"
"23501" "2/1/18" "23.15€"
...
...
Maybe we dont actually need to display the output in the console BUT we need to return the values to, for example, a grid in the Main program or maybe a variable in the main program (output_string='23501,2/1/18,23.15€').

I dont want to use a network client/server design and I dont want to generate temporary files on hard disk.

 :o %)
regards
« Last Edit: January 28, 2018, 01:19:23 am by L.Raúl »
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: How to launch a GUI app with parameters
« Reply #6 on: January 27, 2018, 09:04:15 pm »
Have a look at the pipes demo that comes with FPC.
Specialize a type, not a var.

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: How to launch a GUI app with parameters
« Reply #7 on: January 27, 2018, 09:10:02 pm »
http://wiki.freepascal.org/Executing_External_Programs

Also look at this page, it has lots in there and covers PIPES for input and output.
The only true wisdom is knowing you know nothing

Raul_ES

  • Full Member
  • ***
  • Posts: 183
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Re: How to launch a GUI app with parameters
« Reply #8 on: January 28, 2018, 01:21:39 am »
Thank you very much, you brought some light over me.  :)
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

 

TinyPortal © 2005-2018