On Thu, 4 May 2017, Mark Morgan Lloyd via Lazarus wrote:

On 11/04/17 09:30, Mark Morgan Lloyd via Lazarus wrote:
Apologies if this is an FAQ.
Is there an orthodox way that a Lazarus program can very early on look
at how it's been started and decide whether it can usefully fall back to
a text mode, e.g. to display help info on stdout rather than a messagebox?
I'm tinkering with something (a media test program for SDCards etc.)
which I'd like to either run as a conventional console program, or using
a GUI. I've previously written stuff where operation was entirely
dependant on command-line options, but haven't tried making the decision
completely automatically.

In case it helps anybody avoid wasted time: looking carefully at what I've been doing, it turns out that it's not possible to make an LCL-based program running on unix (i.e. with X11 etc.) to fall back cleanly to text mode, such that it could be run on e.g. a serial terminal, by manipulating the main program unit (.lpr or whatever).

The simple solution is to write 2 binaries. A text-only one, and a GUI one.
The text-only one starts the GUI one if it detects a GUI (or if a
command-line element is present).

I see no added value in having everything in 1 binary.

Michael.
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to