Table of Contents

Name

nemoinp - parse a user supplied number string

Synopsis

nemoinp [parameter=value] ...

Description

nemoinp parses an expression supplied by the user, using the rules as given by nemoinp(3NEMO) . The output format can be defined too, separators, newlines etc. can be choosen at will.

It may come in handy to set an array in a shell variable or to initialize tables, e.g. set x=(‘nemoinp 1:10:2‘) will then result in x having 1 3 5 7 9. (this is unfortunately different from the matlab convention, where this would be written 1:2:10 instead, see also seq(1) , where the syntax is seq 1 2 10.

Parameters

The following parameters are recognized in any order if the keyword is also given:
expression=expr-string
expression to be parsed [default: empty ].
separ=string
The string which is appended to the format string described in previous keyword and is used to separate the numbers output. When no string is supplied, a blank is used. [default: empty].
format=string
Valid C-format descriptor used in printf(3) to output the numbers. When %d is used, integer math is forced. See also next keyword for output number separator. [default: %g].
newline=t|f
Should a newline be added after each number parsed. This is often useful in cases nemoinp is used to generate the independant coordinate when tables have to be generated from scratch. [Default: t].
nmax=integer
Size of scratch array to be allocated dynamically for the parsed number [default: 32768].
tab=table_file
Optional table output. Default: none
seed=initial_seed
Seed for xrandom(3NEMO) . Default: 0
atof=
Merely provided to test what natof returns. Note that this function does not perform any error checking and can return the wrong number.
dms=t|f
Force parsing the (optionally comma separated) string(s) as D:M:S.S, converting them to fractional degrees. For H:M:S parsing the user is responsible for the extra factor of 15. Default: f.

See Also

seq(1) , tabmath(1NEMO) , nemoinp(3NEMO) , getrange(3NEMO) , functions(5NEMO)

Examples


   nemoinp 4.2+3.1           simple math
   nemoinp ’sqrt(2)’         math functions
   nemoinp pi+3              some support for funny numbers
   nemoinp 2:20:4            from 2 to 20 in steps of 4 (NEMO command)
   seq 2 4 20                from 2 to 20 in steps of 4 (UNIX command)
   set n=20                  a C-shell variable
   nemoinp 2:${n}:4          as before, now using a shell variable
   nemoinp 2::4              repeat the value 4 times
   nemoinp ’iflt(1,2,3,4)’   print 3, not 4, because 1 is less than 1
   nemoinp 30:30:15 dms=t    convert hexasegimal 30:30:15 into decimal
30.5043
   nemoinp c,G,h,p,m         a few good constants
   nemoinp ’p*pi/(3600*180)’ 1 AU in km

Author

Peter Teuben

Update History


18-apr-89    V1.0 created    PJT
20-jun-89    V1.0a small changed - doc updated    PJT
 5-jul-89    V1.1 added nmax parameter    PJT
18-may-92    documentation
16-jun-97    V1.6 %d forces integer math    PJT
28-aug-00    V1.7 documented tab= and seed=    PJT
31-may-01    V1.8 added atof=    PJT
4-mar-03    V1.9 added dms=      PJT


Table of Contents