type | range | bytes | to define | to convert |
byte | 0 to 255 | 1 | b=15B | b=byte(x) |
integer | -32768 to +32767 | 2 | i=15 | i=fix(x) |
long | -2147483648 to +2147483647 | 4 | j=long(15) | j=long(x) |
j=147483647 | ||||
floating pt | ![]() |
4 | y=1.7 | y=float(x) |
double prec. | ![]() |
8 | y=1.7d0 | d=double(x) |
complex | two floating point no.s | 8 | z=complex(1.2,0.3) | z=complex(x) |
string | (used for text) | 0-32767 | s='blah' | s=string(x) |
To convert one variable form to another use fix. Eg
str_var=fix(153.15,type=7) ;sets str_var to a string help,str_var ;STR_VAR STRING = ' 153.150'; shows that it is a string, but it has much white space ;remove this with str_var=strtrim(str_var,2); 2 removes white space from the front and back(I do this so often that I have a routine called trmfix that combines fix,type=7 and strtrim).
IDL is a dynamically typed language (you don't declare all variables first like you do in Fortran).