Convert Javascript to Applescript

Hi,
I need to convert javascript to Apple script. Please help!!!
try {
app.activeDocument.layers.getByName( '.ARD' ).remove(); } catch (e) {};
MOhan

tell application "Adobe Illustrator"
          tell the current document
                    try
                              delete (the first layer whose name is ".ARD")
                    end try
          end tell
end tell
It's always a help if you state the language choice in the question…
Edit… a change of string filter
tell a
tell application "Adobe Illustrator"
          tell the current document
                    try
                              delete (the first layer whose name ends with ".ARD")
                    end try
          end tell
end tell

Similar Messages

  • Converting Simple Indesign AppleScript to Javascript

    Hi,
    I have been using as imple Indesign AppleScript but need to convert it to javascript and have no prior experience.  I've been reading the Adobe pdf about scripting and it is great as it shows the differences between the 3 (as, js, vb) but I'm still having trouble figuring out how this would conver.  Would anyone be able to show me the converted result?
    AppleScript:
    tell application "Adobe InDesign CS5.5"
         tell every document
              set visible of layer "Interactive - Web" to true
              set visible of layer "Interactive - Print" to false
         end tell
    end tell
    Javascript:
    var myDocuments = app.documents.everyItem(); // something like this?
    It hides/shows the visibility of 2 specific layers for all opened documents.  I pretty much need to hide/show 2 specific layers ina  book and this should/can accomplish that.
    Thanks for any help!

    This should work:
    var documentsArray = app.documents.everyItem().getElements();
    for (var i = 0; i < documentsArray.length; i++) {
              var document = documentsArray[i];
              var layers = document.layers;
              layers.itemByName("Interactive - Web").visible = true;
              layers.itemByName("Interactive - Print").visible = false;
    Also, it might be possible to do this without using "getElements" which "resolves the object specifier", eliminating the need for the "for" loop. Something like this:
    app.documents.everyItem().layers.itemByName("Interactive - Web").visible = true;
    app.documents.everyItem().layers.itemByName("Interactive - Print").visible = false;

  • Trigger .jsx (Javascript) through Applescript

    I have .jsx (javascript) for InDesign CS5. I am trying to automate in a batch mode. I would like to know how to trigger that Javascript through applescript. It would be much appreciate if any one help me on this regard.
    ~John

    I have .jsx (javascript) for InDesign CS5. I am trying to automate in a batch mode. I would like to know how to trigger that Javascript through applescript. It would be much appreciate if any one help me on this regard.
    ~John

  • Acrobat Web Capture cannot convert javascript links...?

    In Matrix (Multiple Listing Service) Acrobat Adobe 10 Standard won't convert javascript links in newly created PDFs Documents from Matrix.   The Error message is : Acrobat Web Capture cannot convert javascript links and the link often does not work correctly when opened in the web browser...  
    Is there any javascript download or work around program that can fix this problem?
    Thanks

    Probably not. Pretty hard for Acrobat to handle all of the web JavaScript and possible function calls that could appear on a web page and be located in another directory.
    If this is important to you, you can use the bug report/feature request page at adobe.com..

  • Convert javascript array to java array

    Is there any way possible to convert javascript array to java array?

    if you will try to experiment a javascript array
    putting it to a hidden element, it will be converted
    to a string (comma delimited). You can get the value
    of that element as a string and use StringTokenizer
    class to put the values into a java arrayThanks, got it.

  • Convert to Profile (Applescript)

    Hi All,
    I'm looking for an applescript command to perform "Convert to Profile" on my current document in Photoshop CS3. I've seen a Javascript solution in this Forum, but nothing for applescript. Any help would be appreciated.
    I would also love to know how to set PS preferences so that all new docs created in a given image mode use a pre-set profile.
    Thanks,
    Jamie

    Jamie, you can set Photoshop's colour settings by name string before opening/creating your files. You can decide how to treat profiles there. This should give you some help.
    tell application "Adobe Photoshop CS2"
    -- Record current settings
    set User_CS to color settings
    -- Apply your settings
    set color settings to "Marks Test"
    end tell
    tell application "Adobe Photoshop CS2"
    activate
    tell document 1
    -- Apply a colour profile
    if color profile name ≠ "Europe ISO Coated FOGRA27" then
    set color profile name to "Europe ISO Coated FOGRA27"
    end if
    -- Convert to colour profile
    if color profile name ≠ "U.S. Sheetfed Coated v2" then
    convert to profile "U.S. Sheetfed Coated v2" intent absolute colorimetric with dithering without blackpoint compensation
    end if
    end tell
    end tell
    tell application "Adobe Photoshop CS2"
    -- Put back settings
    set color settings to User_CS
    end tell

  • How to convert javascript alert message into an Inline message in Apex Page

    Hi All. Im new to Apex.
    Present Approach -
    I have a dynamic report region developed using API's like APEX_ITEM etc. I am using java scripts to validate these dynamic items and popup alert messages as shown below -
    function ValidateNotObservedCB(p_row_num)
    var v_row_num = p_row_num;
    var v_not_observed_cb_status = document.getElementById('f_notobserved_'+v_row_num).checked;
    var v_not_in_district_cb_status = document.getElementById('f_notindistrict_'+v_row_num).checked;
    var v_program_code = document.getElementById("f_program_code_"+v_row_num).value;
    if ( (v_program_code.length>0)&& ( document.getElementById('f_notobserved_'+v_row_num).checked==true ))
         bold alert("You have already entered a program code.") bold
         document.getElementById('f_notobserved_'+v_row_num).checked=false ;
         document.getElementById('f_notobserved_'+v_row_num).value='N';
    } else if ( (v_program_code.length==0)&& ( document.getElementById('f_notobserved_'+v_row_num).checked==true )) {
         document.getElementById('f_notobserved_'+v_row_num).value='Y';
         document.getElementById('f_notobserved_'+v_row_num).checked=true ;
    } else
         document.getElementById('f_notobserved_'+v_row_num).checked=false ;
         document.getElementById('f_notindistrict_'+v_row_num).checked=false;
         document.getElementById('f_notindistrict_'+v_row_num).value='N';
         document.getElementById('f_notobserved_'+v_row_num).value='N';
    Question/Issue - How can I convert these alert messages into Inline messages to show on the page, similar to what appears when we do Item Validations in APEX.
    Waiting for responses as this is an urgent requirement.
    Thanks in Advance,
    Madhu

    Hi,
    I did with jQuery small sample
    http://apex.oracle.com/pls/otn/f?p=40323:36
    Page HTML header is
    <script type="text/javascript">
    $(function(){
      var lImg = $('<img alt="" class="pb" style="float: right;" src="/i/delete.gif"/>');
      var lMesg = $('<div id="MESSAGE" style="border-top: 1px solid rgb(142, 170, 142); border-bottom: 1px solid rgb(142, 170, 142); padding: 5px; background: rgb(235, 241, 235) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; width: 450px;" class="t14notification"></div>');
      $('.pb').live('click',function(){
        $x_Remove("MESSAGE");
      $('#SUBMIT').click(function(){
        if($('#MESSAGE').length == 0){
          $('#t14Messages').children().append($(lMesg));
           $(lMesg).append($(lImg));
           $(lImg).after($('#P36_NOTIFICATION').val());
        }else{
           $('#MESSAGE').text('');
           $('#MESSAGE').append($(lImg));
           $(lImg).after($('#P36_NOTIFICATION').val());
    </script>I do not know does it help. Using this depend much on theme, defined class and IDs.
    Br, Jari

  • Call JavaScript from AppleScript using InDesign CS2

    Can this be done?
    The following script:
    tell application "Adobe InDesign CS2"
    tell active document
    do script "var thisNumber = 5;" language javascript
    end tell
    end tell
    results in the error:
    tell application "Adobe InDesign CS2"
    do script "var thisNumber = 5;" language javascript
    "Adobe InDesign CS2 got an error: \"var thisNumber = 5;\" doesnt understand the do script message."
    Why doesn't this work and what can I do to fix it?
    William

    On 4/12/08 5:41 AM, "Olav Kvern" <[email protected]> wrote:<br /><br />> These sorts of things are hard to see in AppleScript, because the dictionary<br />> browser(s) don't group methods with their parent objects. Sal Soghoian at<br />> Apple has long said that this needs fixing.<br /><br />And in fact it has been fixed -- it just needs app developers to write their<br />dictionaries appropriately. For a good example, have a look at the<br />dictionary of Script Debugger 4.5 -- you'll see classes listed with<br />elements, properties, and "Responds to". And none of that truncation ID's<br />dictionary is full of.<br /><br />-- <br />Shane Stanley <[email protected]><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>

  • How to call javascript using applescript in InDesign cs2 Mac

    Hi,
    I need to integrate javascript with my apple script??? how to use it???please help me...i need it immediately..........

    Hi Andrew,
    Here is an example for you – a snippet from my script:
    global myBridgeLabel
    -- function that runs on clicking the button in adobe script studio project
    on clicked theObject
    if name of theObject is "b1" then
    set processName to "Started working"
    set myBridgeLabel to "Red"
    set myLabel to 1
    else if name of theObject is "b2" then
    set processName to "Started doing this"
    set myBridgeLabel to "Green"
    set myLabel to 2
    else if name of theObject is "b3" then
    set processName to "Started doing that"
    set myBridgeLabel to "Yellow"
    set myLabel to 3
    else if name of theObject is "b4" then
    set processName to "Finished doing this"
    set myBridgeLabel to "Blue"
    set myLabel to 4
    else if name of theObject is "b5" then
    set processName to "Finished doing that"
    set myBridgeLabel to "Purple"
    set myLabel to 5
    end if
    tell application "Adobe InDesign CS2"
    set mydocument to active document
    set myDocumentPath to full name of mydocument
    set workerName to "Kasyan"
    tell metadata preferences of mydocument
    set theDate to current date
    set myWeekday to weekday of theDate as string
    set myDenNedeli to my convertWeekday(myWeekday)
    set myRecord to (processName & " – " & workerName & " – ") & myDenNedeli & " " & text 1 thru -4 of time string of theDate & " \r"
    set myHistory to get property namespace "http://ns.adobe.com/photoshop/1.0/" path "History"
    set property namespace "http://ns.adobe.com/photoshop/1.0/" path "History" value myHistory & myRecord
    end tell
    set myJavaScript to "var myLabel =\"" & myBridgeLabel & "\"; app.activate(); var bt = new BridgeTalk; bt.target = \"bridge\"; myScript = 'app.displayDialogs = \"none\"; var t = new Thumbnail (File (\"" & myDocumentPath & "\")); var mdata = t.metadata; mdata.namespace = \"http://ns.adobe.com/xap/1.0/\"; mdata.Label = \"' + myLabel + '\";'; bt.body = myScript; bt.send();"
    do script myJavaScript language javascript
    In this javascript I use pares of single and double quotes.
    The main java script – myJavaScript – (inside double quotes) contains another java script – myScript – (inside single quotes) which runs in Bridge via BridgeTalk.
    I also put variables from AppleScript into JavaScript by using two pares of double quotes – the outside pare I escape with slashes:
    set myBridgeLabel to "Red" -- a variable I defined in AppleScript
    set myJavaScript to "var myLabel =\"" & myBridgeLabel & "\"; app.activate();
    -- the contents of myBridgeLabel variable now becomes part of the JavaScript
    Kasyan

  • Converting old Quark applescript to InDesign - problems

    Hello
    I'm converting an old Quark applescript to InDesign CS3 finally. I'm having a problem with placing, scaling and adjusting images.
    Here's how it works ... a user fills out a Microsoft Word form, which a designer unlocks and pastes into the layout, and then runs the script. The image frames are all labeled, and that's how I'd like to call them.
    Here's a snippet of the Quark portion that I'm having a problem with ...
    set Todayicon to item (offset from list Dayicons of Todayval) of DayIconEPS
    set Todayiconpath to (OPIpath and Todayicon as string)
    set Todayicon to item 1 of Todayiconpath
    set scale of Todayicon to {"65","65"}
    set offset of Todayicon to {"-1p2","0p5"}
    And here's what I'm thinking I need to do in InDesign CS3 ...
    set Todayicon to item (offset from list Dayicons of Todayval) of DayIconEPS
    set Todayiconpath to (OPIpath and Todayicon as string)
    set Todayicon to item 1 of Todayiconpath
    set TodayiconTransformationMatrix to make transformation matrix with properties {horizontal scale factor:0.65, vertical scale factor:0.65, geometric bounds:[-14,-5]
    transform Todayicon in inner coordinates with matrix TodayiconTransformationMatrix
    Unfortunately, the script errors out when it tries to make the transformation matrix, even though I'm following the examples in the Working with Tranformations in Applescript pdf.
    Any ideas? I guess I can put dummy images in the layout and call a "Place" to override the dummy images, which should keep the scale, but it doesn't help me when I need to offset the images sometimes.

    Philip Regan wrote: "The new scripting model with all of its touted advantaged is really poorly executed."
    While I didn't design the scripting model for transformations, and disagree with some of the decisions made in the design, I understand that InDesign's transformations architecture had to be rewritten for CS3. There were too many cases in CS2 where objects could not be returned to their original coordinates after transformation. The scripting implementation pretty much had to go along with the change in the underlying architecture.
    If you'd rather things work the way they worked in CS2, why not use the set of transform "wrappers" that I wrote and included in the transform tutorial? With those functions, you don't really need to worry about the new model.
    Thanks,
    Ole

  • Easy way to convert javascript to a java applet?

    Hello all! I am relatively new to java and java programming and had a question about converting a JavaScript to a java applet or even a standalone application. I included the JavaScript code for a checkers game below and wanted to know what would be the easiest way to convert this code if at all possible?
    Thanks in advance,
    Bob
    <SCRIPT language=JavaScript>
    <!--
    version = 1.0;
    // -->
    </SCRIPT>
    <SCRIPT language=JavaScript1.1>
    <!--
    version = 1.1;
    // -->
    </SCRIPT>
    <SCRIPT language=JavaScript>
    <!--
    if (version==1.0)
    document.write("Your browser doesn't have JavaScript 1.1 capabilities. "
    + "This checkers game script only works on Netscape 3+ and MSIE 4+.");
    // -->
    </SCRIPT>
    <SCRIPT language=JavaScript1.1>
    <!--
    // Checkers Game
    // black.gif
    // gray.gif
    // you1.gif -- normal piece (player/red)
    // you2.gif -- highlighted piece
    // you1k.gif -- kinged normal piece
    // you2k.gif -- kinged highlighted piece
    // me1.gif -- normal piece (computer/black)
    // me2.gif -- highlighted piece
    // me1k.gif -- kinged normal piece
    // me2k.gif -- kinged highlighted piece
    function preload() {
    this.length = preload.arguments.length;
    for (var i = 0; i < this.length; i++) {
    this[i] = new Image();
    this.src = preload.arguments[i];
    var pics = new preload("black.gif","gray.gif",
    "you1.gif","you2.gif","you1k.gif","you2k.gif",
    "me1.gif","me2.gif","me1k.gif","me2k.gif");
    var black = -1; // computer is black
    var red = 1; // visitor is red
    var square_dim = 35;
    var piece_toggled = false;
    var my_turn = false;
    var double_jump = false;
    var comp_move = false;
    var game_is_over = false;
    var safe_from = safe_to = null;
    var toggler = null;
    var togglers = 0;
    function Board() {
    board = new Array();
    for (var i=0;i<8; i++) {
    board[i] = new Array();
    for (var j=0;j<8;j++)
    board[i][j] = Board.arguments[8*j+i];
    board[-2] = new Array(); // prevents errors
    board[-1] = new Array(); // prevents errors
    board[8] = new Array(); // prevents errors
    board[9] = new Array(); // prevents errors
    var board;
    Board(1,0,1,0,1,0,1,0,
    0,1,0,1,0,1,0,1,
    1,0,1,0,1,0,1,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,-1,0,-1,0,-1,0,-1,
    -1,0,-1,0,-1,0,-1,0,
    0,-1,0,-1,0,-1,0,-1);
    function message(str) {
    if (!game_is_over)
    document.disp.message.value = str;
    function moveable_space(i,j) {
    // calculates whether it is a gray (moveable)
    // or black (non-moveable) space
    return (((i%2)+j)%2 == 0);
    function Coord(x,y) {
    this.x = x;
    this.y = y;
    function coord(x,y) {
    c = new Coord(x,y);
    return c;
    document.write("<table border=0 cellspacing=0 cellpadding=0 width="+(square_dim*8+8)
    +"<tr><td><img src='black.gif' width="+(square_dim*8+8)
    +" height=4><br></td></tr>");
    for(var j=0;j<8;j++) {
    document.write("<tr><td><img src='black.gif' width=4 height="+square_dim+">");
    for(var i=0;i<8;i++) {
    if (moveable_space(i,j))
    document.write("<a href='javascript:clicked("+i+","+j+")'>");
    document.write("<img src='");
    if (board[i][j]==1) document.write("you1.gif");
    else if (board[i][j]==-1) document.write("me1.gif");
    else if (moveable_space(i,j)) document.write("gray.gif");
    else document.write("black.gif");
    document.write("' width="+square_dim+" height="+square_dim
    +" name='space"+i+""+j+"' border=0>");
    if (moveable_space(i,j)) document.write("</a>");
    document.write("<img src='black.gif' width=4 height="+square_dim+"></td></tr>");
    document.write("<tr><td><img src='black.gif' width="+(square_dim*8+8)
    +" height=4><br></td></tr></table><br>"
    +"<form name='disp'><textarea name='message' wrap=virtual rows=2 cols=40></textarea><br><input "
    +"type=button value=\"Start the Game Over\" onClick=\"location.href+=''\"></form>");
    function clicked(i,j) {
    if (my_turn) {
    if (integ(board[i][j])==1) toggle(i,j);
    else if (piece_toggled) move(selected,coord(i,j));
    else message("First click one of your red pieces, then click where you want to move it");
    } else {
    message("It's not your turn yet. Hang on a sec!");
    function toggle(x,y) {
    if (my_turn) {
    if (piece_toggled)
    draw(selected.x,selected.y,"you1"+((board[selected.x][selected.y]==1.1)?"k":"")+".gif");
    if (piece_toggled && (selected.x == x) && (selected.y == y)) {
    piece_toggled = false;
    if (double_jump) { my_turn = double_jump = false; computer(); }
    } else {
    piece_toggled = true;
    draw(x,y,"you2"+((board[x][y]==1.1)?"k":"")+".gif");
    selected = coord(x,y);
    } else {
    if ((piece_toggled) && (integ(board[selected_c.x][selected_c.y])==-1))
    draw(selected_c.x,selected_c.y,"me1"+((board[selected_c.x][selected_c.y]==-1.1)?"k":"")+".gif");
    if (piece_toggled && (selected_c.x == x) && (selected_c.y == y)) {
    piece_toggled = false;
    } else {
    piece_toggled = true;
    draw(x,y,"me2"+((board[x][y]==-1.1)?"k":"")+".gif");
    selected_c = coord(x,y);
    function draw(x,y,name) {
    document.images["space"+x+""+y].src = name;
    function integ(num) {
    if (num != null)
    return Math.round(num);
    else
    return null;
    function abs(num) {
    return Math.abs(num);
    function sign(num) {
    if (num < 0) return -1;
    else return 1;
    function concatenate(arr1,arr2) {
    // function tacks the second array onto the end of the first and returns result
    for(var i=0;i<arr2.length;i++)
    arr1[arr1.length+i] = arr2[i];
    return arr1;
    function legal_move(from,to) {
    if ((to.x < 0) || (to.y < 0) || (to.x > 7) || (to.y > 7)) return false;
    piece = board[from.x][from.y];
    distance = coord(to.x-from.x,to.y-from.y);
    if ((distance.x == 0) || (distance.y == 0)) {
    message("You may only move diagonally.");
    return false;
    if (abs(distance.x) != abs(distance.y)) {
    message("Invalid move.");
    return false;
    if (abs(distance.x) > 2) {
    message("Invalid move.");
    return false;
    if ((abs(distance.x) == 1) && double_jump) {
    return false;
    if ((board[to.x][to.y] != 0) || (piece == 0)) {
    return false;
    if ((abs(distance.x) == 2)
    && (integ(piece) != -integ(board[from.x+sign(distance.x)][from.y+sign(distance.y)]))) {
    return false;
    if ((integ(piece) == piece) && (sign(piece) != sign(distance.y))) {
    return false;
    return true;
    function move(from,to) {
    my_turn = true;
    if (legal_move(from,to)) {
    piece = board[from.x][from.y];
    distance = coord(to.x-from.x,to.y-from.y);
    if ((abs(distance.x) == 1) && (board[to.x][to.y] == 0)) {
    swap(from,to);
    } else if ((abs(distance.x) == 2)
    && (integ(piece) != integ(board[from.x+sign(distance.x)][from.y+sign(distance.y)]))) {
    double_jump = false;
    swap(from,to);
    remove(from.x+sign(distance.x),from.y+sign(distance.y));
    if ((legal_move(to,coord(to.x+2,to.y+2)))
    || (legal_move(to,coord(to.x+2,to.y-2)))
    || (legal_move(to,coord(to.x-2,to.y-2)))
    || (legal_move(to,coord(to.x-2,to.y+2)))) {
    double_jump = true;
    message("You may complete the double jump or click on your piece to stay still.");
    if ((board[to.x][to.y] == 1) && (to.y == 7)) king_me(to.x,to.y);
    selected = to;
    if (game_over() && !double_jump) {
    setTimeout("toggle("+to.x+","+to.y+");my_turn = double_jump = false;computer();",1000);
    return true;
    function king_me(x,y) {
    if (board[x][y] == 1) {
    board[x][y] = 1.1; // king you
    draw(x,y,"you2k.gif");
    } else if (board[x][y] == -1) {
    board[x][y] = -1.1; // king me
    draw(x,y,"me2k.gif");
    function swap(from,to) {
    if (my_turn || comp_move) {
    dummy_src = document.images["space"+to.x+""+to.y].src;
    document.images["space"+to.x+""+to.y].src = document.images["space"+from.x+""+from.y].src;
    document.images["space"+from.x+""+from.y].src = dummy_src;
    dummy_num = board[from.x][from.y];
    board[from.x][from.y] = board[to.x][to.y];
    board[to.x][to.y] = dummy_num;
    function remove(x,y) {
    if (my_turn || comp_move)
    draw(x,y,"gray.gif");
    board[x][y] = 0;
    function Result(val) {
    this.high = val;
    this.dir = new Array();
    function move_comp(from,to) {
    toggle(from.x,from.y);
    comp_move = true;
    swap(from,to);
    if (abs(from.x-to.x) == 2) {
    remove(from.x+sign(to.x-from.x),from.y+sign(to.y-from.y));
    if ((board[to.x][to.y] == -1) && (to.y == 0)) king_me(to.x,to.y);
    setTimeout("selected_c = coord("+to.x+","+to.y+");piece_toggled = true;",900);
    setTimeout("bak=my_turn;my_turn=false;toggle("+to.x+","+to.y+");my_turn=bak;",1000);
    if (game_over()) {
    setTimeout("comp_move = false;my_turn = true;togglers=0;",600);
    message("Ok. It's your turn. You may make your move.");
    return true;
    function game_over() { // make sure game is not over (return false if game is over)
    comp = you = false;
    for(var i=0;i<8;i++) {
    for(var j=0;j<8;j++) {
    if(integ(board[i][j]) == -1) comp = true;
    if(integ(board[i][j]) == 1) you = true;
    if (!comp) message("You beat me!");
    if (!you) message("Gotcha! Game over.");
    game_is_over = (!comp || !you)
    return (!game_is_over);
    // the higher the jump_priority, the more often the computer will take the jump over the safe move
    var jump_priority = 10;
    function computer() {
    // step one - prevent any jumps
    for(var j=0;j<8;j++) {
    for(var i=0;i<8;i++) {
    if (integ(board[i][j]) == 1) {
    if ((legal_move(coord(i,j),coord(i+2,j+2))) && (prevent(coord(i+2,j+2),coord(i+1,j+1)))) {
    return true;
    } if ((legal_move(coord(i,j),coord(i-2,j+2))) && (prevent(coord(i-2,j+2),coord(i-1,j+1)))) {
    return true;
    } if (board[i][j] == 1.1) {
    if ((legal_move(coord(i,j),coord(i-2,j-2))) && (prevent(coord(i-2,j-2),coord(i-1,j-1)))) {
    return true;
    } if ((legal_move(coord(i,j),coord(i+2,j-2))) && (prevent(coord(i+2,j-2),coord(i+1,j-1)))) {
    return true;
    // step two - if step one not taken, look for jumps
    for(var j=7;j>=0;j--) {
    for(var i=0;i<8;i++) {
    if (jump(i,j))
    return true;
    safe_from = null;
    // step three - if step two not taken, look for safe single space moves
    for(var j=0;j<8;j++) {
    for(var i=0;i<8;i++) {
    if (single(i,j))
    return true;
    // if no safe moves, just take whatever you can get
    if (safe_from != null) {
    move_comp(safe_from,safe_to);
    } else {
    message("You beat me!!");
    game_is_over = true;
    safe_from = safe_to = null;
    return false;
    function jump(i,j) {
    if (board[i][j] == -1.1) { 
    if (legal_move(coord(i,j),coord(i+2,j+2))) {
    move_comp(coord(i,j),coord(i+2,j+2));
    setTimeout("jump("+(i+2)+","+(j+2)+");",500);
    return true;
    } if (legal_move(coord(i,j),coord(i-2,j+2))) {
    move_comp(coord(i,j),coord(i-2,j+2));
    setTimeout("jump("+(i-2)+","+(j+2)+");",500);
    return true;
    } if (integ(board[i][j]) == -1) {
    if (legal_move(coord(i,j),coord(i-2,j-2))) {
    move_comp(coord(i,j),coord(i-2,j-2));
    setTimeout("jump("+(i-2)+","+(j-2)+");",500);
    return true;
    } if (legal_move(coord(i,j),coord(i+2,j-2))) {
    move_comp(coord(i,j),coord(i+2,j-2));
    setTimeout("jump("+(i+2)+","+(j-2)+");",500);
    return true;
    return false;
    function single(i,j) {
    if (board[i][j] == -1.1) {
    if (legal_move(coord(i,j),coord(i+1,j+1))) {
    safe_from = coord(i,j);
    safe_to = coord(i+1,j+1);
    if (wise(coord(i,j),coord(i+1,j+1))) {
    move_comp(coord(i,j),coord(i+1,j+1));
    return true;
    } if (legal_move(coord(i,j),coord(i-1,j+1))) {
    safe_from = coord(i,j);
    safe_to = coord(i-1,j+1);
    if (wise(coord(i,j),coord(i-1,j+1))) {
    move_comp(coord(i,j),coord(i-1,j+1));
    return true;
    } if (integ(board[i][j]) == -1) {
    if (legal_move(coord(i,j),coord(i+1,j-1))) {
    safe_from = coord(i,j);
    safe_to = coord(i+1,j-1);
    if (wise(coord(i,j),coord(i+1,j-1))) {
    move_comp(coord(i,j),coord(i+1,j-1));
    return true;
    } if (legal_move(coord(i,j),coord(i-1,j-1))) {
    safe_from = coord(i,j);
    safe_to = coord(i-1,j-1);
    if (wise(coord(i,j),coord(i-1,j-1))) {
    move_comp(coord(i,j),coord(i-1,j-1));
    return true;
    return false;
    function possibilities(x,y) {
    if (!jump(x,y))
    if (!single(x,y))
    return true;
    else
    return false;
    else
    return false;
    function prevent(end,s) {
    i = end.x;
    j = end.y;
    if (!possibilities(s.x,s.y))
    return true;
    else if ((integ(board[i-1][j+1])==-1) && (legal_move(coord(i-1,j+1),coord(i,j)))) {
    return move_comp(coord(i-1,j+1),coord(i,j));
    } else if ((integ(board[i+1][j+1])==-1) && (legal_move(coord(i+1,j+1),coord(i,j)))) {
    return move_comp(coord(i+1,j+1),coord(i,j));
    } else if ((board[i-1][j-1]==-1.1) && (legal_move(coord(i-1,j-1),coord(i,j)))) {
    return move_comp(coord(i-1,j-1),coord(i,j));
    } else if ((board[i+1][j-1]==-1.1) && (legal_move(coord(i+1,j-1),coord(i,j)))) {
    return move_comp(coord(i+1,j-1),coord(i,j));
    } else {
    return false;
    function wise(from,to) {
    i = to.x;
    j = to.y;
    n = (j>0);
    s = (j<7);
    e = (i<7);
    w = (i>0);
    if (n&&e) ne = board[i+1][j-1]; else ne = null;
    if (n&&w) nw = board[i-1][j-1]; else nw = null;
    if (s&&e) se = board[i+1][j+1]; else se = null;
    if (s&&w) sw = board[i-1][j+1]; else sw = null;
    eval(((j-from.y != 1)?"s":"n")+((i-from.x != 1)?"e":"w")+"=0;");
    if ((sw==0) && (integ(ne)==1)) return false;
    if ((se==0) && (integ(nw)==1)) return false;
    if ((nw==0) && (se==1.1)) return false;
    if ((ne==0) && (sw==1.1)) return false;
    return true;
    message("You may begin! Select a piece to move.");
    my_turn = true;
    // -->
    </SCRIPT>

    Well, you can get a free tutorial to Java at http://www.mindview.net/. It's the "Thinking In Java" book. You can download the whole book from that site, it's about a thousand pages. If you read that whole book, you'll know exactly where to start and probably how to finish it too.
    As a gimmie, think about it -- you'll have to remove all of the browser-detect code, since browser-detection is only done to determine which version of JavaScript is supported by the browser.

  • Convert VBA to AppleScript

    Can anyone help me convert the VBA script to AppleScript? I've tried time and time again to use curl w/o any success. Any guidance would be appreciated.
    Dim ldq As HTTPClass
    Set ldq = New HTTPClass
    'Set up the query fields for the POST form
    ldq.Fields("ldapserverid") = "prod"
    ldq.Fields("rootdn") = "ou=realWorker, o=company.com"
    ldq.Fields("check") = "C"
    ldq.Fields("someid") = ID
    ldq.Fields("condition1") = "and"
    ldq.Fields("condition2") = "and"
    'Open a connection to the server
    ldq.OpenHTTP ("search.company.com")
    'Send the POST request
    Debug.Print ldq.SendRequest("ldq/result.jsp", "POST")
    test = ldq.SendRequest("ldq/result.jsp", "POST")
    'Get the SOAP envelope
    soap = ldq.SendRequest("ldq/viewSOAP.jsp", "GET")
    'Clean up
    Set ldq = Nothing

    Hi
    Theirs a pretty in depth tutorial over at MACTECH, which I think will aid your in your code transition
    Moving from Microsoft Office VBA to AppleScript:
    MacTech's Guide to Making the Transition
    http://www.mactech.com/vba-transition-guide/index.html
    Budgie
    Message was edited by: Budgie
    Their is also the possibility you could use the "do Visual Basic" command, not to sure about thta though

  • Converting VBA to Applescript

    Before I changed to Mac, I ran this User Defined Function in Excel;
    Function Taxdue08(Salary)
    If Salary > 180000 Then
    Taxdue08 = (58000 + (Salary - 180000) * 0.45) + (Salary * 0.015)
    Else
    If Salary > 80000 Then
    Taxdue08 = (18000 + (Salary - 80000) * 0.4) + (Salary * 0.015)
    Else
    If Salary > 34000 Then
    Taxdue08 = (4200 + (Salary - 34000) * 0.3) + (Salary * 0.015)
    Else
    Taxdue08 = ((Salary - 6000) * 0.15) + (Salary * 0.015)
    End If
    End If
    End If
    End Function
    So when i clicked a cell and executed the function it would ask me for an amount (so i would click the cell containing the amount) and then it would display the answer... But now I'm using a mac and Excel 2008 so I'm told I have to use Applescript.. So I tried to convert the code to Applescript as follows:
    on Taxdue08(Salary)
    if Salary is greater than 180000 then
    set Salary to ((58000 + (Salary - 180000) * 0.45) + (Salary * 0.015))
    else if Salary is greater than 80000 then
    set Salary to ((18000 + (Salary - 80000) * 0.4) + (Salary * 0.015))
    else if Salary is greater than 34000 then
    set Salary to ((4200 + (Salary - 34000) * 0.3) + (Salary * 0.015))
    Else
    set Salary to (((Salary - 6000) * 0.15) + (Salary * 0.015))
    end if
    end Taxdue08
    but, not surprisingly I guess, nothing happens when I run the script in Excel 2008... Can anyone help me out here?
    Cheers
    Ray

    Thanks Pierre... As you can tell, I'm a real noobie... I guess what I don't understand is how to actually make it do something... In Windows Excel I would execute the user defined function in a cell and it would ask me for an amount, then I would click on a cell that had an amount in it and the function would use that amount to do the math and display the result in the cell where i executed the function...
    But with the applescript, if i click on a cell and then run the script, nothing happens... There must be some code I'm missing which asks for input from the user and then uses that input for the equation, in this case it would replace the variable 'Salary', then, following your code, the appropriate calculated result would be placed in the variable theTaxDue, which would then be displayed in the cell... Any ideas on what the missing code might be?
    Cheers,and I appreciate your help...
    Ray

  • CS4 do javascript from AppleScript

    Hi all,
    Consider this AppleScript snippet:
    tell application "Adobe Illustrator"
    do javascript myFile with arguments {"one", "two"}
    end tell
    The file "myFile" is executed OK, but how does myFile (a JavaScript script) get the arguments passed in from AppleScript? I don't see this documented anywhere.
    Thanks,
    Chuck

    Since nobody answered this:
    In your Javascript, you will find an arguments array containing the arguments you passed from Applescript or VBscript
    So, using your example, if you added this line to your JSX file:
    alert(arguments[0]);
    You would get an alert saying "one" when you ran your Applescript.

  • Can I translate Javascript to Applescript?

    I am rushing to get my taxes done and I need to calculate a cost basis for my mutual fund shares that I sold. I found a neat Javascript that will do the job but I don't know anything about Javascript. I have tried but to no avail. Can I change it to Applescript? If not, can someone help me get it going using Javascript? The site follows:
    http://javascript.internet.com/math-related/adjusted-cost-base.html

    There's no direct/automatic JavsScript to AppleScript conversion. It can be done by examining the code, but the JavaScript also manages the user interface (reading the values you enter on the form and resetting the output fields), which isn't trivial in AppleScript.
    However, I have to wonder why you think you need to do this?
    Doesn't that script work as-is? Can't you just enter the values on that page and get the answers you want? Sure, you can copy the code to your own page if you want to host if yourself, but there's nothing I can see that's preventing you using their form for your calculation.
    Given how much (little?) time you have before taxes need to be filed, I can't help but think that's a better approach.

Maybe you are looking for