Re: how to get the zero's out of a list
Re: how to get the zero's out of a list
- Subject: Re: how to get the zero's out of a list
- From: Cal <email@hidden>
- Date: Fri, 9 Mar 2001 13:12:36 -0500
Jacco Rens <email@hidden> wrote:
--> becomes {"0", "1", "0", "4"}
set cell "B" of current record to A
--> becomes {"0", "1", "0", "4"}
but i want {"", "1", "", "4"}
How, oh how do i do this ?
Three people responded with essentially the same solution:
set a to {"0", "1", "0", "4"}
repeat with i from 1 to count (a)
if item i of a is "0" then set item i of a to ""
end repeat
set l to {"0", "1", "0", "4"}
repeat with i from 1 to length of l
tell item i of l to if it = "0" then set item i of l to ""
end
l
set aL to {"0", "1", "0", "2"}
repeat with i from 1 to number of items in aL
if item i in aL is "0" then
set item i in aL to ""
end if
end repeat
I am disappointed that the answers to such a question, asked by what
appears to be a novice, while offering something that works,
nevertheless include the use of variable names like "a", "l", and
"aL".
[Using "i", "1", and "l" in the same script fragment (and even in the
same line) makes it hard to distinguish what from what. The same can
be said for "i" and "a".]
When posting examples, particularly for newbies, be mindful that the
person asking the question may not just be interested in a piece of
script that they can copy and paste, but may be trying to understand
how something works. Try to remember what it was like when you were
first learning. Taking a few extra seconds to employ variable names
that are descriptive, indicating what the variables contain, can go a
long way toward making your examples understandable.
Respectfully,
Cal