newmethod.bmx 444 B

123456789101112131415161718192021222324
  1. ' Here's an example of using the optional New () method. You could just
  2. ' set the x field to have a default anyway (Field x = 100) but this shows
  3. ' that you can do other things too (in this case, print a message)...
  4. Type Oink
  5. Field x
  6. Method New ()
  7. Print "Setting the value of x..."
  8. x = 100
  9. End Method
  10. End Type
  11. ' Create an Oink object...
  12. o:Oink = New Oink
  13. ' Print out the value of x...
  14. Print o.x