Re: Getting the labels of a record
Re: Getting the labels of a record
- Subject: Re: Getting the labels of a record
- From: John Delacour <email@hidden>
- Date: Mon, 14 Apr 2003 23:51:15 +0100
- Mac-eudora-version: 6.0a15
At 5:52 pm +0000 8/3/03, has wrote:
Emmanuel wrote:
At 2:09 PM +0100 08/03/03, LE STANG Jean-Baptiste wrote:
>I'm looking for a way to read the names of labels in a record. Does
>anyone know how to do it?
I don't think there is any. If there were one, that would simplify
much some of my scripts.
Yup, the only "clean" way is through an app and osax that know how
to manipulate a record's internal structures; e.g. the RecordAccess
osax (OS9-only).
I've not tested this with all sorts of things, but it ought to work
pretty well in most cases and could be elaborated to work in all
cases.
set reco to {_KEY_1_:1, _KEY_2_:2, _KEY_3_:"hello", _KEY_4_:current date}
--
getkeys(reco)
-- => {"_key_1_", "_key_2_", "_key_3_", "_key_4_"}
--
on getkeys(r)
set {fU, values_} to {"/tmp/r", r as list}
set f to POSIX file fU
try
close access f
end try
open for access f with write permission
set eof f to 0
write r to f
close access f
set s to read f
set my text item delimiters to "TEXT"
set ls to text items 2 through -1 of s
set _keys_ to {}
repeat with i in ls
set s to "" & i
set c to ASCII number character 4 of s
set |key?| to text 5 through (4 + c) of s
if |key?| is not in values_ then set end of _keys_ to |key?|
end repeat
set my text item delimiters to ""
_keys_
end getkeys
--JD
_______________________________________________
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.