How do you do it??

dunbarx at aol.com dunbarx at aol.com
Fri Dec 23 21:50:32 EST 2011


Of course.


I have overdone the "do" construction by not including the whole statement in quotes. I am so used to having to break out literals from variables, reassembling them meticulously into a single line, that I missed this very expected result.


Thanks...


Craig



-----Original Message-----
From: Bob Sneidar <bobs at twft.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Fri, Dec 23, 2011 1:20 pm
Subject: Re: How do you do it??


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"
Bob



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:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 



More information about the Use-livecode mailing list