PDMS 12.0 编程基础ABC

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

下面是PDMS编程介绍

一个简单的Macro

NEW EQUIP /FRED

NEW BOX

XLEN 300 YLEN 400 ZLEN 600

NEW CYL DIA 400 HEI 600

CONN P1 TO P2 OF PREV

参数化宏Parameterized Macro

NEW EQUIP /$1

NEW BOX

XLEN $2 YLEN $3 ZLEN $4

NEW CYL DIA $3 HEI $4

CONN P1 TO P2 OF PREV

变量给属性赋值

New Pipe

Desc 'My Description'

Temp 100

Pspec /A3B

Purp PIPI

!desc = desc

!temp = temp

!pspec = pspec

!purp = purp

New Pipe

Desc '$!desc'

Temp $!temp

!pspec $!pspec

!purp $!purp

字符串方法实例

!line = 'hello how are you'

!newline = !line.after('hello').trim().upcase()

q var !newline

!newline = !newline.replace('how', 'where').replace('you', 'you?')

定义函数

define function !!Area( !Length is REAL, !Width is REAL ) is REAL !Area = !Length * !Width

return !Area $*函数!!Area有两个参数一个返回值Endfunction

练习-新建函数计算园的面积,测试函数

define function !!circleArea( !radius is REAL) is REAL

!Area = PI * pow(!radius,2)

return !Area

Endfunction

条件判断语句(If Construct)

!Type = Type

!OwnType = Type of Owner

IF (!Type eq 'BRAN') THEN

$P CE is Branch.

ELSEIF (!OwnType eq 'BRAN') THEN

$P CE is Branch member.

ELSE

$P CE is $!Type,Pls select Branch.

ENDIF

练习-条件判断

!n = 0

!type = type

if(!type eq 'BRAN') then

!href = href

!tref = tref

if(!href.set()) then

!n = !n + 1

add href

endif

if(!tref.set()) then

!n = !n + 1

add tref

endif

endif

if(!type eq 'NOZZ') then

!cref = cref

if(!cref.set()) then

!n = !n + 1

add cref

endif

endif

$p Total $!n reference

循环赋值

!Total = 0

Do !x From 1 To 100 By 1

!Total = !Total + !x

Enddo

中断循环Break

!Total = 0

Do !x From 1 To 100

!Total = !Total + !x

If(!Total gt 500) then

Break $*或者Break if(!Total gt 500) Endif

Enddo

用skip 跳过奇数

Do !x From 1 To 100

If(Int(!x / 2) NE (!x / 2)) then

Skip $*或者Skip If(Int(!x / 2) NE (!x / 2)) Endif

!Total = !Total + !x

Enddo

练习-跳转

!n = 0

label /start

!type = type

if(!type eq 'BRAN') then

!href = href

!tref = tref

if(!href.set()) then

!n = !n + 1

add href

endif

if(!tref.set()) then

!n = !n + 1

add tref

endif

endif

if(!type eq 'NOZZ') then

!cref = cref

if(!cref.set()) then

!n = !n + 1

add cref

goto cref

golabel /start

endif

endif

$p Total $!n reference

错误提示

Next

$p OK

错误处理(Error Handling)

Next

Handle (2,113)

$p Last element.

EndHandle

$p OK

数组(Array)

!Str = 'Benz,Bmw,Audi'

!BestCar = !Str.Split(',')

Q var ! BestCar

!BestCar[4] = 'Cadillac'

相关文档
最新文档