How do I use an Applescript string in Javascript?

I'm trying to get the contents of a BBEdit window, push them to a textarea on a web page, then click a button.
Here's the applescript that does it:
set scrpt to "Testing"
(* tell application "BBEdit"
set scrpt to contents of text window 1
end tell*)
if scrpt is not "" then
tell application "Safari"
set index of window "Question Editor" to 1
tell document "Question Editor"
do JavaScript "document.getElementsByName('question')[0].value =scrpt"
end tell
tell document 1
do JavaScript "<clicks the button>"
end tell
end tell
end if
You'll see some of my elementary debugging at the top. scrpt is a variable that contains the text from BBEdit. You'll see scrpt at the end of the first do javascript() call. If I literally put a string inside the do javascript() call -- removing scrpt altogether -- all is well.
But no mater how I assign a value to scrpt, either directly or via bbedit, the javascript fails. Any ideas? I wonder if scrpt has something extra around it, like quotes, or if somehow it's not passed as a string.

Well, the obvious problem is:
do JavaScript "document.getElementsByName('question')[0].value =scrpt"
You're including the literal string 'scrpt' in your JavaScript command, so those 5 characters are exactly what's sent to JavaScript to execute.
A better aproach would be:
do JavaScript "document.getElementsByName('question')[0].value='" & scrpt & "'"
note that your scrpt variable is no longer quoted, so AppleScript will embed the variable's value into the command. I've also wrapped scrpt with single quotes to protect the value, in case it has spaces or some such.

