Using command line arguments

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?

Klicken Sie hier, um die Nutzungsbedingungen für unseren Blog zu lesen.

Leave a Reply

Your email address will not be published. Required fields are marked *

Leave the field below empty!

Requests, questions or feedback are welcome:

Terms of use of the comment function in the blog

1. General information

Vectorsoft AG (‘Provider’) provides a public blog for Internet users (‘Users’) on the vectorsoft.de website. The public blog is intended for the exchange of information and ideas. Users who participate with contributions and comments undertake to comply with the blog terms of use and are responsible for the accuracy, appropriateness and freedom from legal infringements of their contributions. By using the comment function in our blog, you accept these terms of use.

2. Netiquette

We ask you to refrain from personal attacks and provocations based on other opinions. Please argue objectively and maintain a constructive discussion culture. Your comment should always be related to the topic in question in order to avoid digressions into other topics. Posting the same comment or several similar comments more than once is not permitted.

3. Prohibition of illegal content

By submitting your comment, you confirm that you are not violating any copyrights or other rights of third parties. Inciting, racist statements, instructions for criminal offences and their glorification, depictions of violence, pornographic content and statements that violate personal rights are prohibited.

4. No advertising

The use of the comment function is not permitted for commercial or party-political purposes. Advertising contributions of any kind will be deleted immediately.

5. Details of the name

When entering your name, pay attention to the principles mentioned above.

6. Source references

If you intend to publish quotes or contributions from third parties, please indicate the respective sources and explain how they relate to the blog post.

7. Violation of the terms of use

Posts that violate this policy will be deleted immediately. If you notice any violations yourself, please send us the link to the comment in question by e-mail to . We expressly point out that we will exclude individual users in the event of repeated or serious violations of these terms of use.

As of: Sept. 2024

Get your Trial Version now!

Test yeet free of charge

IHRE EVALUIERUNGSLIZENZ - JETZT ANFORDERN!

TESTEN SIE DIE CONZEPT 16 VOLLVERSION - UNVERBINDLICH und KOSTENFREI

Subscribe to our newsletter

[cleverreach_signup]
WordPress Cookie Notice by Real Cookie Banner