• 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: (resend)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (resend)


  • Subject: Re: (resend)
  • From: Alex Zavatone <email@hidden>
  • Date: Mon, 29 Mar 2010 23:57:06 -0500

The behaviour is worse with replacing word with text item


set myShellString to "ls -tl " & (quoted form of POSIX path of myFolder) & " | grep '^d'"
set myShellResults to do shell script myShellString as string
log myShellResults
set AppleScript's text item delimiters to " "
set myWords to number of text items in paragraph 1 of myShellResults
log myWords


repeat with myWordIndex from 1 to myWords
log text item myWordIndex of paragraph 1 of myShellResults
end repeat


display dialog "yo"


drwxr-xr-x  12 zav  admin     408 Jul  3  2009 c_prompt_zip_code*)
(*17*)
(*drwxr-xr-x*)
(**)
(*12*)
(*zav*)
(**)
(*admin*)
(**)
(**)
(**)
(**)
(*408*)
(*Jan*)
(**)
(*2*)
(*17:40*)
(*sd*)
(*caller_id_alert_icon*)
end tell
tell application "AppleScript Editor"
display dialog "yo"
--> error number -128

Result:

error "User canceled." number -128

On Mar 29, 2010, at 11:42 PM, Mark J. Reed wrote:

It doesn't suck; you are simply not understanding the explanations.

In AppleScript, "text items" are not "words".  Two different things.
In particular, words are delimited by what AppleScript says they're
delimited by.  Always.  You have no control over how a string breaks
into words.

However, you do have control over how it breaks into text items, by
dint of setting text item delimiters.

If you want to split a string into words based on standard conventions
(space and punctuation), use words.  If you want control over exactly
how it's split, use text items.  Which means you ask for "text items
of (stringHere)", not "words of (stringHere)".

--
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

  • Follow-Ups:
    • Re: (resend)
      • From: "email@hidden" <email@hidden>
References: 
 >Re: (resend) (From: Shane Stanley <email@hidden>)
 >Re: (resend) (From: Alex Zavatone <email@hidden>)
 >Re: (resend) (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: (resend)
  • Next by Date: Re: (resend)
  • Previous by thread: Re: (resend)
  • Next by thread: Re: (resend)
  • Index(es):
    • Date
    • Thread