If I correctly understood, the flag field is to find arguments. If it remains "nil", the argument was not found, otherwise, it's a pointer to the short option.
2012/10/30, Henry Vermaak <henry.verm...@gmail.com>: > On 30/10/12 10:05, luciano de souza wrote: >> Hello listers, >> Getopts offers very good features to process commandline arguments. As >> far as I could understand, I used it successfully. But it remains one >> unknown aspect for me. What is the field "flag"" of TOption record? >> How to use it? >> >> TOption = Record >> Name : String; >> Has_arg : Integer; >> Flag : PChar; >> Value : Char; >> end; > > I think the man page for getopt explains best how this is supposed to work: > > flag specifies how results are returned for a long option. If flag is > NULL, then getopt_long() returns val. (For example, the calling program > may set val to the equivalent short option character.) Otherwise, > getopt_long() returns 0, and flag points to a variable which is set to > val if the option is found, but left unchanged if the option is not found. > > Henry > _______________________________________________ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > -- Luciano de Souza _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal