[AIT logo]

Institut für Astronomie und Astrophysik

Abteilung Astronomie

Sand 1, D-72076 Tübingen, Germany
[Uni logo]


GETOPT Source code in getopt.pro

GETOPT

Name
       GETOPT
Purpose
       Convert a string supplied by the user into a valid scalar or vector
Explanation
       Distinct elements in the string may be
       separated by either a comma or a space.  The output scalar
       or vector can be specified to be  either  integer or floating
       point.   A null string is converted to a zero.
Calling Sequence
     option = GETOPT( input, [ type, numopt, COUNT = ])
Input Parameters
       input   - string that was input by user in response to a prompt
               Arithmetic operations can be included in the string (see
               examples)
Optional Input Parameters
       type    - Either an "I" (integer) or an "F" (floating point) specifying
               the datatype of the output vector.  Default is floating point
       numopt  - number of values expected by calling procedure
               If less than NUMOPT values are supplied the output
               vector will be padded with zeros.
Output Parameters
       option  - scalar or vector containing the numeric conversion of
               the fields in the string INPUT.  If NUMOPT is not
               supplied, the number of elements in OPTION will
               equal the number of distinct fields in INPUT.
Keyword Parameters
       Count - integer giving the number of values actually returned by
               GETOPT.   If the input is invalid then COUNT is set to -1
Note
       (1) If an input is invalid, Count is set to -1 and the result is set
               to 999.
       (2) GETOPT uses the execute function to interpret the user string.
               Therefore GETOPT itself cannot be called with the EXECUTE
               function.
       (3) GETOPT has a hard limit of 10 tokens in the input string.
Example
       (1)   a = getopt( '3.4,5*4 ', 'I' )    yields   a = [ 3, 20]
       (2)   a = getopt( '5/2.', 'F', 5)      yields   a = [2.5,0.,0.,0.,0.]
       (3)   a = getopt( '2*3,5,6')           yields   a = [6.,5.,6.]
Revision History
       written by B. Pfarr, STX, 5/6/87
       change value of !ERR W. Landsman   STX,  6/30/88
       Converted to IDL V5.0   W. Landsman   September 1997

Last modified by pro2html on 2003 January 30 at 04:51 UTC

[Home Page] [Software, Documentation] [IDL Documentation] [Quick Reference] [Feedback]

Jörn Wilms (wilms@astro.uni-tuebingen.de)
Updated automatically