Why Doesn't This Work
Blitz3D Forums/Blitz3D Programming/Why Doesn't This Work
| ||
Hi Ive been busy at the weekend but have hit a problem this section of code don't work, why? dim vorton(5) for a=0 to 4 vorton(a)=loadmesh ("media\vorton.x) next a The array 'vorton' is defined and the object is in my media folder. Can I use arrays for my object pointers or am I missing something here.... Thanks |
| ||
Well, the reason why the code you've posted here does not work is easy. You've forgotten to terminate the string in loadmesh(): loadmesh ("media\vorton.x) should be: LoadMesh("media\vorton.x") And you can drop the 'a' in 'Next a' //PetBom |
| ||
vorton(a)=loadmesh ("media\vorton.x) Is missing a double quote before the ')'. next a Should just be 'next'. There's no need to specify the index variable used. dim vorton(5) You've dimensioned one more array element than you actually use. You need to specify the highest array element index in the 'Dim' statement, rather than the total number of elements to be created. The value returned by LoadMesh is not an object pointer, it's an entity handle. Entity handles are just integer numbers and can be stored anywhere you can store an integer value, including an integer array. Object pointers are the pointer values returned when you use the 'New' command to create a new 'Type' element. These can only be stored in variables, array elements, Type fields, etc, of the declared object type. |
| ||
Oops sorry about the missing quote that was a typo. Apart from that can I use arrays to store the entity handle, my Blitz 3d has been updated to v1.85 but the error still occurs. I need to use arrays for entity handle,zone,x,y,z. I keep getting 'memory access violation' when I use an array such as vorton(1) etc Thanks for helping |
| ||
Did you drop the 'a' in 'Next a' as advised by both me and Axeman? Other than that I can find no error with your code, provided that the "media\vorton.x" path is correct //PetBom |
| ||
This code is tested and works allright:Dim vorton(5) For a=0 To 4 vorton(a)=LoadMesh("media\vorton.x") Next Edit:(I noticed that you have a space in your code between 'loadmesh' and '("media\vorton.x")'. It shouldn't be there, but maybe that was also a typo. In future I advise you to cut n' paste the exact code you want people to check, to avoid wild goose chases caused by typos.) //PetBom |
| ||
Thanks, I'll cut and paste in future. |
| ||
Make sure 'Debug Enabled?' is ticked in the 'Program' menu in the Blitz editor (assuming you're using the standard Blitz editor) so you're getting detailed error messages from the debugger. As far as storing entity handles in arrays is concerned, the answer is yes, as I said in my first post. The array should be declared to store integer data, though, which it will be by default if you've ommitted any datatype declaration. |
| ||
>so you're getting detailed error messages from the >debugger. Hehe... detailed error messages... hehe... Andy |
| ||
Relatively detailed :-P |