知识点:

 

(1)按情况转移选择

 

        SELECT...ENDSEL,块根据一个或多个CASE测试结果执行语句。SELECT块以SELECT语句开始,用一个可选的DFTCAS块语句包含的多个CASE块,并以ENDSEL语句终止。

 

(2)情况语句

 

        CASE...ENDCAS根据SELECT参数进行的测试结果,执行界定在CASE和ENDCAS语句之间的语句。

 

(3)默认情况语句

 

     仅当没有任何一个CASE子句在SELECT块中被激活时,DETCAS...ENDCAS块执行界定在DFTCAS和ENDCAS语句之间的语句。

 

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_参数传递

 

   第一个CASE语句后面的语句块,其文字参数等于SELECT语句参数的值,将一直执行,直到遇到ENDCAS语句,然后程序执行将在ENDSEL语句后的第一个语句处继续执行。如果没有CASE语句的文字参数等于SELECT参数,并且如果存在可选的DFTCAS,则执行DFTCAS语句和ENDCAS语句之间的语句。ENDSEL语句指定SELECT ... ENDSEL块的结尾。

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_情况语句_02

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_字符串_03

    

   为了确定相等性,CASE语句的文字参数必须与SELECT语句的参数具有相同的数据类型。如果论点不同,则它们不相等。如果两个参数都是字符串,则字符串必须具有相同的长度并包含相同的区分大小写的字符,它们的顺序相同。如果两个参数都是整数,则它们必须是相同的数字才能相等。

 

      SELECT ... ENDSEL块的功能如下。作为参数传递给SELECT语句的表达式将被计算一次,以确定整数或字符串。这个整数或字符串依次与每个CASE语句的文字参数进行比较。如果发现CASE和SELECT语句参数相等,则在CASE语句之后执行所有语句,直到遇到ENDCAS语句,此时将执行传递给ENDSEL语句之后的语句。在成功进行相等性评估后执行语句时,如果在ENDCAS语句之前遇到另一个CASE语句,则忽略CASE语句并继续执行,直到遇到ENDCAS语句。如果存在DFTCAS语句且SELECT参数与任何CASE参数之间未找到相等性,则执行DFTCAS语句之后的语句,直到遇到ENDCAS语句,此时将执行传递给ENDSEL语句之后的语句。如果DFTCAS语句不存在且SELECT参数与任何CASE参数之间没有找到相等性,那么SELECT ... ENDSEL块中的语句不会被执行。

 

SELECT..ENDSEL块中CASE语句的数量没有限制。

 

SELECT ... ENDSEL块中只能有一个DFTCAS语句

 

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_字符串_04

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_参数传递_05

DMIS5.2标准示例

 

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_情况语句_06

 

RationalDMIS实际案例:

 

1.分支选择 SELECT  CASE

DECL/INTGR,i

DECL/CHAR,50,tx

i=ASSIGN/10

SELECT/i

CASE/10

tx=ASSIGN/CONCAT('THE ACTUAL VALUE OF X IS: ',STR(i))

TEXT/OPER,tx

ENDCAS

CASE/20

tx=ASSIGN/CONCAT('THE ACTUAL VALUE OF X IS: ',STR(i))

TEXT/OPER,tx

ENDCAS

DFTCAS

TEXT/OPER,'X is not equal to the 2 cases'

ENDCAS

ENDSEL


2.分支选择  测量圆孔

 

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_参数传递_07

 

MODE/AUTO,PROG,MAN

DECL/COMMON, INTGR, KNPTN1

NAN = PROMPT/TITLE,'请输入要测量圆孔号',EDIT,KNPTN1

SELECT/KNPTN1

CASE/1

F(CIR1)=FEAT/CIRCLE,INNER,CART,0.0000,-0.0000,-4.2875,0.0000,0.0000,1.0000, 68.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR1), 5

ENDMES

ENDCAS

CASE/2

F(CIR2)=FEAT/CIRCLE,INNER,CART,55.0000,5.0000,-17.8453,0.0000,0.0000,1.0000, 8.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR2), 5

ENDMES

ENDCAS

CASE/3

F(CIR3)=FEAT/CIRCLE,INNER,CART,90.0000,-0.0000,-37.9710,0.0000,0.0000,1.0000, 8.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR3), 5

ENDMES

ENDCAS

CASE/4

F(CIR4)=FEAT/CIRCLE,INNER,CART,-33.0000,-38.0000,-3.1978,0.0000,0.0000,1.0000, 20.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR4), 5

ENDMES

ENDCAS

ENDSEL

 

3.选择测量圆孔(提示组功能)   字符

 

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_整型变量_08

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_情况语句_09

 

MODE/AUTO,PROG,MAN

DECL/COMMON,CHAR,255,C1

