Problems with the DO command

Dar Scott dsc at swcp.com
Wed Aug 7 12:45:00 EDT 2002


On Wednesday, August 7, 2002, at 10:02 AM, Dar Scott wrote:

> I'm trying to understand what is happening here.  If we ignore the 
> into/after variations, it looks to me that the only difference is 
> the space between fld and the quote.  Is "do" parsing really that 
> fragile?
>
I tried it:

   ----------
local fieldName

on mouseup
   -- Added line to clear field
   put empty into field "myDisplay"
   processmytable "put empty into mytable[tx,ty]"
   -- changed multiplication to comma
   processmytable "put (tx,ty)&space into mytable[tx,ty]"

   -- Original problem (fails)
   #processmytable "put mytable[tx,ty] into fld "myDisplay""

   -- Klaus Solution (works)
   #processMyTable "put mytable[tx,ty] after last char of fld" & 
quote & "myDisplay" & quote

   -- Klaus Solution Variation (works)
   #processMyTable "put mytable[tx,ty] after field" & quote & 
"myDisplay" & quote

   -- Jan Solution (Variation) (works)
   #processMyTable "put mytable[tx,ty] after fld" && quote & 
"myDisplay" & quote

   -- Variable Method (functions, too) (works)
   #put "myDisplay" into fieldName
   #processMyTable "put mytable[tx,ty] after fld fieldName"

   -- Variable Method Variation (fails)
   -- This does not work; it creates a name with quotes in it.  Duh, Dar.
   -- The parentheses may be needed in calculated field names, though.
   #put "myDisplay" into fieldName
   #processMyTable "put mytable[tx,ty] after fld (quote & 
fieldName & quote)"

end mouseup

on processMyTable tcommand
global mytable
   repeat with ty = 1 to 10
     repeat with tx = 1 to 10
       do tcommand
     end repeat
   end repeat
end processMyTable

   ------------

To try a method uncomment the # lines for that method.

Klaus's method does work.  I can sleep now.

(I wonder if there are any conditions in which execution is faster 
when the loop text is wrapped around the command text and included 
in the do.  I wonder if it might be handy to include special text 
for quotes in the strings and then replace them before executing 
the loop.)

Dar Scott




More information about the use-livecode mailing list