How do you do it??
bobs at twft.com
Fri Dec 23 16:26:34 CST 2011
Hmmm lemme follow this as pseudo code:
when the mouse is clicked
put "AA" and a carriage return and "BB" into the variable "it"
on the first pass of a repeat loop, try to do the command put followed by the word "it" followed by the contents of the variable "it" (it's two lines you know) followed by into "temp1". The statement you are trying to "do" will look like this:
do put AA
BB into temp1
Well you see what went wrong don't you? The do command does not know what to do with what comes after AA. It cannot even compile it. This is why it is a MUCH better idea to put your command into a variable, and then do the variable. You could then have stepped through the code and seen what the DO command looked like before you tried to "do" it. It may seem like wisdom at first to try to mash all the code into one compact statement, but there is no gain in performance, and there is a HUGE downside of not being able to debug it.
Try this instead:
> on mouseUp
> get "AA" & return & "BB"
> -- get "AA"
> repeat with y = 1 to 2
> put "put" && line y of it && "into temp" & y into theCommand
> do theCommand
> end repeat
> answer temp1 & comma & temp2
> end mouseUp
You will get "AA,BB"
On Dec 23, 2011, at 1:43 PM, DunbarX at aol.com wrote:
> Why do LC (and HC for that matter) fail to process multi-line variables when using "do"?
> If the variable "it" contains one line, the "do" construction
> works fine, making numbered temp variables as needed. But if I try the routine with a multi-line "it", the handler
> will not compile.
> LC complains as: execution error at line 5 (do: error in source expression) near "put AA", char 1
> HC complains as well, that it cannot understand "BB".
> It seems that the routine breaks simply because of the other lines, that is,
> the next line in "it" is not understandable by the parser. I wonder why it bothers to look there.
> Don't tell me I need two levels of "do": (do "do put...) Just kidding, that fails also.
> Just asking.
> Craig Newman
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the use-livecode