123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|106|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> type help

Wed, 28 Feb 2007, 17:55
dna
I am using this code


and wanted to know how to remove an element?

-=-=-
DNA
Wed, 28 Feb 2007, 18:06
mike_g
Delete this.array?

Never tried using an array in types like that myself. Wouldent it be better just to have a load of "array"'s instead using a handle to get the one you want.

I aint that big & clever so i'm probably all wrong, but at least i got something to say

Oh yeah and from what I know once you define an array you cant redefine it. Mabe you could just shuffle the elements up leaving a space at the end for an extra element should you need it.


Wed, 28 Feb 2007, 18:12
power mousey

hey mike,

how true. I'll leave this to you and others.
I'll be learning more of and concentrating on Cobra.

Yet, thank you dna. Its motivating me
to look into record types and other data containers
in Cobra.

cheers to you both,
Wed, 28 Feb 2007, 18:35
steve_ancell
I was trying to solve this one on another site, if this is the same person. I was'nt sure if Delete this(i) was actually trying to delete the array and not the Type entry.
Wed, 28 Feb 2007, 18:43
power mousey

yeah,

you and mike are right. You can delete a whole object.
and also delete each instance of an object with Delete Each.
and also, iterate thru with that special Each loop too.

I don't know if dna wants to delete each instance in the array and/or the contents only of that instance in the array. esentially, leaving the same number of items in the array but destroyinhg the type contents of the instance.

Wed, 28 Feb 2007, 18:46
steve_ancell
Personally, I would just set all the elements of that particular entry as NULL. That's the only solution I can think of ATM.
Wed, 28 Feb 2007, 18:56
power mousey

yeah, absolutely, steve. absolutely.

you're right. its an array.
its set for 10 items....0 to 9.
you can set,assign,delete the contents
of each element of the array.
Even, setting the range withing the min of 0 and the max of 9...10 elements.
Yet, true about seeting Null to the type instance of each one within the whole array. true.

Now, it would be a different story if instead of an array.
It was a linked list instead.

I was thinking about them too.

Thu, 01 Mar 2007, 01:22
steve_ancell
I actually tried the statement Delete this(5), it MAVs out.

|edit| It did with the code at the top of this page anyway |edit|
Thu, 01 Mar 2007, 04:38
JL235
I find looping through types in an array is over 10 times faster then through the type list, so even with elements missing it'd still (usually) be far faster then iterating through the type list.

Agent Smith, I believe your completely wrong. However, if you only set the array to null then there is still a second reference in the type list, so it will not be reclaimed. So you just tell Blitz to delete the type using the reference in the array, just as you would with the same reference when iterating through the type list.


Thu, 01 Mar 2007, 06:45
JL235
You said Blitz does not reclaim memory, and that is what I was referring to when I said you were wrong. I'll agree this was not properly referred to, and in hindsight I'd say you were only partially wrong. You were right about how setting it to null will not remove the type from the memory.

My code snippet was proving my suggestion, to use delete instead of null (which was explained). My code snippet does this and then tests against null to prove there is no longer a reference. I had fully explained this (at least to a point where I understood the point being conveyed). But I'll note this, and in future I'll try to make my explanations a little simpler from now on.
Thu, 01 Mar 2007, 09:08
JL235
Well, that is a different statement to what you said before. But regardless of how Blitz reclaims memory, there would still be a reference to the type through the type list. So by setting the reference in the array to null, the memory would not be orphaned. So that's wrong.

Your previous original statement implied that Blitz does not recover memory, which is wrong. You've even said so above. If your statement was unclear, that is not my fault, so therefore your original statement is wrong regardless of your intended meaning.

This argument is also starting to sound as though it is about proving the other is wrong, which should not be the point. So I will be leaving this.

In summary, use delete whenever you want to remove a type. Never use null.
Thu, 01 Mar 2007, 14:42
dna
Thanks for the responses. I'll try your example tonight Agent Smith.
The solution that I was looking for was to delete the type element and not set it to null.

Thanks.

-=-=-
DNA
Thu, 01 Mar 2007, 15:57
JL235
After reading your latest comment, my respect for you Agent Smith has just risen dramatically. Previously I could have read your comment more thoroughly and stated my opinions clearer too. So I apologise for failing that.

But at least dna now knows the best way to sort his arrays of types.
Thu, 01 Mar 2007, 16:43
steve_ancell
@ dna... How are you liking this website ?.
Fri, 02 Mar 2007, 00:43
power mousey

yeah, dna, how do you like the site?

I hope you work out that program with those types.


cheers,
power mousey
Sat, 03 Mar 2007, 18:24
dna
Thanks Agent Smith. I'll try it tonight.