Unit 'amigados' Package
[Overview][Constants][Types][Procedures and functions][Index] [#aros]

ReadArgs

Read bytes of data from a file

Declaration

Source position: amigados.pas line 2335

function ReadArgs(

  const Template: PChar;

  Array_: PIPTR;

  RdArgs: PRDArgs

):PRDArgs;

Arguments

Template

  

Template string.

Array_

  

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

RdArgs

  

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.

Description

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:

/S
Option is a switch. It may be either set or left out.
/T
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).
/N
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.
/A
Argument is required. If it is left out ReadArgs() fails.
/K
The keyword must be given when filling the option. Normally it's skipped.
/M
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.
/F
Eats the rest of the line even if there are option keywords in it.

See also

FindArg

  

Find a keyword in a template

ReadItem

  

Reads a single argument/name from command line

FreeArgs

  

Free allocated memory after ReadArgs()

AllocDosObject

  

Creates a dos object

FreeDosObject

  

Frees an object allocated by AllocDosObject()


Documentation generated on: 2021-07-30