Re: Texand Lists Continued
Re: Texand Lists Continued
- Subject: Re: Texand Lists Continued
- From: Christopher Nebel <email@hidden>
- Date: Wed, 2 Sep 2009 14:41:15 -0700
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