Difference between revisions of "Object Oriented Programming with M"

From VistApedia
Jump to: navigation, search
 
Line 1: Line 1:
[[OO Support Library]]
+
* [[OO Support Library]]
[[Definition of tWidget]]
+
* [[Definition of tWidget]]
  
 
<pre>
 
<pre>

Revision as of 05:36, 1 December 2005

;------------------------------------------
;Main function below
;------------------------------------------

MyFunct()
  new Widget  ;"will store all instances of object type Widget
  new tWidget set tWidget=$name(Widget)
  new pWidget1 ;"will store 1 instance of Widget
  
  set pWidget1=$$new^TMGOOL(tWidget,"constrWidget^TMGOOWG")
  
  new done set done=0
  for  do  quit:(done)
  . new x,y
  . read "input x (enter to quit): ",x,!
  . if x="" set done=1 quit
  . read "input y: ",y,!
  . if y="" set done=1 quit
  . write "> ",x," * ",y,"= ",$$fn^TMGOOL(pWidget1,"Multiply",x,y),!
  . write "> ",x," / ",y,"= ",$$fn^TMGOOL(pWidget1,"Divide",x,y),!
  . new temp set temp=$$fn^TMGOOL(pWidget1,"Show",x) 
  do delete^TMGOOL(pWidget1)

  write "That all folks!",!

  quit