Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

thriftinkid

macrumors regular
Original poster
Mar 24, 2008
119
0
Below I have a partial script. The script creates an untitled document and adds some text to it. All I need it to do is save the document as the name "mydocument.txt" on the desktop, but the applescript dictionary seems to be leading me astray.....or maybe I just am an idot (probably true). Any help?

Code:
		make new document
		end if
		set the text of the front document to theText
		save as "mydocument.txt" in "Macintosh HD:Users:John:Desktop"
		quit application "TextEdit"
	end tell
 

lancestraz

macrumors 6502a
Nov 27, 2005
898
0
RI
Use this to save it.
Code:
save the front document in "Macintosh HD:Users:John:Desktop:myDocument.txt"
 

thriftinkid

macrumors regular
Original poster
Mar 24, 2008
119
0
because I don't know one way or the other, will the save action save in RTF or plain-text?

The adjusted script above worked to save a ".txt" file to the desktop but it still prompts me as the program quits to save or not save the untitled document that was created. I just want Text Edit to quit after is saves it under the file name I designate.
 

lancestraz

macrumors 6502a
Nov 27, 2005
898
0
RI
because I don't know one way or the other, will the save action save in RTF or plain-text?
Code:
save the front document in "Macintosh HD:Users:John:Desktop:myDocument.txt"
will save it as plain text.

Code:
save the front document in "Macintosh HD:Users:John:Desktop:myDocument.rtf"
Will save it as rich text.
 

CaptainZap

macrumors regular
Jan 17, 2007
170
0
You should pick up a book on Applescript if you don't have one already. You've made like 15 threads on Applescript and I bet a book could help you out with lots of the problems you have.
 

lancestraz

macrumors 6502a
Nov 27, 2005
898
0
RI
Ah. So Applescript uses the old Mac OS 9 and previous form for file paths then?
You can use both. By default Applescript returns values using ":" as a separator.
Code:
set theFile to (path to temporary items folder)

But you can still work with POSIX paths.
Code:
set theFile to (POSIX path of (path to temporary items folder))
 

thriftinkid

macrumors regular
Original poster
Mar 24, 2008
119
0
You should pick up a book on Applescript if you don't have one already. You've made like 15 threads on Applescript and I bet a book could help you out with lots of the problems you have.

Yeah, I'm going to do that. I was looking around and I saw that O'reily book. Is it any good?
 

thriftinkid

macrumors regular
Original poster
Mar 24, 2008
119
0
You can use both. By default Applescript returns values using ":" as a separator.
Code:
set theFile to (path to temporary items folder)

But you can still work with POSIX paths.
Code:
set theFile to (POSIX path of (path to temporary items folder))

It's not an issues of saving to RTF or TXT. Text Edit will the the document properly, bt it prompts me to save the untitled document as well when it oes to quit. I just want it to ignore or say no to saving that document.
 

lancestraz

macrumors 6502a
Nov 27, 2005
898
0
RI
It's not an issues of saving to RTF or TXT. Text Edit will the the document properly, bt it prompts me to save the untitled document as well when it oes to quit. I just want it to ignore or say no to saving that document.
Use this to quit TextEdit without being prompted to save anything.
Code:
quit without saving
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.