Ren Dexin
Space Science, ESS of USTC, China.
(一)结构体&链表
结构体
str1 = {strname,name:val} 结构体可以继承 str2 = {strname2,inherits str1,name:val}
链表
result = list(1,'2',list(1,'2'),[1,3,5]) list.add,value ;增加链表 value = list.remove[,indices][/all] ;删除链表 list1 + list2 ;链表连接
(二)程序设计
条件运算符 expr?Texrp:Fexpr循环语句(For,ForEach,While,Repeat)
Pro pro1,n = n Print,'at1' For i = 1, n, 3 Do Begin print,i EndFor Print,'at2' For i = 1, n, 3 Do print,i Print,'at3' arr = [1,3,5] ForEach element, arr Do print,element Print,'at4' i = 1 while 2*i < n Do Begin print,i endwhile Print,'at5' i = 1 Repeat Begin print,i Endrep until (2*i > n) n = 10 End (IDL控制台) IDL> .compile -v 'C:\Users\Rdx\Documents\idl\guide\pro1.pro' % Compiled module: PRO1. IDL> pro1,n = 5 at1 1 4 at2 1 4 at3 1 3 5 at4 at5 1 IDL>条件语句(If,Case,Switch)
Function fun1,n = n Print,'请输入一个数' Read,value Print,'at1' if(n > value)Then Begin Print,n Endif Else Begin print,value Endelse ;case自动跳出 ;switch break跳出 Return,n End (IDL控制台) IDL> .compile -v 'C:\Users\Rdx\Documents\idl\guide\fun1.pro' % Compiled module: FUN1. IDL> a = fun1(n = 3) 请输入一个数 : 5 at1 3 另一个函数 ;pro SDF, win_n = win_n, File_name = File_name, $ ; X_size = X_size, Y_size = Y_size ; idl> window,1,xsize = 1000,ysize = 600 ; idl> plot,findgen(100) ; idl> sdf, 1, 'c:\users\rdx\documents\idl\myclass\new.bmp',1000, 600 pro SDF,win_n,File_name,X_size, Y_size wset,win_n File_name = STRCOMPRESS(File_name) dot_pos = strpos(File_name,'.') fig_format = strmid(File_name,dot_pos+1) data = TVRD(0,0,X_size,Y_size,/true) CASE fig_format of 'bmp':begin write_bmp,File_name,data end 'png':begin write_png,File_name,data end ENDCASE ;write_bmp ;write_pict ;write_srf ;write_png ;write_tiff ;write_jpeg ;write_ppm ;writeu ;write_interfile End跳转语句(Break,Continue,Goto)
goto break continue 使用方法同c语言