• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Labels of a Record
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Labels of a Record


  • Subject: Re: Labels of a Record
  • From: email@hidden
  • Date: Tue, 6 Aug 2002 13:24:18 -0700

I took this basic idea and made it a little more explicit. It's great for
what I'm doing, and it's a wonderful haque (ie using one thing to do
something completely different):

set a to {abjkbk:"b", cdvdv:"vdffdvdd", vdfsdfve:334433}
try
a as string
on error errMsg
set AppleScript's text item delimiters to "{"
set theChunks to text items 2 thru -1 of errMsg
logit(theChunks)
set theChunks to theChunks as string

set AppleScript's text item delimiters to "}"
set theChunks to text items 1 thru -2 of theChunks
logit(theChunks)
set theChunks to theChunks as string

set AppleScript's text item delimiters to ", "
set theChunks to text items of theChunks
logit(theChunks)

set AppleScript's text item delimiters to ":"
set theLabelList to {}
repeat with chunk in theChunks
set label to first text item of chunk
set value to last text item of chunk
log "Label '" & label & "' is '" & value & "'"
end repeat

set AppleScript's text item delimiters to ""
end try

to logit(theChunks)
repeat with chunk in theChunks
log chunk
end repeatend logit

-->
(*abjkbk:"b", cdvdv:"vdffdvdd", vdfsdfve:334433} into a string.*)
(*abjkbk:"b", cdvdv:"vdffdvdd", vdfsdfve:334433*)
(*abjkbk:"b"*)
(*cdvdv:"vdffdvdd"*)
(*vdfsdfve:334433*)
(*Label 'abjkbk' is '"b"'*)
(*Label 'cdvdv' is '"vdffdvdd"'*)
(*Label 'vdfsdfve' is '334433'*)

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Seth A. Roby
Scriptwriter Intern
"Life is like an exploded clown. It's really funny until you figure out
what just happened."



Mr Tea <email@hidden>
Sent by: To: AS List <email@hidden>
applescript-users-admin@list cc:
s.apple.com Subject: Re: Labels of a Record


08/05/2002 07:06 PM






This from email@hidden - dated 6-8-02 12.29 am:

> If you do:
> {a: "b", c:3, d:"Jojo Bozo"} as list
>
> you get:
> {"b", 3, "Jojo Bozo"}
>
> is there any way to get:
> {a, c, d}
> ?
>
> What I want, really, is a list of the labels,

Well, you could take a hammer to it...

set theTestList to {a:"b", c:3, d:"Jojo Bozo"}
try
theTestList as string
on error errmsg
set AppleScript's text item delimiters to ":"
set theChunks to every text item of errmsg
set AppleScript's text item delimiters to ""
set theLabelList to {}
repeat with theText in items 1 thru -2 of theChunks
set theLabelList to theLabelList & {character -1 of theText, ", "}
end repeat
end try
items 1 thru -2 of theLabelList as string

--> "a, c, d"

It's as rough as a bear's behind, but perhaps you can use it. ;-)


Nick
_______________________________________________
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.

  • Prev by Date: Re: Need XOR solution
  • Next by Date: Re: set parent
  • Previous by thread: Re: Labels of a Record
  • Next by thread: set parent
  • Index(es):
    • Date
    • Thread