company logo

Setting options within an application

Options may be set while running an application. In order to avoid naming conflicts between options loaded from other sources and application options, application options should follow strict naming conventions, e.g. beginning with a defined prefix or by reserving a special section for application options.

Besides using application options for storing run-time information, any option loaded from another source may be overwritten by application options. In order to refer to any option, the complete option path has to be used as option name.

Options may be set in OSI functions or in any application program.

Setting options in OSI functions

OSI functions allow setting option values at run-time. Within an OSI function, one may refer to options as option variables, except, using the option path enclosed in %...%, or by using odaba::Option functions.

void main () { // referring to options via %...% option names

  %PROJECT_ROOT% = 'c:/odaba/my_projects'; // set option

  Message('Value for PROJECT_ROOT is: ' + %PROJECT_ROOT%);

}

void main () { // referring to options via Option functions

  Option("PROJECT_ROOT") = 'c:/odaba/my_projects';

  Message('Value for PROJECT_ROOT is: ' + Option("PROJECT_ROOT").toString );

}

void main () { // referring to options via Option variables

VARIABLES

  Option       prj_root("PROJECT_ROOT")

PROCESS

  prj_root.assign('c:/odaba/my_projects');

  Message('Value for PROJECT_ROOT is: ' + prj_root.toString );

}

Accessing options from within a program

In an application, one may set option values by mans of odaba::Option functions . In order to set or change an option value, Option:: assign() or the assignment operator ( = ) might be called.

  Option option("PROJECT_ROOT")

  option = "c:/odaba/my_project"; // option.assign("c:/odaba/my_project");

  printf( option.toString() );