Yet Another Array Type question
Blitz3D Forums/Blitz3D Programming/Yet Another Array Type question
| ||
Hi, Been playing around when some custom lists and ran into something I dont understand. This code below Im using for an example: Type gridstore Field x End Type Dim grid.gridstore(50) For n=1 To 50 grid(n) = New gridstore grid(n)\x=Rand(1,100) grid(n) = New gridstore grid(n)\x=Rand(1,100) Next For grid(1)=Each gridstore Print grid(1) \x Next Now, all i want to do is retrieve the values in a given dimmed slot. In the example I want to retrieve the values of x posted to the grid(1)\x array but the list shows me the entire gridstore list [ grid(1) - grid(50) ]. Is what im doing impossible in blitz3d or am I doing something wrong here? thanks. |
| ||
Do this .... for n = 1 to 50 print grid(n)\x next or this ... for g.gridstore = each gridstore print g\x next Stevie |
| ||
I think you missed his question Stevie G. am I doing something wrong here? Yes. You are assigning grid(1) with an instance of a gridstore and then REassigning it to a different instance of a gridstore.SO, all of your 50 array elements point to only ONE gridstore instance. THEN, you are trying to retrieve only the instances assigned to the specific array element, but unfortunately FOR-EACH doesn't work that way. FOR-EACH will return ALL of the instances of that type, regardless of what variables you have used to reference them. If you want to have two type instances per array element then either do this: Type gridstore Field x1 Field x2 End Type Dim grid.gridstore(50) For n=1 To 50 grid(n) = New gridstore grid(n)\x1=Rand(1,100) grid(n)\x2=Rand(1,100) Next Print grid(1)\x1 Print grid(1)\x2or this: Type gridstore Field x End Type Dim grid.gridstore(50,1) For n=1 To 50 grid(n,0) = New gridstore grid(n,0)\x=Rand(1,100) grid(n,1) = New gridstore grid(n,1)\x=Rand(1,100) Next For instance = 0 to 1 Print grid(1,instance)\x Next |
| ||
Oops .. didn't look at his construct .. just the printing part. |
| ||
Thanks Wolron and Steve.. that section example you should Wolron is what I was trying to accomplish. Thanks ever so much ! |
| ||
Ah, "Ronnie Smith" - we need to have a little chat about BlitzTree3D, BlitzGrass3D and the overdue BlitzTree3D 2. Email me on the email in my User Profile. |
| ||
If it is still THE Ronnie Smith from (Ex)AlienCodec I bet there are hundreds that want to have a chat with him ;-) |
| ||
Yeh, I want to get things sorted out. I want to find out what deals have been done and what can be ressurrected. Currently, nobody is selling BlitzTree3D or BlitzGrass3D - so I suggest someone start selling them again. I find it odd that nobody is selling these 2 products. The other stuff that TGC are selling is still all copyrighted to "Ronnie" - TGC are not mentioned in the licence. If nobody wants to sell BlitzTree3D or BlitzGrass3D then I think they should be made freeware, thus making "Ronnie" a Blitz Legend and easing the loss of anyone who has lost out with purchases of products prior to the move to TGC. Whatever the way forward, I want BlitzTree3D or BlitzGrass3D available - freeware or not. Plus - I want BlitzTree3D 2. |
| ||
And I still look out where I can get the PlantLife Modules from. Yes - and Freeware would be nice after all that trouble... ;-) |