Help with
BlitzPlus Forums/BlitzPlus Beginners Area/Help with
| ||
Translated from Portuguese into English with google translator. Sometimes we think we will never use a command. Until ... POW! I'm using classes, and need to put order. Of course, my code is more complex, but with a simple example, one can understand what I need. ;begin Type team Field man $ Field number End Type power.team = New team Power \ man $ = "General" Power \ number = 1 For r = 10 to 13 power.team = New team Power\man $ = "Soldier" Power\r number = next power.team = New team Power\man $ = "Captain" Power \ number = 2 For power.team = Each team Print power\man $ Print power\number Print "-------" next end The need is to put "Captain" in the second position. I tried for hours to get the "Insert" command, but really, it still fails. I am grateful to anyone who can help me in this. |
| ||
Insert puts an object into the specified location, pushing the rest of the items farther down the list. First and Last are at the ends of the list, and Before and After are relative to the given object. You can use After First to refer to the second position. Here is an example. Graphics 600, 400, 0, 2 Type thing Field n End Type For k = 1 To 4 t.thing = New thing t\n = k Next Text 200, 150, TheThings() Insert Last thing After First thing Text 200, 200, TheThings() Flip WaitKey Function TheThings$() Local s$, temp.thing For temp = Each thing s = s + " " + temp\n Next Return s End Function |
| ||
I had so understood, as your example is similar to the manual. But I discovered a very obvious way, (and weird), to do what I want. What he needed was not just place the object in the second position, as you put it in the example, but, where I put that on the tile! Hence, I tried a simple thing. To place the object in the third position, using the example you gave, I would do so: Insert Last thing After After First thing It's kind of weird, but it works well. On the other hand, you can move only the first and last object and can not do anything with the others. And the object I need to move is the means, not the ends. Even so, thank you for answering. I'll try something else here to find another way. Gracias Floyd! |