next up previous contents
Next: A very simple plot Up: Section 1: A first Previous: A first program   Contents

Some simple sums

That wasn't a very useful program. Try writing a program to do some very simple maths. Open a file called simple_maths.pro and put the lines below in the file

print,5+3 

end

Then run this using ``.run simple_maths''.

Try this,

a=5
b=3
print,a*b 

end

then type ``help, a''. The result tells you that a is an integer.

Note that you can do all of this ``on the command line''. Just type,

a=4
b=2
print,a*b
At the IDL command prompt (``IDL>''). Being able to do things on the command line is one of the great strengths of IDL. You can for example read some data in, using some quite complex code, and then play around on the command line to see what you have and decide how you want to plot it. It also makes it very easy to debug -- you can put a ``stop'' in a program, play around and then continue with ``.con''.

Now use the IDL help (type ``?'') to look some more complex maths mathematical functions. How do you use, sin, cos and tan? Does IDL default to radians or degrees?

Although it can be hard to find things, IDL help (``?'') is normally the first place to look.


next up previous contents
Next: A very simple plot Up: Section 1: A first Previous: A first program   Contents
John Marsham 2009-12-07