Re: Checking for return at start of string (OS 10.1)
Re: Checking for return at start of string (OS 10.1)
- Subject: Re: Checking for return at start of string (OS 10.1)
- From: Nigel Garvey <email@hidden>
- Date: Sat, 6 Oct 2001 02:03:30 +0100
Simon Forster wrote on Fri, 5 Oct 2001 10:40:00 +0100:
>
This one is starting to do my head in...
>
>
I've parsed out a file to a list using return as the text item
>
delimiter. Gives me something like:
>
>
{"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", "
>
"}
>
>
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.
It works for me, using your list and code. But if you've used return as
the text item delimiter, there should be no returns in the list at all.
They should all have been stripped out, leaving the bits in between as
separate text items. However, given that there *are* returns here: if you
used AppleScript's text item delimiters to break up the file text and
they're still set to return, you won't be able to find any 'text items'
that are returns. (But of course this won't apply if you used the 'read'
command's 'using delimiter' parameter.) 1) Make sure the text item
delimiters are reset to {""}. 2) Don't use 'text item' unless you
specifically mean the text delimited by the text item delimiters. Use
'item' or 'character' when checking a single character in a string.
>
Tried begins with, coercing to string,
>
specifying the return as return, ascii characters (both Mac and Unix)
>
etc.
>
>
Returning text item 1 of this_item gives me the expected result of:
>
>
"
>
"
>
>
but I cannot get the conditional to work with a return, however I
>
specify that return.
I can't understand that. :-\ If getting the item gives a return, the
condition based on it should work too. Perhaps there's a line feed
character (ASCII 10) there (too).
NG