How to use the NO IVAR container

This forum is for posting of useful information
Post Reply
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

How to use the NO IVAR container

#1 Post by rdonnay »

This example shows how to add instance variables to a DC_Xbp*() class using the NOIVAR feature of Xbase++.

All DC_Xbp*() classes inherit from DC_XbaseParts which inherits from DC_NoIvarContainer().
ALL DC* commands utilize DC_Xbp*() classes.

This allows new iVars to be added on the fly without the need to subclass or to use normal variables.

When you click the button, the iVars will be displayed. The 3rd display is the DC_XbpPushButton() object
in the object inspector. Scroll through the object and note that the custom my* ivars are all members of the object.

This feature requires build 259 or later.

Code: Select all

#INCLUDE "dcdialog.CH"

FUNCTION Main()

LOCAL GetList[0], oButton

@ 0,0 DCPUSHBUTTONXP CAPTION 'Push me;I have custom iVars' SIZE 30,3 ;
      FONT '12.Arial Bold' ;
      COLOR GRA_CLR_WHITE, GRA_CLR_DARKPINK ;
      ACTION {|a,b,o|(DCMSGBOX o:myVar1, o:MyVar2, o:MyVar3), ;
                     DC_ArrayView(o:myDirectory), ;
                     DC_InspectObject(o:mySelf)} ;
      EVAL {|o|o:myVar1 := 'I am VAR 1', ;
               o:myVar2 := 'I am VAR 2', ;
               o:myVar3 := 'I am VAR 3', ;
               o:myDirectory := Directory(), ;
               o:mySelf := o}

DCREAD GUI FIT TITLE 'No Ivar test'

RETURN nil

* -----------

PROC appsys ; RETURN
The eXpress train is coming - and it has more cars.

Post Reply