[fpc-pascal]Re: About GetOpts and configuration file parsing
    Yet Another Geek 
    yetanothergeek at yahoo.com
       
    Fri Jul 12 10:54:17 CEST 2002
    
    
  
(*
If your program only requires short (single-character)
options, 
then you can just add this line at the beginning of
your program:
    OptSpecifier:=['/'];
Not sure how you would handle multi-char (string)
options, though.
The problem is that the getopts unit follows the POSIX
standard, and most DOS programs do not .
The getopts unit decides if an option is a string
or a set of single-character options by whether 
the option begins with "-" or "--"
For instance, if the options are:
-a : Show the current date.
-b : Show the current time.
-c : Destroy the hard drive.
--abc : Tell a funny joke.
Then obviously, "-abc" and "--abc" 
will have completely different results !
So to use slashes with a mixure of single-char (short)
options
and multi-char (long) options you would need to
specify your
long options with '//' on the command line. This would
work, 
but it would look a little bit strange :
*)
program slashopt;
var
  I: integer;
begin
  { convert options from '/' to '-' before parsing ...
}
  for I:=1 to argc -1  do begin
    if ( argv[I] <> nil ) and ( argv[I][0] = '/' )
then  begin
      argv[I][0] := '-' ;
      if ( argv[I][1] = '/' ) then  argv[I][1] := '-' 
    end;
  end;
  { ... Now your command line is ready for the getopts
unit }
  
end.
 - Jeff
__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com
    
    
More information about the fpc-pascal
mailing list