Re(2): problem with for...in
David A. Bayly
dbayly at udena.ch
Sun Nov 3 10:13:29 PST 2002
>Dave Winer wrote:
>
>>local (adr);
>>new (tabletype, @scratchpad.testtable);
>>for adr in @scratchpad.testtable {
>> dialog.alert (adr)}
>>
>>The dialog never appears, as one would expect.
>
>Run the script once, then comment out the second line. Double click on
>scratchpad.testtable. Run the script again. The dialog appears.
>
>David Bayly wrote:
>>This is an old and annoying glitch. You get item#1 when you open the
>>table in the IDE, perhaps there are other circumstances too, but
>>that's the major one.
>>
>>One work-around better than testing in the loop.
>>
>>
>>try {delete(@myTable.["item #1"])}
>>for adr in myTable {
>> adr^.myValue = "this string"}
>
>That was the case here. I accidentally had one of the tables I was
>looping through (a loop within a loop actually - lots of tables)
>expanded, so it was showing the "item #1".
I surmise that when the outline table was introduced a way was needed
to distinguish an open empty table from a closed empty table.
>
>If one tries to delete "item #1" first one has to be certain that it is
>not a "real" item.
It will be "real" if and only if you start creating items called
"item #1", not a good idea I suspect. The first item is is adr^[1]
no period.
>
>Sam's workaround doesn't work in this case, because sizeOf(myTable)
>returns a value of 1, even though the item is not "real".
Just so, that's the problem.
>
>Still better would be to eliminate the glitch.
>
>Thanks everyone,
>
>Jan
--
- David Bayly. Programmer and digest reader. dbayly at udena dot ch
Digest Readers do it once a day.
More information about the Frontier-Users
mailing list