[fpc-pascal]using GetOpts

Rudolf Harney rudolf.harney at web.de
Wed Jan 7 15:46:01 CET 2004


Hi!
I want to use the getopts unit but I fear, I don't understand the docu: If I have long options, what is returned by getLongOpts? In the docu-example (see below), c can be '1', '2', '3', ... or #0 or 'a', 'b', ... I don't understand, what getlongopts='9' means.
Can soneone explain me, how to use getopts with two or three short and long options?

cut uot from units.pdf:
c := getlongopts ( ’ abc:d:012 ’ , at theopts [ 1 ] , optionindex ) ;
case c of
’ 1 ’ , ’ 2 ’ , ’ 3 ’ , ’ 4 ’ , ’ 5 ’ , ’ 6 ’ , ’ 7 ’ , ’ 8 ’ , ’ 9 ’ :
begin
wr i teln ( ’Got opt ind : ’ , c )
end ;
# 0 : begin
wr i te ( ’ Longopt ion : ’ , theopts [ optionindex ] . name ) ;
if theopts [ optionindex ] . has_arg >0 then
writeln ( ’ With value : ’ , optarg )
else
writeln
end ;
’ a ’ : writeln ( ’ Option a . ’ ) ;
’ b ’ : writeln ( ’ Option b . ’ ) ;
’ c ’ : writeln ( ’ Option c : ’ , optarg ) ;
’ d ’ : writeln ( ’ Option d : ’ , optarg ) ;
’ ? ’ , ’ : ’ : writeln ( ’ Error with opt : ’ , optopt ) ;
end ; { case }

Thanks, RUDOLF
-- 
Rudolf Harney

______________________________________________________________________________
Erdbeben im Iran: Zehntausende Kinder brauchen Hilfe. UNICEF hilft den
Kindern - helfen Sie mit! https://www.unicef.de/spe/spe_03.php





More information about the fpc-pascal mailing list