Checking for return at start of string (OS 10.1)
Checking for return at start of string (OS 10.1)
- Subject: Checking for return at start of string (OS 10.1)
- From: George Mack <email@hidden>
- Date: Fri, 5 Oct 2001 11:00:05 -0400
Simon Forster <email@hidden> asked this morning
Doing some further processing, I want to check whether each item in the
list starts with a return. So:
repeat with this_item in dir_listing
if text item 1 of this_item is equal to "
" then
never evaluates to true. Tried begins with, coercing to string,
specifying the return as return, ascii characters (both Mac and Unix)
etc.
Have you tried the text constant variant "return" for "
"? I'm wondering if the literal use of the return is what's giving
you a problem.
This works on my machine (Allowing for rewraps in the List...):
set MyList to {"drwx------ folder 5 Sep 19 15:07
~nethues_rw", "
drwx------ folder 4 Oct 03 10:51 ~noblesvenues", "
drwx------ folder 28 Sep 20 16:53 ~Regus", "
drwx------ folder 13 Oct 01 17:25 ~rettie", "
drwx------ folder 33 Aug 30 10:41 ~riley", "
drwx------ folder 68 Jul 26 12:02 ~RileyNew 2001-07-26", "
drwx------ folder 14 Aug 13 14:39 ~RileyNew 2001-08-13", "
drwx------ folder 14 Aug 30 12:05 ~RileyNew 2001-10-12", "
drwx------ folder 15 Mar 28 2001 ~wiccaways", "
"}
set countEm to 0
repeat with this_item in MyList
if text item 1 of this_item is return then set countEm to countEm + 1
end repeat
display dialog countEm
--> display dialog 9
note that there's a "non item" at the end of the list (the single
trailing return) that you'll have to trap for...
Hope this helps
--
GEORGE MACK DESIGN - Scituate, MA 02066 - (781) 544-3880
Design - Illustration - Desktop Publishing - Miscellaneous Magic