help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getopt


From: Judd Storrs
Subject: Re: getopt
Date: Sat, 10 Oct 2009 18:34:56 -0400

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]