TYPE 2 object collections of same TYPE
BlitzPlus Forums/BlitzPlus Programming/TYPE 2 object collections of same TYPE
| ||
Try this code Why is x\x the same as w\x I would like them not to be the same. I want to create two independent collections of the same TYPE. Who do you do that Can anybody help? Type CHAIR Field x, y End Type w.chair = New chair w\x = 5226 test() renderworld() WaitKey End ;------------------------------- Function test() For w.chair = Each chair Print "test" w\x = w\x + 1 Next End Function Function renderworld() For x.chair = Each chair ; do you think the following statement will executed. Print "renderworld" Print x\x Next End Function |
| ||
Simply as this. Type CHAIR Field x, y End Type Type CHAIR_X Field x, y End Type Done :) |
| ||
Actually, I'm surprised that your code ran at all. Technically, you never created the x type, only the w type. In other words, you had:w.chair = New chairBut you forgot: x.chair = New chairUnless you simply forgot to add that when you entered it in the forums, that's probably your whole problem; you were calling a field from a type that didn't exist. |
| ||
Thanks ADAM That's what you showed is what I ended up doing. The example code does run. I just copied and pasted to test. I am running the BlitzBasic not the Blitzplus, |
| ||
No problemo, Dan60. One thing you should know is that calling your functions RenderWorld() can be a bad idea, because if you ever import your code to Blitz 3D, RenderWorld is a built-in command, so your program won't run. As long as you stick with B2D, though, it should be fine. |