Collapse (?) An Array?
Admin
admin at mfelkerco.com
Thu Sep 1 09:48:45 EDT 2011
I totally get what the OP wants, code-wise, I just cannot help make
it happen, but perhaps I can put it in my terms and help someone more
knowledgeable than me help him.
What he is saying, is that when a
variable is deleted from within the array, he needs the entire array
re-ordered (sorted) and moved up a notch to account for the now deleted
variable.
So, if A,B,C,D is the array with positions 1,2,3,4
and you
delete array variable 2
It will now look like this:
A,C,D
and the
array numbers are now:
1,3,4
He needs it to be
A,C,D
and
1,2,3
The C is now 2 and the D is now 3, so on and so forth across however
large the array is.
Now, does one simply re-write the array once the
deletion is made?
Not sure.
Note - if this is for a database and you
are dealing with IDs, then DO NOT RE-ORDER ANYTHING - you will break the
database (well, not literally until you do a SAVE - then you really will
break it). Just leave it as is. Databases can eventually be re-ordered
(re-indexed) once they are too large and riddled with holes, but until
then, just leave it alone.
Mike
On Thu, 1 Sep 2011 14:27:44 +0100,
Dave Cragg wrote:
> On 1 Sep 2011, at 14:16, Dave Cragg wrote:
>
>>
It seems using any key on an existing array will produce an empty value.
(I don't know if that's how it should behave. I guess the alternative
would be throwing an error.)
>
> Update: it seems the array doesn't
even need to exist. This also produces the same result:
>
> put "A"
into theArray[1]
> put "B" into theArray[2]
> put "C" into theArray[3]
>
delete variable theArray[2]
> put theArray[1] &"*"&otherArray[7] &"*"&
theArray[3]
>
> Cheers
> Dave
>
>
_______________________________________________
> use-livecode mailing
list
> use-livecode at lists.runrev.com [1]
> Please visit this url to
subscribe, unsubscribe and manage your subscription preferences:
>
http://lists.runrev.com/mailman/listinfo/use-livecode [2]
Links:
------
[1] mailto:use-livecode at lists.runrev.com
[2]
http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list