Re: Standard Additions 'read' command - basic questions
Re: Standard Additions 'read' command - basic questions
- Subject: Re: Standard Additions 'read' command - basic questions
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 18 Jan 2004 21:54:11 -0800
Nothing is a valid delimiter if your writing dates, lists or records, since
the binary data in which they're encoded can, and does, contain any and all
ASCII characters whatsoever. That always screws up using the delimiter,'
However, lists and records are self-defining - you can always 'read as list'
or 'read as record' and you will get the whole of next segment of the file
if you know that it's a list or record. an the list or record can contain
string, Unicode text, integer, real, date, or data elements (I've probably
forgotten a few) : basically all the native AppleScript (not application)
types. And dates are always 8 characters, so you can just 'read for 8' if
you know its a date. I have shareware scripts which write all sorts of data
- string, Unicode, dates, lists and records - to a file and read it back the
next time. I could actually done the entire thing as a mega-list, as you
suggest. Chris Nebel (AppleScript engineer) confirmed to me that that would
work.
--
Paul Berkowitz
>
From: Chap Harrison <email@hidden>
>
Date: Sun, 18 Jan 2004 23:35:24 -0600
>
To: <email@hidden>
>
Subject: Standard Additions 'read' command - basic questions
>
>
Hi all,
>
>
First post to the list, first-time user of Applescript, but not a
>
novice programmer.
>
>
I used a Unix script to create a text file that I need to read from an
>
Applescript in order to add records to a Filemaker DB.
>
>
The text file consists of records, each of which contains a variable
>
number of fields. So far so good, with one caveat: the "fields" are
>
ASCII text which may contain Mac new-line characters (in fact, any
>
ASCII character). Therefore, I chose to delimit these fields with the
>
non-ASCII character 0xfe. Furthermore, since each record contains an
>
unknown number of fields, I must also delimit each record -- I use
>
0xff.
>
>
The first thing I noticed was that a single invocation of 'read'
>
appears to return the entire *file* as a list!! Is this how 'read' is
>
supposed to work?
>
>
If so, are there any limits as to the length of a list?
>
>
The second problem was that 'read' doesn't care for my high-end
>
delimiters:
>
>
set foo to (read fid using delimiter (ASCII character 254)) -- also
>
tried 255
>
>
foo is a list containing one string, which is the contents of the
>
entire file, with my oddball delimiters intact.
>
>
Are 0xfe or 0xff not valid delimiters as far as AS is concerned?
>
>
Suggestions for a better approach?
>
>
Thanks,
>
Chap
>
_______________________________________________
>
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.
_______________________________________________
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.