Similar Messages

  • How can you use a format string to make all information in a string line up and stack up?

    I am trying to post data on screen using "format into string" and make all data line up into one indicator string

    Not exactly sure what you are looking for. Could you elaborate, or post a screen shot of what you are trying to accomplish. I would hate to give you an answer based on my interpretation of your problem.

  • How to use Native SQL String

    Hi all,
    How do i use Native SQL String in the Reciver JDBC Adapter.
    Do i need to change the message format could u suggest me some blogs on the same.
    Also please can anyone let me knw if i can use this for stored procedure.

    hi aditya,
    there shud be no format as such. for sql xml format there are specific structure. but for native sql there shudnt be any specific structure.
    as pointed in sap documentaion:
    Instead of an XML document format, a text is expected that represents any valid SQL statement.
    When inserting a line into a table the corresponding document looks as follows:
    INSERT INTO tableName  (column-name1, column-name2, column-name3) VALUES(‘column-value1’, ‘column-value2’, ‘column-value3’)
    so jus make sure that u give a valid sql statement becoz if will be passed as it is to the database and try ur scenario.
    regards,
    latika.

  • How do I use AppleScript to Change the Creation Date to the Current Date?

    I sorted my downloads folder by creation date and found that the items were sorted seemingly randomly. On closer inspection, I saw that the creation dates were not the same as the dates that I downloaded the items, so I figures that Snow Leopard was using the date given to it by the server.
    In order to get the items sorted by download date, I figured I'd use Hazel, but it doesn't have a “change creation date” item. It does, however, have an “run AppleScript” item.
    So my question is this: how do I use AppleScript to change the creation date of an item to the current date?

    TC (Techno Cat) wrote:
    Okay, I tried changing the creation date with SetFile, but it kept giving me an error:
    What am I doing wrong?
    Looks like the date and time was not quoted
    Try this Applescript. It will change the creation date of every file in the Downloads folder to the current date and time:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #E6E6EE;
    overflow: auto;"
    title="this text can be pasted into the AppleScript Editor">
    set current_date_and_time to do shell script "date \"+%m/%d/%Y %H:%M\""
    tell application "Finder"
    set filelist to every file of the alias (the path to downloads folder as text)
    repeat with currentFile in filelist
    do shell script "/usr/bin/SetFile -d " & quoted form of current_date_and_time & space & quoted form of POSIX path of (currentFile as string)
    end repeat
    end tell</pre>

  • How to use multiple VCI strings for lap 1300 and 1200 (option 60) in one pool?

    Hi All,
    Hope to you a very happy new year,
    I have two differnt LAP 1300 and 1200 in my network and I need to add theme to the WLC,
    I successed to add one of theme by the option 60 in the DHCP pool at the Core SW,
    So my quetion is below:
    How to use multiple VCI strings for lap 1300 and 1200 (option 60) in one pool?
    Thanks in Advanced,
    Ahmed,

    To add to Scott's post.  Option 60 would be useful if you needed to put certain types of AP on specific controllers.  Otherwise, no real need to use it for the most part.
    Though, I do recall an issue a few years ago that some windows machines had issues getting DHCP if option 43 is being returned.
    Now, on an IOS switch, you can only configure one option 60 per DHCP scope
    HTH,
    Steve
    Please remember to rate useful posts, and mark questions as answered

  • How do i search for a string in a txt file using java??

    How do i search for a string in a txt file using java??
    could you please help thanks
    J

    Regular expressinos work just fine, especially when
    searching for patterns. But they seem to be impying
    it's a specific group of characters they're looking
    for, and indexOf() is much faster than a regex.If he's reading from a file, the I/O time will likely swamp any performance hit that regex introduces. I think contains() (or indexOf() if he's not on 5.0 yet) is preferable to regex just because it's simpler. (And in the case of contains(), the name makes for a very clear, direct mapping between your intent and the code that realizes it.)

  • How can I use Applescript to copy a file's icon to the clipboard?

    Hello,
    How can I use Applescript to copy a file's icon to the clipboard?
    Thanks.
    Lennox

    there is no way to do that that I know of. but you can extract an icon of a file to another file using command line tool [osxutils|http://sourceforge.net/projects/osxutils]. you can then call the relevant command from apple script using "do shell script".

  • How can i get getwayed url string using pluggable nav in news portlet?

    hi.
    How can i get getwayed url string using pluggable nav in news portlet?
    A code just like below is what I want.
    <param value="param=http://.../portal/server.pt/gateway/PTARGS_.../http/...">
    I tryed the following, but didn't work as I wanted.
    1.<param value="<pcs:valueexpr='var'/>">
    -> transformed. but I want the prefix 'param=' in the enquoted string's too.
    2. <param value="param=<pcs:valueexpr='var'/>">
    -> not transformed.
    Any idea?
    Hiroyuki

    Hi all,
    We have HPROF functionality in our latest roadmap, so you will see that feature in our next major release called JRockit R28.
    I recommend, above from the MemLeak documentation suggested by Makiey, the following information on how to use JRockit tools.
    Performance Tuning & Profiling:
    http://download.oracle.com/docs/cd/E13150_01/jrockit_jvm/jrockit/geninfo/diagnos/part_02.html
    Using JRockit tools:
    http://download.oracle.com/docs/cd/E13150_01/jrockit_jvm/jrockit/geninfo/diagnos/part_03.html
    Diagnostics & Troubleshooting
    http://download.oracle.com/docs/cd/E13150_01/jrockit_jvm/jrockit/geninfo/diagnos/part_04.html
    Best Regards,
    Tuva
    JRockit PM

  • How can I use AppleScript Studio to display an image

    How can I use AppleScript Studio to display an image in a dialog?

    Add an image well to your window in Interface Builder.
    You can also add an image file to the Resources group of your Xcode project and then set the image to be displayed inside the image well directly in Interface Builder. No AppleScript code is needed if the image is contained within your app bundle and can be set ahead of time like this.
    If the image is contained in your app's bundle but you need to set or change the image at run time then you can use a line of AppleScript to load it into the image well using just it's filename:
    set image of image view "yourImageView" of window "yourWindow" to load image "YourImageFile.jpg"
    If you need to load an image from an arbitrary location outside your app's bundle then use a path to the image file...
    set image of image view "yourImageView" of window "yourWindow" to load image "/path/to/YourImageFile.jpg"
    Steve

  • How to skip 3 chars when use "scanf from string" by the parameter "format string" ?

    hi, I want to read a num 123 from the string like that "sfg123" "fgd123" "ghj123"
    I know that I can use "%3s" to skip 3 chars, but it will add an output to "scanf from string"
    So, how to use parameter "format string" not only to skip 3 chars, but also add no output to the "scanf from string"
    Solved!
    Go to Solution.
    Attachments:
    1.JPG ‏15 KB

    Hi Chenyin,
    Try this VI....
    I think... This is what you are expecting....
    <<Kudos are welcome>>
    ELECTRO SAM
    For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.
    - John 3:16

  • How do count how many 'A' s in this string using sql stmt?

    hi all,
    i have a string like 'AAAAARAMAAAAKRISHNAAAA'.
    in this ,i want to find out how many 'A's .
    how do find out this using select stmt.

    (length(s) - nvl(length(replace(s, 'A')), 0)) / length('A')but consider (by modifying the question slightly to "how do count how many 'AA' s in this string using sql stmt? ")
    SQL>  select (length('AAAAARAMAAAAKRISHNAAAA') - nvl(length(replace('AAAAARAMAAAAKRISHNAAAA', 'AA')), 0)) / length('AA') x from dual
             X
             6
    1 row selected.couldn't I argue that the result should be 10 as e.g. in
    SQL>  select * from xmltable('let $str := "AAAAARAMAAAAKRISHNAAAA"
                            let $search := "AA"
                            for $i in 1 to string-length($str)
                              where substring($str, $i, string-length($search)) = $search
                              return substring($str, $i, string-length($search))' columns x varchar2(10) path '.')
    X        
    AA       
    AA       
    AA       
    AA       
    AA       
    AA       
    AA       
    AA       
    AA       
    AA       
    10 rows selected.Matter of definition I suppose .... ;)
    btw. regexp_count also yields 6:
    SQL>  select regexp_count('AAAAARAMAAAAKRISHNAAAA', 'AA') x from dual
             X
             6
    1 row selected.

  • How can i use a string name as an onject name.please help!

    hi it seems like an easy one but i can not find it anywhere.how can i use the name of a string as a name of an object such as the code(my problem is the code)...
    public void oda(String name1){ 
    String name2=name1+"s";
    String name3=name1+"ss";
    TextArea name1=new TextArea();
    TextArea name2=new TextArea();
    TextArea name3=new TextArea();
    i think my problem is clear but to be sure..
    how can i give a name to an object in my textarea which is already using as a string.
    thank u .

    it get very compilcated to change the name of the object you created. identity is something you don't want to mess with..you can do it by usin reflection, but it will slow down your application and (again) is quite complicated...
    a simple solution (and more object-oriennted) is to create a Wrapper, Decorator, or Extends the class.
    example
    public class MyTextBox{
        private String name = null;
        private boolean value = false;
        private JTextArea txtArea = null;
        public MyTextBox(String name, boolean value){
            txtArea = new JTextArea();
            this.value = value;
            this.isOn = isOn;
        public String getComponentName(){  return name; }
        pubic boolean getComponentValue(){ return value; }
        public JTextArea getTextArea(){ return area; }
    }

  • How come the JRE uses == to compare Strings?

    I was looking through the source of javax.swing.plaf.basic.BasicComboBoxUI and came across this:        public void propertyChange(PropertyChangeEvent e) {
                String propertyName = e.getPropertyName();
             JComboBox comboBox = (JComboBox)e.getSource();
                if ( propertyName == "model" ) {
                else if ( propertyName == "editor" && comboBox.isEditable() ) {
                else if ( propertyName == "editable" ) {
                else if ( propertyName == "enabled" ) {
                else if ( propertyName == "focusable" ) {
                else if ( propertyName == "maximumRowCount" ) {
                else if ( propertyName == "font" ) {
                else if ( propertyName == JComponent.TOOL_TIP_TEXT_KEY ) {
                else if ( propertyName == BasicComboBoxUI.IS_TABLE_CELL_EDITOR ) {
             else if (propertyName == "prototypeDisplayValue") {
             else if (propertyName == "renderer") {
            }So
    1) Is there a valid reason for the developer to have used == instead of .equals(...) to compare Strings?
    2) How does the code work consistently with this anomaly?
    Similar use of == and not .equals(...) is seen in many other swing classes.
    Doesn't affect me, but I would be interested to know if anyone can throw some light on this.
    Thanks, Darryl

    Darryl.Burke wrote:
    DeltaGeek, thank you for your response.
    Paul, I think I understand what you are saying, but the String reference propertyNamein this case comes from e.getPropertyName() from the PropertyChangeEvent class, not from within the BasicComboBoxUI class.
    I gather that all loaded classes share the same String pool, and that's how this works correctly. But in that case any comparison of a String variable to a literal String using == should also work.
    Then why the brouhaha about never using == to compare Strings?The key thing here is that the String returned by getPropertyName() must have come from a String literal. For example, in javax.swing.JComboBox:
    firePropertyChange( "maximumRowCount", oldCount, maximumRowCount );This string literal will be the same instance as the string literal in the code you posted.
    If they had instead done something like
    String s = "RowCount";
    boolean isMaximum = true;
    firePropertyChange((isMaximum ? "maximum" : "minimum") + s, oldCount, maximumRowCount );In this case, the String literal "maximumRowCount" is not used, but rather created from a concatenation at runtime, so it's likely that the comparison would fail.
    Note that the following would be the same String literal because this concatenation would be done at compile-time, not runtime:
    "maximum" + "RowCount"As for why, I agree with DeltaGeek: performance.

  • How do I use Sun Web Server 7.0u1 reverse proxy to change public URLs?

    Some of our installations use the Sun Web Server 7.0 (update 1, usually)
    for hosting some of the public resource and reverse-proxying other parts
    of the URI namespace from other backend servers (content, application
    and other types of servers).
    So far every type of backend server served a unique part of the namespace
    and there was no collision of names, and the backend resources were
    published in a one-to-one manner. That is, a backend resource like, say,
    http://appserver:8080/content/page.html would be published in the internet
    as http://www.publicsite.com/content/page.html
    I was recently asked to research whether we can rename some parts of
    the public URI namespace, to publish some or all resources as, say,
    http://www.publicsite.com/data/page.html while using the same backend
    resources.
    Another quest, possibly related in solution, was to make a tidy url for the
    first page the user opens of the site. That is, in the current solution when
    a visitor types the url "www.publicsite.com" in his or her browser, our web
    server returns an HTTP-302 redirect to the actual first page URL, so the
    browser sends a second request (and changes the URL in its location bar).
    One customer said that it is not "tidy". They don't want the URL to change
    right upon first rendering the page. They want the root page to be rendered
    instantly i the first HTTP request.
    So far I found that I can't solve these problems. I believe these problems
    share a solution because it relies on ability to control the actual URI strings
    requested by Sun Web Server from backend servers.
    Some details follow, now:
    It seems that the reverse proxy (Service fn="service-passthrough") takes
    only the $uri value which was originally requested by the browser. I didn't
    yet manage to override this value while processing a request, not even if
    I "restart" a request. Turning the error log up to "finest" I see that even
    when making the "service-passthrough" operation, the Sun Web Server
    still remembers that the request was for "/test" (in my test case below);
    it does indeed ask the backend server for an URI "/test" and that fails.
    [04/Mar/2009:21:45:34] finest (25095) www.publicsite.com: for host xx.xx.xx.83
    trying to GET /content/MainPage.html while trying to GET /test, func_exec reports:
    fn="service-passthrough" rewrite-host="true" rewrite-location="true"
    servers="http://10.16.2.127:8080" Directive="Service" DaemonPool="2b1348"
    returned 0 (REQ_PROCEED)My obj.conf file currently has simple clauses like this:
    # this causes /content/* to be taken from another (backend) server
    NameTrans fn="assign-name" from="/content" name="content-test" nostat="/content"
    # this causes requests to site root to be HTTP-redirected to a certain page URI
    <If $uri =~ '^/$'>
        NameTrans fn="redirect"
            url="http://www.publicsite.com/content/MainPage.html"
    </If>
    <Object name="content-test">
    ### This maps http://public/content/* to http://10.16.2.127:8080/content/*
    ### Somehow the desired solution should instead map http://public/data/* to http://10.16.2.127:8080/content/*
        Service fn="service-passthrough" rewrite-host="true" rewrite-location="true" servers="http://10.16.2.127:8080"
        Service fn="set-variable" set-srvhdrs="host=www.publicsite.com:80"
    </Object>
    I have also tried "restart"ing the request like this:
        NameTrans fn="restart" uri="/data"or desperately trying to set the new request uri like this:
        Service fn="set-variable"  uri="/magnoliaPublic/Main.html"Thanks for any ideas (including a statement whether this can be done at all
    in some version of Sun Web Server 7.0 or its opensourced siblings) ;)
    //Jim

    Some of our installations use the Sun Web Server 7.0 (update 1, usually)please plan on installing the latest service pack - 7.0 Update 4. these updates addresses potentially critical bug fixes.
    I was recently asked to research whether we can rename some parts of
    the public URI namespace, to publish some or all resources as, say,
    http://www.publicsite.com/data/page.html while using the same backend
    resources.> now, if all the resources are under say /data, then how will you know which pages need to be sent to which back end resources. i guess, you probably meant to check for /data/page.html should go to <back-end>/content/page.html
    yes, you could do something like
    - edit your corresponding obj.conf (<hostname>-obj.conf or obj.conf depending on your configuration)
    <Object name=¨default¨>
    <If $uri = ¨/page/¨>
    #move this nametrans SAF (for map directive - which is for reverse proxy within <if> clause)
    NameTrans.. fn=map
    </If
    </Object>
    and you could do https-<hostname>/bin/reconfig (dynamic reconfiguration) to check out if this is what you wanted. also, you might want to move config/server.xml <log-level> to finest and do your configuration . this way, you would get enough information on what is going on within your server logs.
    finally,when you are satisfied, you might have to run the following command to make your manual change into admin config repository.
    <install-root>/bin/wadm pull-config user=admin config=<hostname> <hostname>
    <install-root>/bin/wadm deploy-config --user=admin <hostname>
    you might want to check out this for more info on how you could use <if> else condition to handle your requirement.
    http://docs.sun.com/app/docs/doc/820-6599/gdaer?a=view
    finally, you might want to refer to this doc - which explains on ws7 request processing overview. this should provide you with some pointers as to what these different directives mean
    http://docs.sun.com/app/docs/doc/820-6599/gbysz?a=view
    >
    One customer said that it is not "tidy". They don't want the URL to change
    right upon first rendering the page. They want the root page to be rendered
    instantly i the first HTTP request.
    please check out the rewrite / restart SAF. this should help you.
    http://docs.sun.com/app/docs/doc/820-6599/gdada?a=view
    pl. understand that - like with more web servers - ordering of directives is very important within obj.conf. so, you might want to make sure that you verify the obj.conf directive ordering is what you want it to do..
    It seems that the reverse proxy (Service fn="service-passthrough") takes
    only the $uri value which was originally requested by the browser. I didn't
    yet manage to override this value while processing a request, not even if
    I "restart" a request. Turning the error log up to "finest" I see that even
    when making the "service-passthrough" operation, the Sun Web Server
    still remembers that the request was for "/test" (in my test case below);
    it does indeed ask the backend server for an URI "/test" and that fails.
    now, you are in the totally wrong direction. web server 7 includes a highly integrated reverse proxy solution compared to 6.1. unlike 6.1, you don´t have to download a separate plugin . however, you will need to manually migrate your 6.1 based reverse proxy settings into 7.0. please check out this blog link on how to set up a reverse proxy
    http://blogs.sun.com/amit/entry/setting_up_a_reverse_proxy
    feel free to post to us if you need any futher help
    you are probably better off - starting fresh
    - install ws7u4
    - use gui or CLI to create a reverse proxy and map one on one - say content
    http://docs.sun.com/app/docs/doc/820-6601/create-reverse-proxy-1?a=view
    if you don´t plan on using ws7 integrated web container (ability to process jsp/servlet), then you could disable java support as well. this should reduce your server memory footprint
    <install-root>/bin/wadm disable-java user=admin config=<hostname>
    <install-root>/bin/wadm create-reverse-proxy user=admin uri-prefix=/content server=<http://your back end server/ config=<hostname> --vs=<hostname>
    <install-root>/bin/wadm deploy-config --user=admin <hostname>
    now, you can check out the regular express processing and <if> syntax from our docs and try it out within <https-<hostname>/config/<hostname>-obj.conf> file and restart the server. pl. note that once you disable java, ws7 admin server creates <vs>-obj.conf and you need to edit this file and not default obj.conf for your changes to be read by server.
    >
    I have also tried "restart"ing the request like this:
    NameTrans fn="restart" uri="/data"
    ordering is very important here... you need to do this some thing like
    <Object name=default>
    <If not $restarted>
    NameTrans fn=restart uri from=/¨ uri=/foo.
    </If>

  • How to use an if statement in javascript code

    Hello,
    I have a batch processing script to search for text "employee signature" on each page in a multiple page file and to then list in the console any pages that do not have the "Employee Signature" text included.
    The script is not yet functional as an if statement needs to be included.
    Can anyone please advise how to use an if statement in javascript code?
    var numpages = this.numPages;
    for (var i=0; i < numpages; i++)
    search.query("Employee Signature", "ActiveDoc");
    console.println('Pages that do not include an employee signature: ' + this.pageNum +' ');
    Any assistance will be most appreciated.

    Thank you very much for your assistance try.
    I have modified the code as suggested and the page numbers are now listing correctly, thank you, but....................,
    The console  lists every page as having an "employee signature" when there are pages in the document that do not have an employee signature.
    The code (revised as follows) is not processing the "getPageNthWord part of the statement" in the console report?
    Can you please advise where the code needs reworking?
    var ckWords; // word pair to test
    var bFound = false; // logical status of found words
    // loop through pages
    for (var i = 0; i < this.numPages; i++ ) {
       bFound = false; // set found flag to false
       numWords = this.getPageNumWords(i); // number of words on page
       // loop through the words on page
       for (var j = 0; j < numWords; j++) {
          // get word pair to test
          ckWords = this.getPageNthWord(i, j) + ' ' + this.getPageNthWord(i, j + 1); // test words
          // check to see if word pair is 'Employee' string is present
          if ( ckWord == "Employee") {
             bFound = true; // indicate found logical value
             console.println('Pages that includes an employee signature: ' + (i + 1) +' ');
             break; // no need to further test for this page
          } // end Employee Signature
       } // end word loop
       // test to see if words not found
       if(bFound == false) {
             console.println('Pages that do include an employee signature: ' + (i + 1) +' ');
        } // end not found on page  
    } // end page loop
    Thank you

Maybe you are looking for

  • Installation of ECC 6.0 on vmware

    Dear Team, I am trying to install ECC 6.0 on VMware workstation, to simulate existing environment. I have an external HDD of 500 GB out of which I have reserved 290GB for ECC installation. The VM has 3 GB of memory allocated. Operating system: window

  • Error Msg while trying to post GR

    An error occurred when I try to post  GOODS RECEIPT, which is " G/L account 300010 does not exist in chart of account CAUS" ,  I do not see the G/L account anywhere typed? How do I resolve this issue, so I can post the GR. Thanks. Steve.

  • Exporting full quality problem.

    i shoot my movie in 16:9 on my sony camcorder. everything works perfectly in regards to editing and transfering to iDvd. the one thing i noticed that was weird is 2 days ago i made a short clip. about 5 minutes in 16:9 format. got it in and edited it

  • Purchase requisition without sales order

    Hi experts, I'm facing with a very strange problem. In our system,  purchase requisition are created automatically when sales order are created. Problem is that some purchase requisition does not contain linkage to sales order (does not have any link

  • NOKIA MAPS! The biggest scam! Simply **bleep**

    All users are complaining about NOKIA MAP Loader. Nokia is not giving any answers. So, we don't want to became nokia betatesters. Stop using this application... it is the biggest **bleep** i have ever seen!