Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8348565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:43:46+00:00 2026-06-09T07:43:46+00:00

I am storing text from TextEdit in an AppleScript variable, and I want to

  • 0

I am storing text from TextEdit in an AppleScript variable, and I want to pass it to JavaScript. I thought I was doing it right, but I still can’t get the value to be stored. The code is as follows:

tell application "TextEdit"
    activate
    set docText to the text of the front document --This works. I've checked.
end tell

tell application "Google Chrome"
    tell window 1
        tell active tab
            execute javascript "function encryptDocument() {
                plainText = '" & docText & "';
                return plainText;
                } encryptDocument();"
                set skurp to the result
                display dialog skurp
            end tell
    end tell
end tell

The reason I house the JavaScript code within a tell application "Google Chrome" command is because I get an error every time I try to call it in the previous tell application "TextEdit" command. The error always says that it expects an end of line but found ". Not really sure why, but I can’t find a way around this problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:43:49+00:00Added an answer on June 9, 2026 at 7:43 am

    Is it possible that the value you want to give to the variable (I mean the text in Text Editor) contains a single quote (‘)?
    Without ‘ in Text Editor this seems to work for me.

    The following code snippet may be used to escape single quotes. (adapted from this code)

    on escape(this_text)
        set AppleScript's text item delimiters to the "'"
        set the item_list to every text item of this_text
        set AppleScript's text item delimiters to the "\\'"
        set this_text to the item_list as string
        set AppleScript's text item delimiters to ""
        return this_text
    end escape
    
    tell application "TextEdit"
        activate
        set docText to the text of the front document --This works. I've checked.
    end tell
    
    set docText to escape(docText)
    
    tell application "Google Chrome"
        tell window 1
            tell active tab
                execute javascript "function encryptDocument() {
                    plainText = '" & docText & "';
                    return plainText;
                    } encryptDocument();"
                set skurp to the result
                display dialog skurp
            end tell
        end tell
    end tell
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I read multiple lines from a text file (variable width) and store
How can I change the datatype of a column from text to timestamp. The
I'm parsing text from a file and storing it in a string. The problem
I am a windows batch dunce. I have a variable storing some text surrounded
I want to compress TEXT for storing in MySQL. So I would just do
I'm doing something that requires storing some text entered in a UITextView . It
I have a arbitrarily large string of text from the user that needs to
My method looks like: public string DoObjectProperties<T>(T obj, string text) { } Now from
I have a string in C# and would like to get text from specific
I'm trying to get all the text from a txt file into a string,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.