• 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: Barry Wainwright <email@hidden>
  • Date: Tue, 05 Jan 2010 17:15:07 +0000

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

IIRC, Apple's recommendation is to NOT assume any particular value to TIDs when using them and ALWAYS set them before use.

Common practice is to reset them to their initial state after you have finished with them, but is everyone follows the Apple advise, this would not be necessary!

In the end, it's up to you. In my own simple scripts I tend not to bother resetting TIDs, in scripts that I am planning to distribute, I always do.

--
Barry




On 5 Jan 2010, at 17:06, Tin Tin wrote:

> Should Josh first set a variable to the current test delimiters so
> that he might
> return it to that after his script is done with the text parsing?
>
> Something like:
>
> set originalDel to current text item delimiter
> --rest of script
> 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)
> --finished
> set AppleScript's text item delimiters to originalDel
>
> The above is neither tested nor known to work, probably doesn't.  I am actually
> asking because I don't know it this precaution is relevant.
>
> kyle
>
>>
>> On Tue, Jan 5, 2010 at 9:54 AM, Mark J. Reed <email@hidden> wrote:
>>> On Tue, Jan 5, 2010 at 10:25 AM, Luther Fuller <email@hidden> wrote:
>>>> On Jan 5, 2010, at 9:04 AM, Josh Tishhouse wrote:
>>>> What's the best way to convert that, and set it as a new variable?
>>>>
>>>> Here's how ...
>>>> 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)
>>>
>>> Except Josh wanted to create a new variable with the underscore
>>> version, not replace the original text.
>>>
>>> To do that, just use a different name than "textVar" in the last "set"
>>> statement.  You can pick any variable name; the "set" statement will
>>> create it.
>>>
>>> --
>>> Mark J. Reed <email@hidden>
>>>  _______________________________________________
>>> 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
>>>
>>
>>
>>
>> --
>> Kyle Olson
>>
>
>
>
> --
> Kyle Olson
> _______________________________________________
> 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

 _______________________________________________
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

  • Follow-Ups:
    • Re: Newbie Question - Replacing spaces with underscores
      • From: Wayne Melrose <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>)

  • Prev by Date: Re: Newbie Question - Replacing spaces with underscores
  • Next by Date: Re: Newbie Question - Replacing spaces with underscores
  • Previous by thread: Re: Newbie Question - Replacing spaces with underscores
  • Next by thread: Re: Newbie Question - Replacing spaces with underscores
  • Index(es):
    • Date
    • Thread