PDA

View Full Version : random messages




Keytachi
Sep 26, 2006, 02:16 PM
how do i use the random command? i want the computer to say randomly some phrases how do i do that?

btw the "make your computer greet you" v.2.0 is almost out :D



balamw
Sep 26, 2006, 02:30 PM
how do i use the random command? i want the computer to say randomly some phrases how do i do that?
You could always look at the source code to that standard unix "fortune" command. http://en.wikipedia.org/wiki/Fortune_%28program%29 for inspiration.

B

Unorthodox
Sep 26, 2006, 03:54 PM
This AppleScript will do it.
The only changes you need to make to this script is to modify the top two variables.

set amount_of_greetings to 5 -- set this to the amount of items in the variable below
set message_list to {"Hello", "Hi", "Waz up", "Howdy", "Long time no see"} -- add or modify the text in quotes

set message_number to random number from 1 to amount_of_greetings
set the_greeting to item message_number of message_list
display dialog return & the_greeting & "!" buttons {"OK"} default button 1 with icon 2

Eraserhead
Sep 26, 2006, 05:19 PM
This AppleScript will do it.
The only changes you need to make to this script is to modify the top two variables.
Good but,

set message_list to {"Hello", "Hi", "Waz up", "Howdy", "Long time no see"} -- add or modify the text in quotes
set amount_of_greetings to the count of message_list

set message_number to random number from 1 to amount_of_greetings
set the_greeting to item message_number of message_list
display dialog return & the_greeting & "!" buttons {"OK"} default button 1 with icon 2 is better, as the computer counts the list automatically.

Unorthodox
Sep 26, 2006, 05:30 PM
Good but,
>snip< is better, as the computer counts the list automatically.
Ahh.
Yes.
Well, I didn't really devote that much time thinking about how to make it more user friendly.

WAAAA IM SUCH A NOOB!!!!
*sobs uncontrollably*

Since you're such a pro....
Maybe you can answer this (http://forums.macrumors.com/showthread.php?t=237662)?
*sniff*