Saving Text Document to Desktop

Discussion in 'Mac Programming' started by thriftinkid, Apr 18, 2008.

  1. thriftinkid macrumors regular

    Joined:
    Mar 24, 2008
    #1
    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
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
  3. lancestraz macrumors 6502a

    lancestraz

    Joined:
    Nov 27, 2005
    Location:
    RI
    #3
    Use this to save it.
    Code:
    save the front document in "Macintosh HD:Users:John:Desktop:myDocument.txt"
     
  4. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #4
    because I don't know one way or the other, will the save action save in RTF or plain-text?
     
  5. thriftinkid thread starter macrumors regular

    Joined:
    Mar 24, 2008
    #5
    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.
     
  6. lancestraz macrumors 6502a

    lancestraz

    Joined:
    Nov 27, 2005
    Location:
    RI
    #6
    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.
     
  7. CaptainZap macrumors regular

    Joined:
    Jan 17, 2007
    #7
    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.
     
  8. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #8
    Ah. So Applescript uses the old Mac OS 9 and previous form for file paths then?
     
  9. lancestraz macrumors 6502a

    lancestraz

    Joined:
    Nov 27, 2005
    Location:
    RI
    #9
    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))
     
  10. thriftinkid thread starter macrumors regular

    Joined:
    Mar 24, 2008
    #10
    Yeah, I'm going to do that. I was looking around and I saw that O'reily book. Is it any good?
     
  11. thriftinkid thread starter macrumors regular

    Joined:
    Mar 24, 2008
    #11
    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.
     
  12. lancestraz macrumors 6502a

    lancestraz

    Joined:
    Nov 27, 2005
    Location:
    RI
    #12
    Use this to quit TextEdit without being prompted to save anything.
    Code:
    quit without saving
     

Share This Page