tap.applescript setting global

div's icon

Hi I am using tap.applescript to control the apple chess application. I have a simple problem i think.

when i set the global in my script using

script set mv1 to "white pawn, e2"

nothing happens anymore, something is happening inside the applescript object?

It seems quite a simple thing no?

Can i run such a script with the shell object?

global k
global mv1
global mv2

set mv1 to "white pawn, e2"
set mv2 to "e4"

set k to 0

tell application "Chess" to activate
tell application "System Events" to tell process "Chess"
    keystroke "l" using {command down}
    keystroke "n" using {command down}
    click button "Start" of sheet 1 of window 1
    set theNameOfLogW to name of window 1
    set theNameofGameW to name of window 2
    click last menu item of menu 1 of menu bar item 5 of menu bar 1
    delay 1
    click button mv1 of group 1 of window 1
    click button mv2 of group 1 of window 1
end tell

on whiteMove(a, b)
    tell application "System Events" to tell process "Chess"
        tell group 1 of window 1
            set k to k + 1
            click button a
            click button b
        end tell
        tell table 1 of scroll area 1 of window 2
            repeat until row k exists
            end repeat
            repeat while value of text field 3 of row k is ""
            end repeat
            (*return value of text field 3 of row k*)
        end tell
    end tell
end whiteMove

pdelges's icon

div wrote on Mon, 12 October 2009 12:52Can i run such a script with the shell object?

You can use osascript.
Type man osascript in a Terminal to learn how to use this command.

p

PhiDjee's icon

div wrote on Mon, 12 Oct 2009 12:52Can i run such a script with the shell object?

If the shell object still works for you then: yes!

Quote:on whiteMove(a, b)
end whiteMove

For this, prefer 'load' or 'run' an external script.

Some older topics about AppleScript:AppleScriptMAX and Applescriptapplescript pro needed
etc.

div's icon

Great, the shell works on my machine!

Is there any reason why it shouldn't? It is obsolete? any other object i could use to do such things?

Best,

Tim

PhiDjee's icon

div wrote on Tue, 13 October 2009 19:02Great, the shell works on my machine!
Is there any reason why it shouldn't? It is obsolete? any other object i could use to do such things?

Hi Tim,

shell is not obsolete and works fine for me too.
If you need it, that's the right choice!

Philippe