Read from file, then display results

Alex Tweedly alex at tweedly.net
Thu Jul 15 08:19:14 EDT 2004


Hi Marian - I'm a bit late responding - hope it's not too late to be useful.

I hope I properly understood the question ...

At 21:53 07/07/2004 -0700, Mark Brownell wrote:

>on 7/7/04 7:30 PM, Marian Petrides at mpetrides at earthlink.net wrote:
>
> > I have two questions:
> >
> > 1)  What I would like to be able to do is:
> >
> > Figure out a more general way to specify number of iterations for the
> > repeat  (something like:  repeat with j = 1 to the number of words in
> > file "AddressList.txt"
> >
> > How do I do this?

and Mark said:

>yours:
>   put it into AddListContents
>   split AddListContents by tab
>   repeat with j = 1 to 6
>     put AddListContents[j] into line j of field "Results"
>   end repeat
>
>mine:
>   put it into AddListContents
>   set the itemDelimiter to tab
>   put 1 into thisSpot
>   repeat for each item j in AddListContents
>     put j into line thisSpot of field "Results"
>     add 1 to thisSpot
>   end repeat

It wasn't 100% clear from the context if the field Results already had 
anything in it or not (and if it did, whether you needed to preserve that). 
If you didn't, then you could simply do

>   put it into AddListContents
>   split AddListContents by tab
>   combine AddListContents with cr
>   put AddListContents into field "Results"

If you did have something in the field, and wanted to preserve it, then 
what you would be preserving is the lines after N (where N is the number 
being replaced here). So you'd need to do

>   put it into AddListContents
>   split AddListContents by tab
>   combine AddListContents with cr
>   delete line 1 to the number of lines in AddListContents
>   put AddListContents before field "Results"

But doing that made it clearer to me that this is over-complex. You could 
simply do

>   put it into AddListContents
>   replace tab with cr in AddListContents
and then
>   delete line 1 to the number of lines in AddListContents
>   put AddListContents before field "Results"

-- Alex.
-------------- next part --------------

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004


More information about the use-livecode mailing list