Re: Getting label from a record (part 2)
Re: Getting label from a record (part 2)
- Subject: Re: Getting label from a record (part 2)
- From: kai <email@hidden>
- Date: Tue, 18 Nov 2003 00:10:42 +0000
on 18/11/03 12:02 am, I wrote:
>
Possibly a more robust method (if somewhat longer and slower) would be the
>
alternative that I also posted around the same time...
>
>
[Please see part 2 of this message]
...which follows...
(Due to the way in which the raw data of records is structured, the
resulting label strings are not necessarily returned in the order entered):
--============================
to getKeys from r with dupes
tell r's class to if it is not record then error "Can't get keys from "
& it & "."
local dupes
set r to {r} as string
script s
property a : (ASCII character 199) & "class "
property z : ASCII character 200
property o : ASCII character 0
property d : r
property k : {}
property m : 0 - 8
on val(x)
set {t, v} to {d's text (x - 3) thru x, 0}
repeat with n from 1 to 4
set c to t's item n
if c is not o then set v to v + (ASCII number c) * (256 ^ (4 - n))
end repeat
v
end val
on nxt(n)
set m to m + n
if d's text (m + 1) thru (m + 4) is "reco" then return rec()
set m to m + 8
tell val(m) to set m to m + it + it mod 2
end nxt
on usr()
set m to m + 20
repeat val(m - 4) div 2 times
set m to m + 8
tell val(m) to set {q, m} to {d's text (m + 1) thru (m + it), m + it +
it mod 2}
if dupes or q is not in k then set k's end to q
if d's text (m + 1) thru (m + 4) is "list" then
lst()
else
nxt(0)
end if
end repeat
end usr
on lst()
set m to m + 16
repeat val(m - 4) times
nxt(0)
end repeat
end lst
on rec()
set m to m + 16
repeat val(m - 4) times
set n to d's text (m + 1) thru (m + 4)
if n is "usrf" then
usr()
else
tell (run script a & n & z) as string to if dupes or it is not in k then
set k's end to it
nxt(4)
end if
end repeat
end rec
if d starts with "d" then set m to 8
tell rec() to k
end script
run s
end getKeys
--============================
..which should handle something as perverse as this:
set r to {subject:"Re: Getting label from a record", date:date "1/1", |time
sent|:"14:36:25 pm", list:{list:{number:1576, string:string}},
alias:{path:{name:{disk:{folder:{file:{item:false}}}}}}, file:"Macintosh
HD:Desktop Folder:test", |initial values|:{list:{1, 2, 3, 4},
|final\raverage|:10 / 4}}
----------------------------
getKeys from r with dupes
--> {"date", "list", "list", "number", "string", "alias", "path", "name",
"disk", "folder", "file", "item", "file", "subject", "time sent", "initial
values", "list", "final
average"}
----------------------------
getKeys from r without dupes
--> {"date", "list", "number", "string", "alias", "path", "name", "disk",
"folder", "file", "item", "subject", "time sent", "initial values", "final
average"}
----------------------------
(Note that the final label contained an escaped return character.)
The above scripts should work in both OS 9 and OS X.
---
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.