[Overview][Constants][Types][Procedures and functions][Index] Reference for unit 'amigados' (#aros)


Read bytes of data from a file


Source position: amigados.pas line 2379

function ReadArgs(

  const Template: STRPTR;

  Array_: PIPTR;

  RdArgs: PRDArgs





Template string.



Array to be filled with the result values. The array must be intialized to the default values before calling ReadArgs().



An optional RDArgs structure determining the type of input to process.

Function result

A handle for the memory allocated by ReadArgs(). Must be freed with FreeArgs() later.


Parses the commandline, a given string or DosInput() and fills an argument array according to the options template given. The array must be initialized to the wanted defaults before each call to ReadArgs(). If the rdargs argument is nilReadArgs() tries to parse the commandline and continues on the input channel if it just consists of a single '?', prompting the user for input.

The template string is given as a number of options separated by ',' and modified by '/' modifiers, e.g. 'NAME,WIDTH/N,HEIGHT/N' means get a name string and two numbers (width and height). The possible modifiers are:

Option is a switch. It may be either set or left out.
Option is a boolean value. Requires an argument which may be "ON", "YES" (setting the respective argument to 1), "OFF" or "NO" (setting the respective argument to 0).
Option is a number. Strings are not allowed. If the option is optional, a pointer to the actual number is returned. This is how you know if it was really given. The number is always of type LONG.
Argument is required. If it is left out ReadArgs() fails.
The keyword must be given when filling the option. Normally it's skipped.
Multiple strings or, when used in combination with /N, numbers. The result is returned as an array of pointers to strings or LONGs, and is terminated with NULL. /M eats all strings that don't fit into any other option. If there are unfilled /A arguments after parsing they steal strings from /M. This makes it possible to, for example, write a Copy command template like 'FROM/A/M,TO/A'. There may be only one /M option in a template.
Eats the rest of the line even if there are option keywords in it.

See also



Find a keyword in a template



Reads a single argument/name from command line



Free allocated memory after ReadArgs()



Creates a dos object



Frees an object allocated by AllocDosObject()

Documentation generated on: 2017-01-10