Re(2): problem with for...in

Jan M.J. Storms jan at storms.org
Sun Nov 3 10:05:33 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".

If one tries to delete "item #1" first one has to be certain that it is
not a "real" item.

Sam's workaround doesn't work in this case, because sizeOf(myTable)
returns a value of 1, even though the item is not "real".

Still better would be to eliminate the glitch.

Thanks everyone,

Jan




More information about the Frontier-Users mailing list