Dim command gone ?
BlitzMax Forums/BlitzMax Programming/Dim command gone ?
| ||
I've used the DIM command in my little proggie, but get the compile error: COMPILE ERROR - IDENTIFIER 'DIM' NOT FOUND ' So.. does this mean DIM isnt supported ? (or am I just using it wrong) Also.. TYPES, are these used any differently in Blitzmax to BB/BB3D ? This is soo much easier to do in C: struct { float x float y } object[5] |
| ||
HO ; yap its gone use this example global a#[1000,10,1] |
| ||
See the "Differences Between Blitz3D and BlitzMAX : Language" article on the http://www.blitzwiki.org site (it is in the Getting Started section) |
| ||
I'll check it out |
| ||
ok.. I've got some code working from reading up, but I've got a few questions - if ya dont mind.. whats the difference from using the field and global ? eg.. Type obj Global x:Float Global y:Float End Type ----- Type obj Field x:Float Field y:Float End Type Both methods seem to work, and do the same thing ?. then theres the local/global bit when declaring .. global game_objects:obj [100] ----- local game_objects:obj [100] Sorry for all the questions, just trying to understand it better. |
| ||
if there is a global x in the type, then there is only 1 x for every instance. if x is a field then every instance has its own x |
| ||
A "Field" variable in a type relates to a particular object, whereas "Global" variables 'belong' to the type itself, and not to any particular object. For example, if we had a SpaceShip type, we might use Field to store the x and y positions, because they will be different for each SpaceShip object, but Global to store the image for the SpaceShip, since that will be the same for each object. Type SpaceShip Global _image:TImage Field _x Field _y End Type SpaceShip._image=LoadImage("spaceship.png") Local ship1:SpaceShip=New SpaceShip Local ship2:SpaceShip=New SpaceShip ship1._x=0 ship1._y=0 ship2._x=100 ship2._y=100 Regarding Local / Global: In the your code, game_objects if declared in the main body of your program would be available to all of the Functions in your program if you used "Global", but only to the main body of the program if you used "Local". Inside functions you should use "Local" |
| ||
Aha...Nice one! I was wondering about the Field vs Global thing too :o) |
| ||
In your main code, you should always try to use as many Locals as possible, as they provide a huge speed increase over Globals. |