Maths with variables

Hello,
I'm trying to write a while loop for a decimal value in tcsh which I know can't be done. Instead I want my increments to be one order of magnitude too large and then divide it by 10 when I use the variable. However, I don't know how to divide my variable and set it as another.

set RI_min = 10
set RI_max = 30
set RI_inc = 1

# Run Flex2d for each RI
set RI = $RI_min
echo "Calculating flexure for:"
while ($RI <= $RI_max)

@ RI = $RI + $RI_inc

I then want to set PI to equal RI/10 to use PI in another program so my PI values will range from 1.0 to 3.0.
Thanks

The bc(1) command can do scripted mathematics for you, e.g.:

$ RI=30
$ RESULT=`echo "scale=3; 10 / ${RI}" | bc`
$ echo $RESULT
.333

The above will work in BASH, Bourne and Korn shell.

So the script in Bourne would be:

RI_min=10
RI_max=30
RI_inc=1

# Run Flex2d for each RI
RI=${RI_min}
echo "Calculating flexure for:"
while [ ${RI} -le ${RI_max} ]; do
  RI=`expr ${RI} + ${RI_inc}`
  PI=`echo "scale=3; 10 / ${RI}" | bc`
  echo PI = ${PI}
done

and running this produces:

Calculating flexure for:
PI = .909
PI = .833
PI = .769
PI = .714
PI = .666
PI = .625
PI = .588
PI = .555
PI = .526
PI = .500
PI = .476
PI = .454
PI = .434
PI = .416
PI = .400
PI = .384
PI = .370
PI = .357
PI = .344
PI = .333
PI = .322

I'll leave you to translate it into tcsh if you must.

This site:
Math Commands
goes into more detail about calculations in scripts.