Re: loops
Re: loops
- Subject: Re: loops
- From: paulskinner <email@hidden>
- Date: Thu, 14 Feb 2002 15:54:11 -0500
On Thursday, February 14, 2002, at 03:11 PM, garbanzito wrote:
further, even in ancient programming practice, "i" would be
better understood if it held an integer value, rather than
text. i wonder how many people realize this shorthand is
derived from Fortran, where variable names starting with
i,j,k,l,m & n were implicitly integers.
Ah...Fortran...( looks off wistfully)
set theLines to (every line of document 1)
repeat with aLine in theLines
there is a subtle but important point here, well known to
experienced AppleScripters, which makes Mark's example much
more efficient and less prone to error ...
when assigned to a variable outside the repeat, "every line"
is evaluated only once, where the original example would
evaluate it on each cycle of the loop. in the case of a
large document, Mark's approach would be much faster.
I believe that to be a pig in a poke.
repeat with i in (my getList())
display dialog i
end repeat
on getList()
display dialog "returning your list, as asked."
return {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}
end getList
my only quibble (and i realize most people think this is
very personal), is that running words together dilutes the
effort at readability. i go to the effort to put underscores
between words (even in terse languages) within a variable
name (i'd use "the_lines" and "a_line").
snip
-- steve harley email@hidden
And I have to remove the underscores before I can even look at em
without it hurting. I cant stand having to drag to select variables. Not
to mention the 'a' or 'the' in those variables...Hey you're right...this
is very personal. :^)
--
Paul Skinner
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
References: | |
| >Re: loops (From: garbanzito <email@hidden>) |