• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: search and count
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: search and count


  • Subject: Re: search and count
  • From: "Arthur J. Knapp" <email@hidden>
  • Date: Mon, 18 Nov 2002 15:03:51 -0500

> Subject: search and count
> Date: Mon, 18 Nov 2002 09:21:11 -0500
> From: "Ruby Madraswala" <email@hidden>

> 1. open a text file. (Is simple text scriptable?)

SimpleText is not scriptable.

Is it a small file? Try and see if you can work with it all in memory
at once:

set myFile to (choose file) --> get the file you're working with

set myData to read myFile --> error if not enough memory

> 2. search for a word "Data" always the first word of a line.
> 3. if found count number of pipes "|" in that line.

set oldDelim to text item delimiters
set text item delimiters to "|"

set collectedCounters to {}

repeat with i from 1 to count each paragraph in myData

if ( myData's paragraph i starts with "Data" ) then

set x to count each text item in myData's paragraph i

> 4. pass the count to the script.

set collectedCounters's end to x

end if
end repeat
set text item delimiters to oldDelim

collectedCounters --> { 4, 2, 7, etc... }


{ Arthur J. Knapp, of <http://www.STELLARViSIONs.com>
a r t h u r @ s t e l l a r v i s i o n s . c o m
}
_______________________________________________
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.

  • Prev by Date: Re: Shell Script on a string
  • Next by Date: Re: What is ASLG?
  • Previous by thread: Re: search and count
  • Next by thread: Re: search and count
  • Index(es):
    • Date
    • Thread