加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

IDL case 语法【syntax】

(2012-09-22 14:18:14)
标签:

idl

it

分类: IDL
IDL的帮助中是这样的:

Syntax

CASE expression OF

    expression: statement

    ...

    expression: statement

[ ELSE: statement ]

ENDCASE

Examples

This example illustrates how the CASE statement, unlike SWITCH, executes only the one statement that matches the case expression:

x=2 
CASE x OF  
 1: PRINT, 'one'  
 2: PRINT, 'two'   
 3: PRINT, 'three'   
 4: PRINT, 'four'
ENDCASE

IDL Prints:

two
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
但是对于每个case中不止一句的话,
需要加上begin 和 end

Examples

x=2 
CASE x OF  
 1: begin 
  PRINT, 'one'
  y=x
  print, y
  end  
 2: PRINT, 'two'   
 3: PRINT, 'three'   
 4: PRINT, 'four'
ENDCASE


0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有