[fpc-pascal] Freevision etc.
Graeme Geldenhuys
mailinglists at geldenhuys.co.uk
Thu May 4 14:43:06 CEST 2017
On 2017-05-04 13:21, Mark Morgan Lloyd wrote:
> text-mode console or over something really crude like telnet... and I
> hope you're doing that for fpGUI since you keep telling us how good it
> is :-)
As I said, I do that often in my own (and commercial) applications that
use fpGUI. The fpGUI framework itself also has some extra checks in to
see if a GUI environment is available, and will exit gracefully with a
error message if such an environment doesn't exist.
The usual remote functionality of X11 also works perfectly with fpGUI
applications. ie: run a app here, but it displays on a different server.
> initialisation block, but it would mean splitting out e.g. text-mode
> --help and graphics-mode --about into separate places.
With my applications, I normally implement a reusable initialize.inc
file which sits before the fpgApplication.Initialize() call.
This include file does command line parameter handling and in case of
database applications, initialised tiOPF for me. When it comes to
command line parameters, I check if I need to handle anything (eg: -h or
--help) then do a IF IsConsole THEN.... ELSE.... and that is it. Quite
simple.
Here is the code for the application output I showed earlier.
================================================
// Help
if gCommandLineParams.IsParam(['h', 'help']) then
begin
if IsConsole then
begin
writeln(Format(cAppNameFormatStr, [ApplicationName,
cMajorVersion, cMinorVersion, uiVersionBuild, cBuildVersion]));
writeln('Compiled on ' + cCompileDateTime);
writeln('');
writeln('The following parameters are available:');
writeln('');
writeln(' h, help Shows this help');
writeln(' lc Logs debug information to the
console');
writeln(' lv Logs debug information to a visual
screen');
writeln(' ls Logs debug information to debug
server');
writeln(' l Logs debug information to a file');
writeln(' style Applies a custom style to the
application. Available');
writeln(' options are: ' +
fpgStyleManager.StyleTypesAsString);
writeln('');
writeln('NOTE: This program requires a graphical windowing
environment to function.');
Exit;
end
else
begin
fpgApplication.Initialize;
tiShowString(
Format(cAppNameFormatStr, [cAppName, cMajorVersion,
cMinorVersion, uiVersionBuild, cBuildVersion])
+ LineEnding + 'Compiled on ' + cCompileDateTime
+ LineEnding + ''
+ LineEnding + 'The following parameters are available:'
+ LineEnding + ''
+ LineEnding + ' h, help Shows this help'
+ LineEnding + ' lc Logs debug information to the
console'
+ LineEnding + ' lv Logs debug information to a
visual screen'
+ LineEnding + ' ls Logs debug information to
debug server'
+ LineEnding + ' l Logs debug information to a file'
+ LineEnding + ' style Applies a custom style to the
application. Available'
+ LineEnding + ' options are: ' +
fpgStyleManager.StyleTypesAsString
, 'Quick Help', False);
fpgApplication.Run;
Exit;
end;
end;
// activate application logging code here
// apply user defined fpGUI style here
// activate tiOPF initialisation code here
================================================
Regards,
Graeme
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
My public PGP key: http://tinyurl.com/graeme-pgp
More information about the fpc-pascal
mailing list