• 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: Texand Lists Continued
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Texand Lists Continued


  • Subject: Re: Texand Lists Continued
  • From: Peter Baxter <email@hidden>
  • Date: Thu, 03 Sep 2009 08:49:35 +1000

Thanks Christopher,

It was that easy. I tried something similar earlier, but had the syntax wrong.


On 03/09/2009, at 7:41 AM, Christopher Nebel wrote:

On Sep 2, 2009, at 3:11 AM, Peter Baxter wrote:

I have been using this script to create a comma delimited list that allocates teachers to their classes for import into a database. I am nearly there, however the resulting list has lots of quotation marks in it. Can someone please help me clean this up?

The result:
{"
", "ADA", "SCI7B", "SCI7G", "SCF10B", "
", "AND", "IP7B", "DRA7G", "DRA7O", "IP8B", "ART8O", "ART8R", "ART9B", "COMP", "
", "BAP", "MUS7B", "MUS8B", "MUS8G", "MUS9A", "2ND", "
", "
", "BAS", "FRE7B", "FRE7G", "FRE7O", "FORM8B", "FRE8B", "HUM8G", "FRE8R", "2ND", "
", "BRE", "CAR10A", "CAR10B", "CAR10C", "
", "BRP", "MAT9G", "NUM9A", "2ND", "


What I would like:

{ADA, SCI7B, SCI7G, SCF10B,
AND, IP7B, DRA7G, DRA7O, IP8B, ART8O, ART8R, ART9B, COMP,
BAP, MUS7B, MUS8B, MUS8G, MUS9A, 2ND,
BAS, FRE7B, FRE7G, FRE7O, FORM8B, FRE8B, HUM8G, FRE8R, 2ND,
BRE, CAR10A, CAR10B, CAR10C,
BRP, MAT9G, NUM9A, 2ND, …...

I don't think there's actually anything to clean up. AppleScript Editor's result pane shows you the result in "source" form, such that you could paste it back into a script and compile it. You've got a list of strings, hence each string has quotation marks around it because that's the syntax for a string literal in AppleScript. The quotes aren't actually part of the strings, that's just how they're displayed.


If you want to turn the list of strings into one big string with commas separating the items, then you can do this:

	set AppleScript's text item delimiters to ", "
	set myBigString to myWords as text

Exactly what you do depends on how you plan to use "myWords" -- put it in the clipboard, write it to a file, etc.


--Chris Nebel AppleScript Engineering

PS: If you're using "read" to simply read the entire file, you don't need to open and close it; just a plain "read" command will do:

	set fileRef to open for access includedFile
	set includedlist to read fileRef
	close includedFile

is equivalent to...

	set includedlist to read includedFile


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >Texand Lists Continued (From: Peter Baxter <email@hidden>)
 >Re: Texand Lists Continued (From: Christopher Nebel <email@hidden>)

  • Prev by Date: Re: Texand Lists Continued
  • Next by Date: Re: Script to mail contents of safari web page.
  • Previous by thread: Re: Texand Lists Continued
  • Next by thread: toolbar-sidebar
  • Index(es):
    • Date
    • Thread