"do" statements and value function

Timothy Miller gandalf at doctorTimothyMiller.com
Sun Jun 19 18:58:07 EDT 2011


Hi Mike,

Thanks again.

On Jun 19, 2011, at 2:52 PM, Mike Bonner wrote:

> I don't know much about *do*, (I have been able to mostly avoid it so far)
> but there are cases where it does seem to be the right tool for the job.
> 
> The example of one of the more useful possibilities with do would be the
> creation incremented variable names.  The example in the dictionary though,
> seems to be slightly incorrect.
> 
> *do "put" && x && "into tNumberOfRecords" & x -- might become "put 3 into
> tNumberOfRecords"*

Assuming an unspecified repeat loop for incrementing variable x, is this equivalent to:

Put value(x) into tNumberOfRecords  ?

I also normally use "do" to create incremented container names. It now seems that you can do the same thing with "value" in a repeat loop. Not certain -- I'm pondering.

Are there things you can do with "do" that you can't do with "value"?

Maybe, in some cases, "do" would produce a more concise script.

The trouble with "do" is that I usually make mistakes with the quote constant, the & and && operators, spaces and quotation marks. After the "do" command is done evaluating, I end up with too many quotes and spaces or too few, or in the wrong places. Then I have to fuss with it until I get it right.

If my "do" statement is complex, I'll usually assemble a "do" statement in a variable. Then "answer myDoVar" When it looks right, I'll change it to "do myDoVar" That helps, but it's still a hassle.


Cheers,


Tim



> This would actually become* "put 3 into tNumberOfRecords3"* I believe. So in
> a loop you can create variable names on the fly using this method. In
> addition, you can have a fullblown multi-line script executed by *do* as
> long as you don't exceed the scriptlimits. It is true though, that *do* can
> be sidestepped in quite a few instances.
> 
> Don't know enough about uses of do to venture much more.
> 
> On Sun, Jun 19, 2011 at 3:10 PM, Timothy Miller <
> gandalf at doctortimothymiller.com> wrote:
> 
>> Aha! Didn't know about the merge function. Useful information. Thanks,
>> Mike.
>> 
>> I'm still wondering about the question at the top of my original message.
>> I'm trying to understand the "do" command better.
>> 
>> Is it true that the "do" command and the "value" function perform about the
>> same tasks in different ways? I.e., is it true that you can avoid "do" by
>> judicious use of "value"?
>> 
>> Cheers,
>> 
>> 
>> Tim
>> 




More information about the Use-livecode mailing list