• 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
Adding items to a record in a list.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Adding items to a record in a list.


  • Subject: Adding items to a record in a list.
  • From: Robert Smith <email@hidden>
  • Date: Fri, 1 Apr 2005 15:29:51 -0500

I have a list of records, say:

set r1 to {name:"B", junk:"ab "}
set r2 to {name:"A"}
set lr to {r1, r2}

I want to add a "c" to the end of every 'junk:' item in the list. But those records with no junk: need to get one with just a "c" in it. I do not want to copy the list, only modify it in place. Here is one try:

on addc(j)
	try
		set junk of j to junk of j & "c"
	on error number errnum
		set j to j & {junk:"c"}  -- < -- What to put here??
	end try
end addc

repeat with i in lr
	addc(i)
end repeat
 get lr
--> {{name:"B", junk:"ab c"}, {name:"A"}}

The first one gets modified, but the second one doesn't. Any ideas?

--
Robert G. Smith
National Center for Biotechnology Information
Bethesda, MD [Contractor]

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Adding items to a record in a list.
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Re: asx file creation
  • Next by Date: Re: Adding items to a record in a list.
  • Previous by thread: Re: asx file creation
  • Next by thread: Re: Adding items to a record in a list.
  • Index(es):
    • Date
    • Thread