I just learned how to use this proc (woohoo!), but I was sadly disappointed that I couldn't use it like this...
var/list/L1 = list("a","b","c")
var/list/L2 = L.Cut(2,3)
...to take the "b" out of L1 and place it into L2. It seems intuitive that a Cut() proc would also have some paste functioning built in if you would like to use it; like the Cut feature in the Windows environment. As it is, I have to use Cut() and Copy() to achieve the above effect.
=$= Big J Money =$=
ID:135764
Feb 29 2004, 3:09 pm
|
|
#define CutPaste(L1, L2, pos1, pos2) L2 = L1.Copy(pos1, pos2); L1.Cut(pos1, pos2) I think that should work. |
In response to Jon88
|
|
Jon88 wrote:
I think that should work. You'd have to be careful about how and where you used it. Use it on the same line with an if() and it won't work correctly. Better to create a proc. Lummox JR |
In response to Lummox JR
|
|
Yes, but you don't have to use it. If the list doesn't get used it gets cleaned up, right? WHOOSH.
L.Cut(2,3) ...would still function the same way it did before. There are LOTS of procs that return values that we rarely use the values on. =$= |
In response to BigJMoney
|
|
BigJMoney wrote:
Yes, but you don't have to use it. If the list doesn't get used it gets cleaned up, right? WHOOSH. And LOTS of games would slow down or malfunction altogether by relying on list.Cut() to function as it does now. There isn't really any point in changing it; it would screw up a lot for no good reason. Instead it makes more sense to just create your own proc and use that. proc/listcut(list/L, start=1, end=0) Lummox JR |
In response to Lummox JR
|
|
Lummox JR wrote:
proc/listcut(list/L, start=1, end=0) Sorry to butt in with a stupid question, but what is it doing? I thought that . was nothing more then the value to return if nothing else was specified. Shouldn't it be: proc/listcut(list/L, start=1, end=0) . = L.Copy(start, end) L.Cut(start, end) return . |
In response to DarkView
|
|
DarkView wrote:
Sorry to butt in with a stupid question, but what is it doing? I thought that . was nothing more then the value to return if nothing else was specified. proc/listcut(list/L, start=1, end=0) Yeef! I shouldn't have put in the return statement. Edited and removed. The "return ." line in your fix isn't needed though. Lummox JR |
In response to Lummox JR
|
|
Hey, if you're still around about this one. What DOES cut return? A 1 if it found and accomplished its task? I looked up its entry and it doesn't give return information. I don't know enought about procs to know if there are times when they can't return anything.
Thanks for the info, =$= |
In response to BigJMoney
|
|
If it doesn't say that it returns anything, it probably doesn't return anything (that is, it returns null).
|
I don't see this as being at all a good idea. Then every Cut() would involve creating a new list.
Lummox JR