Some AppleScript help over here

4 replies [Last post]
Offline
Joined: Nov 1 2004
Posts: 15

I am not AppleScript literate, so if someone could please help me with this little script I wrote for "ircle", the program I use for IRC

tell application "ircle 3.1 Am. English Carbon"
set ch to currenttarget
set n to numberofusers of ch
set counter to (???)
set u to nickname of user counter of ch
set obj to argstring
if obj = "" then
set obj to "a large trout"
end if
do "/me smacks " & u & " around a bit with " & obj
end tell

I want the script to choose a random user. "n" is the number of users in the selected channel. What do I need to set "counter" to if I want a random integer between 1 and "n"?

__________________

What?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Tiger G5 Kid's picture
Offline
Joined: Dec 20 2003
Posts: 134
thru

try:

set counter to (1 thru n)

__________________

(\ /)
(O.o)
(> <)
This is Bunny. Copy Bunny into your signature to help him on his way to world domination.

Offline
Joined: Nov 1 2004
Posts: 15
nope

It didn't work. Got the syntax error message "a thru:n can't go after this 1"

anyone else? Undecided

edit: proper syntax is
set counter to integers 1 thru n
but that's not what I want. I want counter to be ONE integer BETWEEN 1 and n

another edit:
I also tried
set counter to integer is less than n
returned the error "can't make integer into a number, date, or text

__________________

What?

Tiger G5 Kid's picture
Offline
Joined: Dec 20 2003
Posts: 134
bingo - scripting additions dictionary

set counter to (random number from 1 to n)

__________________

(\ /)
(O.o)
(> <)
This is Bunny. Copy Bunny into your signature to help him on his way to world domination.

Offline
Joined: Nov 1 2004
Posts: 15
bwahaha

Hell yes man, that totally worked Laughing out loud

Thanks a bunch. ^_^

__________________

What?