0

type raygun( currentCharge as int, maxDamage as int, minDamage as int)

I couldn't find any examples demonstrating how to set the type's attribute to a default value when it is initialized. For example in this instance it would make sense to default the currentCharge to 100. I understand constants aren't supported at the moment, but I was wondering if there was a way to do this that I may not have considered.

dbergusa
  • 5
  • 1

1 Answers1

0

There is no automatic way to do it. You can however create a sub that will create the type and initialize it as required:

Dim rg As Raygun
rg = InitRaygun

Sub InitRaygun As Raygun
 Dim r As Raygun
 r.Initialize
 r.currentCharge = 100
 Return r
End Sub
Erel
  • 1,802
  • 2
  • 15
  • 58
  • Thanks, that is what I have been doing. I wasn't sure if I had been missing something. I have worked with languages that allowed something similar to Type raygun(currentCharge =100, maxDamage as int, minDamage as int). I just wasn't certain if it could be done here. – dbergusa Oct 22 '11 at 13:48