首页/文章/ 详情

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

1年前浏览238

知识点:


(1)按情况转移选择


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


(2)情况语句


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


(3)默认情况语句


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



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

    

   为了确定相等性,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)

DMIS5.2标准示例



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.分支选择  测量圆孔


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.选择测量圆孔(提示组功能)   字符


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.选择测量圆孔(提示组功能)    整型变量


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.请输入要测量的圆孔号



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测量技术
ACT
著作权归作者所有,欢迎分享,未经许可,不得转载
首次发布时间:2023-07-02
最近编辑:1年前
山涧果子
大专 签名征集中
获赞 203粉丝 48文章 1203课程 0
点赞
收藏
未登录
还没有评论
课程
培训
服务
行家
VIP会员 学习 福利任务 兑换礼品
下载APP
联系我们
帮助与反馈