[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: getopt
From: |
Juergen Rose |
Subject: |
Re: getopt |
Date: |
Sun, 11 Oct 2009 11:07:38 +0200 |
Hi Judd,
thank you for your hints, I am to tired now (it after midnight in
europe) I will test it tomorrow.
Juergen
Am Samstag, den 10.10.2009, 18:34 -0400 schrieb Judd Storrs:
> Suppose you have:
>
> #!/usr/bin/octave -qf
>
> ## Command line defaults
> opt.help = false ;
> opt.pdb = false ;
> opt.fileA = "" ;
> opt.fileB = "" ;
>
> ## Process command line options
> args = argv() ;
> i = 1 ;
> while i <= length(args)
> option = args{i} ;
> switch option
> case {"-h" "--help"}
> opt.help = true ;
> case {"-p" "--pdb"}
> opt.pdb = true ;
> otherwise
> break ;
> endswitch
> i++ ;
> endwhile
>
> if opt.help
> opt
> disp("Usage") ;
> exit(1) ;
> endif
>
> opt.fileA = args{i++} ;
> opt.fileB = args{i++} ;
> opt
>
>
>
> On Sun, Oct 11, 2009 at 3:22 AM, Juergen Rose <address@hidden>
> wrote:
> $ superimpose.m file1.csv file2.csv
>
> $ ./superimpose.m file1.csv file2.csv
> opt =
> {
> help = 0
> pdb = 0
> fileA = file1.csv
> fileB = file2.csv
> }
>
>
>
> $ superimpose.m -p file1.pdb file2.pdb
>
> $ ./superimpose.m -p file1.pdb file2.pdb
> opt =
> {
> help = 0
> pdb = 1
> fileA = file1.pdb
> fileB = file2.pdb
> }
>
>
> $ superimpose -h to print a help message.
>
> $ ./superimpose.m -h
> opt =
> {
> help = 1
> pdb = 0
> fileA =
> fileB =
> }
>
> Usage
>
>
- RE: getopt, (continued)
- RE: getopt, Juergen Rose, 2009/10/10
- Re: getopt, Ben Abbott, 2009/10/10
- Re: getopt, Juergen Rose, 2009/10/10
- Re: getopt, Ben Abbott, 2009/10/10
- Re: getopt, John W. Eaton, 2009/10/10
- Re: getopt, Juergen Rose, 2009/10/10
- Re: getopt, John W. Eaton, 2009/10/10
- Re: getopt, Judd Storrs, 2009/10/10
- Re: getopt, Juergen Rose, 2009/10/10
- Re: getopt, Judd Storrs, 2009/10/10
- Re: getopt,
Juergen Rose <=
- Re: getopt, Jaroslav Hajek, 2009/10/10
- Re: getopt, Juergen Rose, 2009/10/10
- Re: getopt, Carlo de Falco, 2009/10/11
- Re: getopt, Martin Helm, 2009/10/10