1

I am trying to work out how I am able to split the query entered on run in applescript into two separate variables able to be operated on.

Example:

{query} = bob jane

variable1 = bob

variable2 = jane

I was looking into doing this as a wordlist but have been unsuccessful as it separates the query by other symbols apart from " " [space].

I am sorry, I am not very good with applescript and am very confused as to how to go about doing this. Thankyou for any help.

1 Answers1

1
set input to "bob jane"
set the text item delimiters to space
set {var1, var2} to {text item 1, text item 2} of the input

var1 will now be set to "bob", and var2 will be set to "jane".


Added 2020-10-26:

Alternatively:

set input to "bob jane"
set {var1, var2} to the input's words
CJK
  • 5,732
  • 1
  • 8
  • 26
  • it says: [error "The variable Applescripts is not defined." number -2753 from "Applescripts"] EDIT: think it was just a grammatical error, think it should be *Applescript's* instead of *Applescripts's* – Ryannnnnmmm Jul 18 '18 at 21:25
  • All good xD Im very bad at applescript but that didnt really make sense to me. Thankyou for your help! – Ryannnnnmmm Jul 18 '18 at 21:28