• 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: Newbie Question - Replacing spaces with underscores
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie Question - Replacing spaces with underscores


  • Subject: Re: Newbie Question - Replacing spaces with underscores
  • From: Wayne Melrose <email@hidden>
  • Date: Tue, 05 Jan 2010 18:40:55 +0100


On 5. jan. 2010, at 18.15, Barry Wainwright wrote:

This is one of those questions that divides opinion and shouldn't be discussed at 'polite' dinner tables ;-)


Yes... I was in fact half way through writing a response when I saw the initial reply from Luther. Personally I think it's ALWAYS a good idea to EITHER reset them to the state you found them in, or simply set them back to "" which is actually what suits me. 

The other thing that I like to do, no matter how simple your script seems, is to wrap an error handler around it, and reset them on error

something like 

set TIDs to AppleScript's text item delimiters
try
set textVar to "Text With Spaces"
set AppleScript's text item delimiters to space
set itemList to (text items of textVar) as list
set AppleScript's text item delimiters to "_"
set textVar to (itemList as text)
set AppleScript's text item delimiters to TIDs
on error
-- make sure you reset TID's
set AppleScript's text item delimiters to TIDs
end try
return textVar

That way you will always put them back the way you found them, and avoid alot of headache. 


 _______________________________________________
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: 
 >Newbie Question - Replacing spaces with underscores (From: Josh Tishhouse <email@hidden>)
 >Re: Newbie Question - Replacing spaces with underscores (From: Luther Fuller <email@hidden>)
 >Re: Newbie Question - Replacing spaces with underscores (From: "Mark J. Reed" <email@hidden>)
 >Re: Newbie Question - Replacing spaces with underscores (From: Tin Tin <email@hidden>)
 >Re: Newbie Question - Replacing spaces with underscores (From: Barry Wainwright <email@hidden>)

  • Prev by Date: Re: Newbie Question - Replacing spaces with underscores
  • Next by Date: Just say no ?
  • Previous by thread: Re: Newbie Question - Replacing spaces with underscores
  • Next by thread: List content of a folder, output to document
  • Index(es):
    • Date
    • Thread