Re: string count in log file
Re: string count in log file
- Subject: Re: string count in log file
- From: Nigel Garvey <email@hidden>
- Date: Fri, 21 Sep 2001 23:10:27 +0100
Greg Sutherland wrote on Fri, 21 Sep 2001 06:28:56 -0400 (EDT):
>
I thought I was beginning to understand. Wrong. I get a count of 0 every
>
time. Even when I use the same file which just has one line with one word
>
I still get a count of zero. :(
>
I've displayed the values of theText and srchStrng and they look correct.
>
What am I doing wrong??
[snip]
>
set od to AppleScript's text item delimiters
>
repeat with srchStrng in srchTbl
>
set AppleScript's text item delimiters to srchStrng
srchStrng is a reference in this kind of repeat, not a string, so you're
setting the delimiters to the reference rather than the string to which
it refers. The 'text items of theText' is therefore a list containing
just one item (the whole of 'theText'), so the count - 1 is 0. You need
either to get the 'contents' of the reference:
set AppleScript's text item delimiters to srchStrng's contents
... or to do a pretend coercion:
set AppleScript's text item delimiters to srchStrng as string
or:
set AppleScript's text item delimiters to srchStrng as item
>
set theCount to (count text items of theText) - 1
>
set rsltText to rsltText & srchStrng & tab & (theCount as text) & return
>
end repeat
>
>
display dialog rsltText
Don't forget to set the delimiters back to 'od' afterwards. :-)
NG