
Command line arguments have been around since the days of DOS. They are a simple way to pass additional values to a program and thus influence the program flow. In the conzept 16 installation routine, for example, it is possible to use command line arguments to automate the entire installation process.
It would be wrong to claim that modern software does not use or require command line arguments. Most programs, even those with a graphical user interface, often offer hidden options that can be defined via the command line.
Command line arguments are specified after the command or program name. There are various ways to specify an argument. For conzept 16 applications, there are two types in particular:
1. Arguments defined by name:
c16_?.exe /<Argumentname>=<Argumentwert>
c16_setup.exe /cpn_action=extract /cpn_cln=1 /dir=.
The installation routine extracts the standard and advanced clients to the current directory.
This variant has the advantage that the arguments are identified by name. The order is irrelevant.
In Windows, the name of an argument is often preceded by ‘-’ or ‘/’. However, this may vary depending on the program. Similarly, the name and value of an argument do not necessarily have to be separated by an ‘=’ sign. An argument value that contains one or more spaces must be enclosed in quotation marks:
/path="C:\Program Files\MyApp.exe".
2. Arguments defined by position:
c16_?.exe <Argumentwert1> <Argumentwert2> ... <ArgumentwertN>
c16_apgi.exe * CodeLibrary START
The client connects to the CodeLibrary on the local server as user “START.” The second variant has the disadvantage that it is not clear to the user which argument has which meaning.
conzept 16
conzept 16 applications can also process command line arguments. The command SysGetArg() is available for this purpose. The name of the argument is passed to the command, which then returns the value (option 1).
Example (start application in debug mode)
c16_apgi.exe * Verwaltung USER /debug_mode=on
// Run program in debug mode?
tDebug # SysGetArg('debug_mode') =^ 'on';
if (tDebug)
... // Start program in debug mode
If the argument is not specified, the command returns an empty string.
Application example
A common use case is to be able to define the startup procedure via a command line argument. This allows an “experienced user” to execute different functions via a user. This is particularly interesting for conzept 16 developers, for example, to start special tools without always having to switch users.
sub ProcExecutable
(
aProcName : alpha(20); // Procedure
)
: logic; // Procedure may be executed (true)
local
{
tText : handle;
tExecutable : logic;
}
{
tText # TextOpen(16);
if (tText > 0)
{
// Check whether text exists and may be executed
tExecutable # tText->TextRead(aProcName, _TextProc | _TextNoContents) = _rOk and (
aProcName =^ 'DebugClient' or
aProcName =^ 'FTP' or
aProcName =^ 'LogFiles' or
aProcName =^ 'Manager' or
aProcName =^ 'XMLViewer'
);
tText->TextClose();
}
return (tExecutable);
}
main
()
local
{
tProcStart : alpha(20);
}
{
tProcStart # SysGetArg('proc_start');
if (tProcStart != '')
{
if (ProcExecutable(tProcStart))
{
Call(tProcStart);
return;
}
}
StartApp();
}
Note
The following names are already used by conzept 16, but can also be queried using the command SysGetArg():
/c16=<path>
Path of the program files/c16cfg=<path\file>
Location of the configuration file/c16tmp=<path>
Path for temporary files/c16lang=DE|EN|TR|*U
Display language in Designer (German, English, Turkish, depending on the operating system)/c16splashon=y|n(Standard:y)
Display splash screen on startup?/load_user_profile=y|n(Standard:y)
Load user profile?