Duplicate variable name
Blitz3D Forums/Blitz3D Beginners Area/Duplicate variable name
| ||
So i have been getting this problem, as the title suggests: it keeps saying "duplicate variable name". please help |
| ||
The syntax is wrong at the Type declaration. You can't assign values to fields there. At that moment you're just specifying how many Fields exist, what are their names and data types. To assign values you need an actual instance of that Type: Global xPos% = screenX / 2 Global yPos% = screenY / 2 Type Torpedo Field x% Field y% End Type myTorpedo.Torpedo = New Torpedo myTorpedo\x = xPos myTorpedo\y = yPos |
| ||
Interesting that the debugger doesn't throw an error if you assign a default value to the fields in a Type declaration, but the default values aren't assigned when you create an object of that type (the fields are zeroed by default). I wonder if Mark originally planned to allow for custom default field values, but didn't end up implementing it?Type torpedoes Field x = 1 Field y = 2 End Type torpedo.torpedoes = New torpedoes Print torpedo\x Print torpedo\y WaitKey End |