KNPTN1=PROMPT/GROUP,'请输入测量圆孔号',C1,'圆孔1','圆孔2','圆孔3','圆孔4'

SELECT/C1

CASE/'圆孔1'

F(CIR1)=FEAT/CIRCLE,INNER,CART,0.0000,-0.0000,-4.2875,0.0000,0.0000,1.0000, 68.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR1), 5

ENDMES

ENDCAS

CASE/'圆孔2'

F(CIR2)=FEAT/CIRCLE,INNER,CART,55.0000,5.0000,-17.8453,0.0000,0.0000,1.0000, 8.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR2), 5

ENDMES

ENDCAS

CASE/'圆孔3'

F(CIR3)=FEAT/CIRCLE,INNER,CART,90.0000,-0.0000,-37.9710,0.0000,0.0000,1.0000, 8.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR3), 5

ENDMES

ENDCAS

CASE/'圆孔4'

F(CIR4)=FEAT/CIRCLE,INNER,CART,-33.0000,-38.0000,-3.1978,0.0000,0.0000,1.0000, 20.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR4), 5

ENDMES

ENDCAS

ENDSEL

 

4.选择测量圆孔(提示组功能)    整型变量

 

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_整型变量_10

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_情况语句_11

MODE/AUTO,PROG,MAN

DECL/COMMON, INTGR, KNPTN2

KNPTN1=PROMPT/GROUP,'请输入测量圆孔号',KNPTN2,'圆孔1','圆孔2','圆孔3','圆孔4'

SELECT/KNPTN2

CASE/1

F(CIR1)=FEAT/CIRCLE,INNER,CART,0.0000,-0.0000,-4.2875,0.0000,0.0000,1.0000, 68.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR1), 5

ENDMES

ENDCAS

CASE/2

F(CIR2)=FEAT/CIRCLE,INNER,CART,55.0000,5.0000,-17.8453,0.0000,0.0000,1.0000, 8.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR2), 5

ENDMES

ENDCAS

CASE/3

F(CIR3)=FEAT/CIRCLE,INNER,CART,90.0000,-0.0000,-37.9710,0.0000,0.0000,1.0000, 8.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR3), 5

ENDMES

ENDCAS

CASE/4

F(CIR4)=FEAT/CIRCLE,INNER,CART,-33.0000,-38.0000,-3.1978,0.0000,0.0000,1.0000, 20.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR4), 5

ENDMES

ENDCAS

ENDSEL

 

 5.请输入要测量的圆孔号

 

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_实际案例_12

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_字符串_13

 

MODE/AUTO,PROG,MAN

DECL/COMMON,CHAR,255,C1

KNPTN1 = PROMPT/TITLE,'请输入要测量的圆孔号',EDIT,C1

SELECT/C1

CASE/'CIR1'

F(CIR1)=FEAT/CIRCLE,INNER,CART,0.0000,-0.0000,-4.2875,0.0000,0.0000,1.0000, 68.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR1), 5

ENDMES

ENDCAS

CASE/'CIR2'

F(CIR2)=FEAT/CIRCLE,INNER,CART,55.0000,5.0000,-17.8453,0.0000,0.0000,1.0000, 8.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR2), 5

ENDMES

ENDCAS

CASE/'CIR3'

F(CIR3)=FEAT/CIRCLE,INNER,CART,90.0000,-0.0000,-37.9710,0.0000,0.0000,1.0000, 8.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR3), 5

ENDMES

ENDCAS

CASE/'CIR4'

F(CIR4)=FEAT/CIRCLE,INNER,CART,-33.0000,-38.0000,-3.1978,0.0000,0.0000,1.0000, 20.0000

$$ Measurement points are created through nominal points

MEAS/CIRCLE, F(CIR4), 5

ENDMES

ENDCAS

ENDSEL

 

6.分支语句的作用及其应用

 

DECL/COMMON,CHAR,20,AAA

 

TEMPCHAR = PROMPT/TEXT,'你是怎么笑的',LIST,AAA,'哈哈','嘿嘿','呵呵','HOHO'

 

SELECT/AAA

 

CASE/'哈哈'
WRITE/DID(DEFAULTSCREEN),'性格爽朗'
ENDCAS

CASE/'嘿嘿'
WRITE/DID(DEFAULTSCREEN),'阴险~~~'
ENDCAS

CASE/'呵呵'
WRITE/DID(DEFAULTSCREEN),'没心没肺~~'
ENDCAS

CASE/'HOHO'
WRITE/DID(DEFAULTSCREEN),'上网上多了吧'
ENDCAS

 

ENDSEL

 

7.分支选择——列表选择

 

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_情况语句_14

 

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_参数传递_15

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_情况语句_16

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_情况语句_17

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_参数传递_18

RationalDMIS高级指令(按情况转移选择 SELECT  CASE)_整型变量_19