Re: Collapse (?) An Array?

2011-09-01 Thread Bob Sneidar
No Scott you are missing a bit of information here. Try this: on mouseUp put "This is a test" into theArray[1] put "This is a second test" into theArray[2] put "This is a third test" into theArray[3] delete variable theArray[2] put the keys of theArray end mouseUp What you will get

Re: Collapse (?) An Array?

2011-09-01 Thread Bob Sneidar
Try instead: put the keys of theArray into myKeys put "2" is in myKeys See what you get. Bob On Sep 1, 2011, at 2:53 AM, Scott Rossi wrote: > Sorry, I don't know the correct verbiage here... > > If I script this: > > put "A" into theArray[1] > put "B" into theArray[2] > put "C" into theArray

Re: Collapse (?) An Array?

2011-09-01 Thread Bob Sneidar
I can put "put theArray[2]" into the message box and get empty, and I do not even HAVE an array called theArray! :-) Bob On Sep 1, 2011, at 5:13 AM, Colin Holgate wrote: > Try this in the multiline message box: > > put "A" into theArray[1] > put "B" into theArray[2] > put "C" into theArray[3]

Re: Collapse (?) An Array?

2011-09-01 Thread Richard Gaskin
Scott Rossi wrote: Recently, Richard Gaskin wrote: The delete is fine; the problem is in the display of the results. If you use: put theArray[1] &"*"&theArray[2] &"*"& theArray[3] ...you'll get the empty entry for theArray[2]. The variable theArray still exists, but there's nothing in t

Re: Collapse (?) An Array?

2011-09-01 Thread Scott Rossi
Recently, Jacque Landman Gay wrote: >> From what you're saying, it sounds like I need to put the remaining elements >> of the array into a temporary variable and then replace the original array. > > If that's what you need, then it might be easier to just combine the > array, remove the line you

Re: Collapse (?) An Array?

2011-09-01 Thread Andre Garzia
On Thu, Sep 1, 2011 at 12:18 PM, J. Landman Gay wrote: > On 9/1/11 9:10 AM, Scott Rossi wrote: > > From what you're saying, it sounds like I need to put the remaining >>> elements >>> >> of the array into a temporary variable and then replace the original >> array. >> > > If that's what you need,

Re: Collapse (?) An Array?

2011-09-01 Thread J. Landman Gay
On 9/1/11 9:10 AM, Scott Rossi wrote: From what you're saying, it sounds like I need to put the remaining elements of the array into a temporary variable and then replace the original array. If that's what you need, then it might be easier to just combine the array, remove the line you don't

Re: Collapse (?) An Array?

2011-09-01 Thread Colin Holgate
Yes, the "I think" part of what I said meant that to me it had over complicated things. Glad to hear that it was easy to understand for the others, and at least I had the personal breakthrough of realizing that anArray[10] doesn't refer to the tenth position of an array. On Sep 1, 2011, at 10:

Re: Collapse (?) An Array?

2011-09-01 Thread Scott Rossi
Recently, Richard Gaskin wrote: > The delete is fine; the problem is in the display of the results. > > If you use: > >put theArray[1] &"*"&theArray[2] &"*"& theArray[3] > > ...you'll get the empty entry for theArray[2]. The variable theArray > still exists, but there's nothing in that slo

Re: Collapse (?) An Array?

2011-09-01 Thread Admin
Collin, Perhaps to you I was over complicating things, but as I see it, that is what he was asking for. If you have nothing nice to say . . . Mike P.S. I am not an admin - when I joined the live code summer academy, they auto-assigned this forum name to me - it's not by my choice. On

Re: Collapse (?) An Array?

2011-09-01 Thread Dave Cragg
On 1 Sep 2011, at 14:48, Admin wrote: > 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 Looking ba

Re: Collapse (?) An Array?

2011-09-01 Thread Colin Holgate
I think Mike's explanation over complicated things! I now understand what Dave was saying, and the problem stems from us humans reading a "1" as an index into the array, and not a key of the array. In other languages you could say: put "hello" into theArray[10] and that array would now have te

Re: Collapse (?) An Array?

2011-09-01 Thread Richard Gaskin
Scott Rossi wrote: If I script this: put "A" into theArray[1] put "B" into theArray[2] put "C" into theArray[3] And then script this: delete variable theArray[2] I essentially get an array with entries that look like this: A C How can I collapse (?) the array after deleting element 2 so

Re: Collapse (?) An Array?

2011-09-01 Thread Admin
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)

Re: Collapse (?) An Array?

2011-09-01 Thread Dave Cragg
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

Re: Collapse (?) An Array?

2011-09-01 Thread Dave Cragg
On 1 Sep 2011, at 13:13, Colin Holgate wrote: > Try this in the multiline message box: > > put "A" into theArray[1] > put "B" into theArray[2] > put "C" into theArray[3] > delete variable theArray[2] > put theArray[1] &"*"&theArray[2] &"*"& theArray[3] > > > You'll see that although theArray[2

Re: Collapse (?) An Array?

2011-09-01 Thread Colin Holgate
Try this in the multiline message box: put "A" into theArray[1] put "B" into theArray[2] put "C" into theArray[3] delete variable theArray[2] put theArray[1] &"*"&theArray[2] &"*"& theArray[3] You'll see that although theArray[2] is deleted, its position is still kept. The way the dictionary de

Re: Collapse (?) An Array?

2011-09-01 Thread Dave Cragg
On 1 Sep 2011, at 10:53, Scott Rossi wrote: > Sorry, I don't know the correct verbiage here... > > If I script this: > > put "A" into theArray[1] > put "B" into theArray[2] > put "C" into theArray[3] > > > And then script this: > > delete variable theArray[2] > > > I essentially get an arr