• 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: Detect if third word in string contains a number
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detect if third word in string contains a number


  • Subject: Re: Detect if third word in string contains a number
  • From: theDaniel <email@hidden>
  • Date: Fri, 11 May 2012 19:23:17 -0400

I don't quite understand everything, but there seems to be a bug somewhere.
If I put one non-number word on the clipboard (ex. "he", "winds"), then condition 2 is called (?)

I modified your code slightly to give me some feedback:
get the clipboard as text    -- 
set _selection to result
-- Identify which word's the number.
set numberWordNumber to 1
repeat with thisWord in _selection's words
if (thisWord is in "363534332313029282726252422120191817161514110") then exit repeat
set numberWordNumber to numberWordNumber + 1
end repeat
-- Act accordingly.
if (numberWordNumber is 1) then
-- The first word's the number.
say "word one is the number" using "Bruce"
else if (numberWordNumber is 2) then
-- The second word's the number.
say "word two is the number" using "Victoria"
else if (numberWordNumber is 3) then
-- The third word's the number.
say "word three is the number" using "Alex"
set word1 to word 1 of _selection
if (word1 is in "I II III") then set the clipboard to ((count word1) as text) & space & text from word 2 to -1 of _selection
else -- (numberWordNumber > 3).
error say "None of the first three words of the selection is a number."
end if 

-Daniel

On May 10, 2012, at 10:20AM, Nigel Garvey wrote:

-- Identify which word's the number.
 set numberWordNumber to 1
 repeat with thisWord in _selection's words
   if (thisWord is in "363534332313029282726252422120191817161514110") then exit repeat
   set numberWordNumber to numberWordNumber + 1
 end repeat
 -- Act accordingly.
 if (numberWordNumber is 1) then
   -- The first word's the number.
 else if (numberWordNumber is 2) then
   -- The second word's the number.
 else if (numberWordNumber is 3) then
   -- The third word's the number.
   set word1 to word 1 of _selection
   if (word1 is in "I II III") then set the clipboard to ((count word1) as text) & space & text from word 2 to -1 of _selection
 else -- (numberWordNumber > 3).
   error "None of the first three words of the selection is a number."
 end if

 _______________________________________________
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: Detect if third word in string contains a number
      • From: Thomas Fischer <email@hidden>
References: 
 >Re: Detect if third word in string contains a number (From: Nigel Garvey <email@hidden>)
 >Re: Detect if third word in string contains a number (From: Nigel Garvey <email@hidden>)

  • Prev by Date: Re: List of aliases contains alias
  • Next by Date: hide file
  • Previous by thread: Re: Detect if third word in string contains a number
  • Next by thread: Re: Detect if third word in string contains a number
  • Index(es):
    • Date
    • Thread