wit4r7
wit4r7

Reputation: 135

Print result from two functions to console

I've created a small script to get the current size and position of a window. Unfortunately, I only can get one result at a time and need to comment/uncomment the other one.

tell application "System Events" to tell process "Toggl Track"
    # get position of window 1
    get size of window 1
end tell

If I uncomment both, I will only get the size.

So, my I tried to write the results in a variable and then log these instead.

tell application "System Events" to tell process "Toggl Track"
    set position to get position of window 1
    set size to get size of window 1
    log position & size
end tell

With this, I get no result at all.

What did I do wrong?

Upvotes: 0

Views: 57

Answers (1)

vadian
vadian

Reputation: 285150

position and size are part of the terminology of System Events. You cannot use them as variable names. Rename the variables

tell application "System Events" to tell process "Toggl Track"
    set windowPosition to position of window 1
    set windowSize to size of window 1
    log windowPosition & windowSize
end tell 

Regarding the first script, get saves the result of the line in the AppleScript property result and overwrites previous values.

Upvotes: 1

Related Questions