可参考网站:https://www.harrisgeospatial.com/docs/begin___end.html
1.判断语句
1)
if (a gt b) then z=a else z=b
可写为:
z=(a gt b)?a:b
x=2
case x of
1:print,'one'
2:print,'two'
3:print,'three'
4:print,'four'
else:print,'no match'
endcase
IDL输出结果:
two
如果x=5,没有匹配的数值,不加else,就会出错,所以加上。但用下面的switch就不会出错,当然switch也可加else
3)
x=2
switch x of
1:print,'one'
2:print,'two'
3:print,'three'
4:print,'four'
endswitch
IDL输出结果:
two
three
four
4)因为switch的特点,所以其场合break搭配使用
x=2
SWITCH x OF
1: PRINT, 'one'
2: BEGIN
PRINT, 'two'
BREAK
END
3: PRINT, 'three'
4: PRINT, 'four'
else:print,'no match'
ENDSWITCH
idl输出结果:
two
2.循环语句
1)For:
Syntax :
FOR variable = init, limit [, Increment] DO statement
or
FOR variable = init, limit [, Increment] DO BEGIN
statements
ENDFOR
解释:init–初始值。limit–最大值。increment–间隔。
示例:
1)
IDL> for i=1,6,2 do print,i
结果:
1
3
5
IDL> for i=1,6,2 do begin
print,i
print,i+1
endfor
2.IDL搜索文件夹里的文件
参考网址:http://blog.sciencenet.cn/blog-344887-630319.html
https://malagis.com/idl-file-search-function.html