Navigation:  ThinBASIC Language > Data types and variables > TYPE (ord UDT User Defined Types) > UDT (User Defined Types) > UDT and Functions > UDT Functions >


Previous pageReturn to chapter overviewNext page




The optional _destroy function has two basic properties: automatically called once the variable goes out of scope does not take any parameters


Defining it in context of Point2D has no meaning, but we can use it to illustrate how it works:


TYPE Point2D
    ME.x = x
    ME.y = y
    msgBox strFormat$("Point2D Variable is being created with x = {1}, y = {2}"ME.x, ME.y)
  FUNCTION _destroy()
    msgBox "Point2D Variable is being released"

msgBox "Hello, I am about to call MyFunction"
msgBox "Hello, I finished calling MyFunction"
FUNCTION MyFunction()
  DIM p AS Point2D(1, 2)