PML基础练习 PDF
PML基础练习 PDF
PML基础练习 PDF
一个简单的 Macro
变量给属性赋值
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
字符串方法实例
2007-6-5 1-12
PML 基础练习
定义函数
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
2007-6-5 2-12
PML 基础练习
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
Endif
Enddo
用 skip 跳过奇数
Do !x From 1 To 100
If(Int(!x / 2) NE (!x / 2)) then
Endif
!Total = !Total + !x
Enddo
练习-跳转
!n = 0
label /start
2007-6-5 3-12
PML 基础练习
!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
2007-6-5 4-12
PML 基础练习
!BestCar[4] = 'Cadillac'
!BestCar.Append('Lincoln')
赋值循环 Do value
索引循环 Do indices
do !n indices !BestCar
!Car = !BestCar[!n]
$p Array element $!n is $!Car
Enddo
管道排序
文件处理(Handling Files)
2007-6-5 5-12
PML 基础练习
!ResultArray.Append( !Column1)
Enddo
!Output = object FILE('%pdmsexe%def.txt')
练习-文件处理
显示输出窗口
一个简单的对话框(Form)
缺省构造方法(Constructor method)
2007-6-5 6-12
PML 基础练习
endmethod
endmethod
控件定位
控件定义
!modifyOnIcon = !!pml.getpathname('modmodeon16.png')
button .pick pixmap /$!modifyonicon at x0 ymax
exit
2007-6-5 7-12
PML 基础练习
设置控件初始值
!modifyOnIcon = !!pml.getpathname('modmodeon16.png')
button .pick pixmap /$!modifyonicon at x0 ymax
exit
define method .addvolumn()
!this.bran.val = true
!this.input.val = '1500'
endmethod
按钮的应用实例
!modifyOnIcon = !!pml.getpathname('modmodeon16.png')
2007-6-5 8-12
PML 基础练习
对话框控制属性-Apply
!modifyOnIcon = !!pml.getpathname('modmodeon16.png')
button .pick pixmap /$!modifyonicon at x0 ymax
exit
define method .addvolumn()
!this.bran.val = true
!this.input.val = '1500'
!this.ce.callback = '!this.ce()'
endmethod
define method .ce()
!this.cename.val = fullname
endmethod
define method .apply()
!dist = !this.input.val
!name = !this.cename.val
2007-6-5 9-12
PML 基础练习
多选框的应用实例
!modifyOnIcon = !!pml.getpathname('modmodeon16.png')
button .pick pixmap /$!modifyonicon at x0 ymax
exit
define method .addvolumn()
!this.bran.val = true
!this.input.val = '1500'
!this.ce.callback = '!this.ce()'
endmethod
define method .ce()
!this.cename.val = fullname
endmethod
define method .apply()
!name = !this.cename.val
!dist = !this.input.val
!elements = array()
if(!this.bran.val) then
var !elements append coll all bran Within Volume $!name $!dist
endif
if(!this.equi.val) then
var !elements append coll all equip Within Volume $!name $!dist
endif
var !names eval name for all from !elements
2007-6-5 10-12
PML 基础练习
列表框应用实例
!modifyOnIcon = !!pml.getpathname('modmodeon16.png')
button .pick pixmap /$!modifyonicon at x0 ymax
exit
define method .addvolumn()
!this.bran.val = true
!this.input.val = '1500'
!this.ce.callback = '!this.ce()'
!this.list.callback = '!this.doselection()'
endmethod
define method .ce()
!this.cename.val = fullname
endmethod
define method .apply()
!name = !this.cename.val
!dist = !this.input.val
!elements = array()
if(!this.bran.val) then
var !elements append coll all bran Within Volume $!name $!dist
endif
if(!this.equi.val) then
2007-6-5 11-12
PML 基础练习
var !elements append coll all equip Within Volume $!name $!dist
endif
var !names eval name for all from !elements
!this.list.dtext = !names
do !element value !elements
add $!element
enddo
endmethod
define method .doselection()
!name = !this.list.selection()
$!name
endmethod
Alpha Views
Volumn View
2007-6-5 12-12