BCX Console Demonstration Program s154.bas

 '======================================================================= 
 '          Semi-OOP implementation for BCX by Kevin Diggins  
 '======================================================================= 
 
 TYPE FOO
    MyVar
    FUNCTION Squared (MyClass AS FOO_CLASS) AS INTEGER
    FUNCTION Cubed   (MyClass AS FOO_CLASS) AS INTEGER
    FUNCTION TimesX  (MyClass AS FOO_CLASS, X AS INTEGER) AS INTEGER
  END TYPE
 
  DIM IAm AS FOO : Initialize(&IAm, 3)
  DIM You AS FOO : Initialize(&You, 4)
 
  CLS
 
  PRINT "================="
  PRINT "IAm.Squared " , IAm.Squared(&IAm)
  PRINT "IAm.Cubed " , IAm.Cubed(&IAm)
  PRINT "IAm.TimesX " , IAm.TimesX(&IAm, 100)
  PRINT "================="
  PRINT "You.Squared " , You.Squared(&You)
  PRINT "You.Cubed " , You.Cubed(&You)
  PRINT "You.TimesX " , You.TimesX(&You, 100)
  PRINT "================="
 
  PRINT "Changing .MyVar in IAm and You"
 
  IAm.MyVar = 6
  You.MyVar = 7
 
  PRINT "================="
  PRINT "IAm.Squared " , IAm.Squared(&IAm)
  PRINT "IAm.Cubed " , IAm.Cubed(&IAm)
  PRINT "IAm.TimesX " , IAm.TimesX(&IAm, 100)
  PRINT "================="
  PRINT "You.Squared " , You.Squared(&You)
  PRINT "You.Cubed " , You.Cubed(&You)
  PRINT "You.TimesX " , You.TimesX(&You, 100)
  PRINT "================="
 
 
  SUB Initialize(ME AS FOO_CLASS, b AS INTEGER)
    WITH ME
      .MyVar = b
      .Squared = Squared
      .Cubed = Cubed
      .TimesX = TimesX
    END WITH
  END SUB
 
 
  FUNCTION Squared(ME AS FOO_CLASS)
    FUNCTION = ME.MyVar * ME.MyVar
  END FUNCTION
 
 
 FUNCTION Cubed(ME AS FOO_CLASS)
    FUNCTION = ME.MyVar * ME.MyVar * ME.MyVar
  END FUNCTION
 
 
 FUNCTION TimesX(ME AS FOO_CLASS, X)
    FUNCTION = ME.MyVar * X
  END FUNCTION