random messages

Discussion in 'Mac Programming' started by Keytachi, Sep 26, 2006.

  1. macrumors regular

    Joined:
    Sep 14, 2006
    #1
    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
     
  2. Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #2
    You could always look at the source code to that standard unix "fortune" command. http://en.wikipedia.org/wiki/Fortune_(program) for inspiration.

    B
     
  3. macrumors 65816

    Unorthodox

    Joined:
    Mar 3, 2006
    Location:
    Not at the beach...
    #3
    This AppleScript will do it.
    The only changes you need to make to this script is to modify the top two variables.

     
  4. macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #4
    Good but,
    Code:
    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.
     
  5. macrumors 65816

    Unorthodox

    Joined:
    Mar 3, 2006
    Location:
    Not at the beach...
    #5
    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?
    *sniff*
     

Share This Page