I've been playing about with DBC, and I've stumbled across a few things I didn't think it would allow:
1) Semi-dynamic arrays.
A function can alter the size (and perhaps also the number of dimensions) of an existing array. The array must have been dimmed at the top of the main code, otherwise DBC gives a compiler error, but this appears to work fine:
Dim Array(0)
GenerateArrays()
Print Array(4)
Wait key
End
Function GenerateArrays()
Rem this bit proves that an Array value may be used to determine the size of another array
Dim Test(0)
Test(0) = 500
Dim Array( Test(0) )
Array(4) = 5
EndFunction
As expected, the Redim will erase any existing data. I've been using this in my DarkGUI project, without any trouble, but I wanted to ask - is this really safe and/or stable?
2) Functions can use Gosub.
The Subroutine must be located inside the function, but cannot be accessed by any other part of the program. I find it quite handy for simplifying my function code in DarkGui, but again - is it safe?
Test()
wait key
End
Function Test()
GoSub Routine
ExitFunction
Routine:
Print "This is a subroutine"
return
EndFunction
3) Arrays can hold more data than you'd think...
Dim Array(5, 5)
Array(5) = 42
Print Array(5)
Wait key
End
You can write data at each dimension of the array - Lightning Limbs used it to log the keyframe with the associated XYZ rotation/offset/scale of each limb!
"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."