I am trying to count all the buddies that are online in iChat. Can someone please tell me what is wrong with:
tell application "iChat"
set onlinecount to 0
set nameList to (name of account of service 1)
repeat with currentNumber from 2 to length of nameList
if status of account currentNumber is available then
onlinecount = onlinecount + 1
end if
end repeat
return onlinecount
end tell
set q to 0
set w to 0
set e to 0
set r to 0
tell application "iChat"
set a to count every account
set a to a as integer
set a to a - 1
repeat with x from 1 to a
set b to status of account x as text
if b = "available" or b = "«constant ****aval»" then
set q to q + 1
else if b = "away" or b = "«constant ****away»" then
set w to w + 1
else if b = "idle" or b = "«constant ****idle»" then
set e to e + 1
else if b = "offline" or b = "«constant ****offl»" then
set r to r + 1
end if
end repeat
display dialog "You have got " & a & " Buddies." & return & return & ¬
"Available: " & q & return & ¬
"Idle: " & e & return & ¬
"Away: " & w & return & ¬
"Offline: " & r ¬
as text buttons "OK" default button 1 with icon 1
end tell
The problem in your script is the line onlinecount = onlinecount + 1, which you probably intended to write as set onlinecount to onlinecount + 1 (as it is, I’m guessing that AS sees the line as the statement 0 = 1, and evaluates it as false, which is why it doesn’t throw an error).