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: Tue, 15 Apr 2003 00:41:28 +0100
- Mac-eudora-version: 6.0a15
At 11:51 pm +0100 14/4/03, John Delacour wrote:
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.
Here it is elaborated to deal with strings embedded in lists.
You can still fool it, but it's not working badly for 40 minutes' work.
set reco to {_KEY_1_:{"a", 3.87, name, ""}, _KEY_2_:2,
_KEY_3_:"hello", _KEY_4_:{current date, 3 / 77}, _KEY_5_:{"oooo",
string}}
--
getkeys(reco)
-- => {"_key_1_", "_key_2_", "_key_3_", "_key_4_", "_key_5_"}
--
on getkeys(r)
set {fU, values_, listitems_, values_2} to {"/tmp/r", r as list, {}, {}}
repeat with v in values_
if class of v is list then
repeat with i in v
set i to contents of i
if class of i is string and i is not "" then
set end of listitems_ to i
end if
end repeat
end if
end repeat
repeat with i in values_ & listitems_
if class of i is string then
set end of values_2 to (contents of i)
end if
set end of values_2 to "t"
end repeat
set values_ to values_2 & "t"
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
try
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 try
end repeat
set my text item delimiters to ""
_keys_
end getkeys
_______________________________________________
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.