A difficult one with edit text and fill forms…

Hi !

I am really new at this so bear with me please :rolleyes: !

I want to do something tough with automator : I would like to search 3 variables in my opened textedit document and extract them.
Let’s say my document contains “I love you guys and I hope you can help me!”. Only “guys”, “hope” and “help” will change from one document to the other, the rest is constant. Therefore, I figure I could search for the surronding words, e.g. “you” and “and” to find “guys”.
Then I would need to past these values in my web page containing theree field called “vector”, “norm” and “size”.

I just do not know how to do it in applescript… could anyone help me a bit ???

I thank you so much for any help !

Hi,

to extract the words use AppleScript’s text item delimiters,
here with your example

set a to "I love you guys and I hope you can help me!"
set delim to {"I love you ", "and I ", "you can "}
set TID to text item delimiters
set valueList to {}
repeat with i in delim
	set text item delimiters to i
	set end of valueList to word 1 of text item 2 of a
end repeat
set text item delimiters to TID
valueList
--> {"guys", "hope", "help"}

To pass the data to your website you can probably use UI scripting

thanks a lot Stefan!

However, the boring begginner that I am still has questions :smiley: !
The first is : How can I get the sentence from textedit ? In your exemple, you set already the sentence to “I love you guys and I hope you can help me!”, but how can I just get it from textedit?
Second, I want to run this in an automated fashion so I went to automator, open a “run script” action, copied yours and place a “copy to clipboard” action afterwards to see the output of the script. It did not work… What am I not getting here ??

thank in any case for such a fast answer !

Hi,

instead of the first line use this and change the path (colon separated) to the path to your document

tell application "TextEdit"
	open "path:to:my:document.rtf"
	set a to text of document 1
end tell