|
|
fieldsep: CHAR; (* field separator *) delim: ARRAY 4 OF CHAR; (* used to read fieldsep *) selected: SET; (* selected set of fields *) fieldnum: INTEGER; (* used to read a field number *) arg: Streams.Stream; (* command line argument as stream *) option: CHAR; (* current command line option *) in: Streams.Stream; (* input stream *) pathname: ARRAY 512 OF CHAR; (* name of an input file *) |
![]() | Der Parameter einer Option kann mit Args.FetchString
oder Args.Fetch geholt werden.
|
(* set defaults *)
fieldsep := ASCII.tab; selected := {};
(* process options *)
Args.Init("[-d delim] {-f fieldno} {file}");
WHILE Args.GetFlag(option) DO
CASE option OF
| "d": Args.FetchString(delim); fieldsep := delim[0];
| "f": Args.Fetch(arg); Read.IntS(arg, fieldnum);
IF (arg.count > 0) & (fieldnum >= 1) &
(fieldnum <= MAX(SET) + 1) THEN
INCL(selected, fieldnum-1);
ELSE
Args.Usage;
END;
ELSE
Args.Usage;
END;
END;
|
|
| Copyright © 2004, 2005 Andreas Borchert, in HTML konvertiert am 18.02.2005 |