Re: What happened to delimiters?
Re: What happened to delimiters?
- Subject: Re: What happened to delimiters?
- From: Kai <email@hidden>
- Date: Fri, 13 Jun 2003 20:41:45 +0100
on Fri, 13 Jun 2003 11:23:06 -0400, Deivy Petrescu wrote:
>
On Friday, Jun 13, 2003, at 00:21 US/Eastern, Kai wrote:
>
> In spite of the vanishing 's', it still seems to work here. In fact,
>
> although the stated limit is 2 delimiters, I get these results:
>
>
>
> ---------------------------
>
>
>
> read file f
>
>
>
> --> "abcdefghijklmnopqrstuvwxyz"
>
>
>
> ---------------------------
>
>
>
> read file f using delimiter {"e", "n", "w"}
>
>
>
> --> {"abcd", "fghijklm", "opqrstuv", "xyz"}
>
>
>
> ---------------------------
>
>
>
> read file f using delimiter {"a", "b", "c", [...etc...] "x", "y", "z"}
>
>
>
> --> {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
>
> "", "",
>
> "", "", "", "", "", "", "", ""}
>
Thanks Kai, your experience is definitely different than mine.
>
I tried using a negative number as a delimiter (dd is the text
>
returned from a display dialog) and it does not work.
>
It takes the "-" to be the delimiter skipping the number altogether.
>
However, setting astid to a negative number works.
>
>
So if your file is
>
1 1 2 3 4 -200
>
3 3 5
>
>
using delimiter(s) {"-200" , return} yields:
>
{1 1 2 3 4, 200 , 3 3 5}
>
>
it does not change if you modify delimiter to {-200, return}
I must admit that, by trying to use more than 2 delimiters, I was expecting
to be hit by a -50 parameter error. (Are _you_ rewarded with an error if you
engage in this sort of irresponsible, anti-social behaviour?)
As far as your own tests are concerned, I actually get similar results:
---------------------------
read file f using delimiter {"-200", return} -- or {-200, return}
--> {"1 1 2 3 4 ", "200", "3 3 5"}
---------------------------
You may have noticed that, in my original tests, I used only single
character delimiters - mainly because 'Read' seems to ignore anything beyond
the first character. For example, if I write "this is a test" to a file, I
get this:
---------------------------
read file f using delimiter "is"
--> {"th", "s ", "s a test"}
---------------------------
(This would also explain why only the "-" of "-200" is acting as a
delimiter.)
So, unless anyone else can chip in with more information, I'm tempted to
assume that Read's delimiters are restricted to single characters. For
anything more ambitious, AppleScript's text item delimiters would seem to be
more appropriate.
--
Kai
_______________________________________________
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.