sâmbătă, 18 octombrie 2014

Expression operators

Expression operators
+ - / *
LT GT EQ NE LE GE
NOT AND OR
SIN COS TAN SQR POW NEGATE ASIN ACOS ATAN LOG ALOG ABS INT NINT

!s = 30 * sin(45)
!t  =  pow(20,2) raise 20 to the power 2 (=400)
!f = (match(name of owner,’LPX’)gt 0)

4.3.5 Operator Precedence
()
 * /
 + -
 EQ NE GT LT GE LE
 NOT
 AND
 OR
(60 * 2 / 3 + 5) = 45
n array element may itself be an array:  (Multi - dimensional Arrays)

!x[1] = 'Hello'
!x[2] = 'World'
!y[1] = 'fred'
!y[2] = 'cup'
!z[1] = !x
!z[2] = !y

q var !z[1][2]
<string> ‘world’

q var !z[2][2]
<string> ‘cup’

The PML1 way is:          VAR !Z ( ‘$!X’ + ‘$!Y’ ) 
The PML2 way is           !Z = !X + !Y
NOTE: in this case !Z is a REAL variable and !X and  !Y must be real.

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

!SurfaceArea = REAL()
!Partlength = 7
!PartWidth = 6
call !!Area(!PartLength, !PartWidth, !SurfaceArea)

define function !!Initialise()
 !TotalWeight = 0
 !!MaxWeight = 0
endfunction
call !!Initialise()

setup form !!view
  View .view1 plot width 41 hei 15
exit
exit

define method .view()
  !this.view1.borders = FALSE
  !this.view1.add('/c:\pmllib\ladder.plt')
endmethod

-----------------------------------------------------------------
Setup form !!stairfrm

   title 'Model stair'
   member .cyl is Dbref
   member .pos is Position
   !!stairfrm.callback  = '!!stairfrm.init()'
 
   view .diagram  PLOT height 10 width 36

   text .start ' Start Elevation Helical ' at xmin.diagram ymax+0.3 width 10 is real
   text .end   ' End Elevation Helical   ' at xmin.start ymax  width 10 is real
   text .name ' Name           ' at xmin.start ymax  width 10 is string
   text .height ' Height       ' at xmin.start ymax  width 10 is real
   text .width ' Width         ' at xmin.start ymax  width 10 is real

   Button .Ok 'ok'  at xmin.start ymax callback 'call !!stairfunc()' Ok
   Button .cancel |Cancel| at xmax form-size ymin.Ok CANCEL

Exit

Define Method .init()

  !this.height.val = 1200
  !this.width.val = 200


0 comentarii:

Trimiteți un comentariu

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More