tap.applescript setting global

Oct 12, 2009 at 10:52am

tap.applescript setting global

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

#45828
Oct 12, 2009 at 1:19pm
div wrote on Mon, 12 October 2009 12:52
Can 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

#165220
Oct 13, 2009 at 5:50am
div wrote on Mon, 12 Oct 2009 12:52
Can 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:
AppleScript
MAX and Applescript
applescript pro needed
etc.

#165221
Oct 13, 2009 at 5:02pm

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

#165222
Oct 14, 2009 at 12:30am
div wrote on Tue, 13 October 2009 19:02
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?

Hi Tim,

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

Philippe

#165223

You must be logged in to reply to this topic.