TMGOOWG ;TMG/kst/OO widget setup ;03/25/06 ;;1.0;TMG-LIB;**1**;04/25/04 ;"Note: this was concept code. But a better example now is the TMGW* code ;"Kevin Toppenberg MD ;"GNU General Public License (GPL) applies ;"------------------------------------------ ;"Object Widget setup code below ;"------------------------------------------ constrWidget(instanceName) ;"Purpose -- A constructor for object Widget ;"Input: objectType -- the NAME of the type of the object to be defined. ;" This should be a variable (global or otherwise) of the object. ;"Note: This function should not be called directly, but instead is called ;" via new^TMGOOL ;"Result: none <--- REQUIRED TO NOT RETURN A RESULT ;"Here we define the default values for vars and functions. ;"----------------All constructors should copy this format -------------------- new typeDef set typeDef=@instanceName@("TYPEDEF") set @typeDef@("Multiply")="wgtMultiply^TMGOOWG(x,y)" set @typeDef@("Divide")="wgtDivide^TMGOOWG(x,y)" set @typeDef@("Show")="wgtShowValue^TMGOOWG(x)" ;"-------------------------------------------------------------------------------- ;"Optional initialization of some instance-specific variables. set @instanceName@("MyVar1")=0 set @instanceName@("MyVar2")=0 set @instanceName@("MyVar3")=0 quit destWidget(instanceName) ;"Purpose: A destructor for object Widget ;" any needed clean up code would go here first. ;"Input: instanceName -- the name of the object instance to be deleted. ;" This should be the value returned from defWidget ;"Note: Don't actually delete the object here. Just perform code needed to ;" save the object variables etc. Anything neeed before the object ;" is deleted by delete^TMGOOL ;"----------------- ;" Here I would put code that needs to be called before destruction of the object. ;"----------------- quit ;"------------------------------------------ ;"Object Widget member functions below ;"------------------------------------------ wgtMultiply(x,y) ;"Widget member function ;"Note: function may depend on variable (with global scope) TMGthis, as a 'this' pointer to object calling quit x*y wgtDivide(x,y) ;"Widget member function ;"Note: function may depend on variable (with global scope) TMGthis, as a 'this' pointer to object calling quit x/y wgtShowValue(x) ;"Widget member function (with no return value, i.e. a procedure) ;"Note: function may depend on variable (with global scope) TMGthis, as a 'this' pointer to object calling write x,! quit 0