[NAME] ALL.dao.tutorial.tips [TITLE] Programming Tips [DESCRIPTION] 1 Handling of command line arguments To handle command line arguments, one must define explicit main functions. With explicit main functions, the command line arguments will be parsed automatically according to the function parameters of these functions. For example, for a program to accept a number as command line argument, one can define the following main function, 1 routine main( arg : double ) 2 { 3 io.writeln( arg ); 4 } Then this script can be run in the following ways, 1 shell$ dao script.dao 123 2 shell$ dao script.dao arg=123 3 shell$ dao script.dao -arg=123 4 shell$ dao script.dao -arg 123 5 shell$ dao script.dao --arg=123 6 shell$ dao script.dao --arg 123 As shown in the example, parameter names can appear in the command line arguments. In fact, in the command line arguments, arg=, -arg= -arg, --arg= and --arg= are always interpreted as argument names which must match to parameter names in main functions. Main functions can be overloaded with different parameter lists. The one with parameter names and types compatible with a given command line argument list will be executed. So user can define difine different main functions to handle different command line arguments. To allow the script to accept any command line arguments, one can define a main function with variadic parameter list, for example, 1 routine main( ... as args ) 2 { 3 io.writeln( args ) 4 } then all the command line arguments will be passed to this main function as a tuple with variable name args.