Re: Getting label from a record
Re: Getting label from a record
- Subject: Re: Getting label from a record
- From: EBI Aktivitet <email@hidden>
- Date: Thu, 20 Nov 2003 08:54:50 +0100
Den 03-11-19 23.07, skrev "Emmanuel" <email@hidden>:
>
I've seen you got several replies, however you may want to consider using
>
Smile since it does include specific tools for that kind of thing - more
>
generally, for manipulating scripts by script.
>
>
The script belows finds all labels that do not include a colon (a rather rare
>
case, you would admit). To find also those that include a colon you need a few
>
additional lines, that would not help understanding how the script works.
>
>
The strategy here is 1. making the record into text (Smile's 'display'
>
command) - 2. finding the first label (here I just locate the first occurrence
>
of ":") (Satimage osax' 'find text' command) - 3. suppressing the said label
>
out of the record (Satimage osax' 'suppress item' command) - then iterate
>
until record is empty.
>
>
---------------------------------------
>
on GetLabels(r)
>
set labs to {}
>
repeat
>
set n to count r
>
if n = 0 then return labs
>
set lab to find text "\\{(\\|?)([^:|]+)\\|?:" in (display r) using "\\2" with
>
regexp and string result
>
set end of labs to lab
>
set r to suppress item lab from r
>
try
>
if n is (count r) then set r to do script "suppress item " & lab & " from " &
>
(display r)
>
end try
>
end repeat
>
end GetLabels
>
---------------------------------------
>
Thanks Emmanuel, that9s really cool! I actually downloaded Smile yesterday,
to have a look at what it could do for me. Problem is, I'm stubbornly trying
to do it all in vanilla, but after seeing your solution I might have to
rethink... :-)
Regards, Adim
_______________________________________________
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.