Jump to content

Recommended Posts

Posted (edited)

hi!

i made a script where the user can put some text into input boxes.

after clicking apply those texts will be displayed in the chat line, everything works fine.

now i decided that the messages (10) should be displayed randomized, meaning in a random order

so i tried it out, now the code is:

$randommessage = Random(1, 10)
                    Select
                        Case $randommessage = 1
                            Send($msg1)
                            Send ("{ENTER}")
                            Sleep ($interval)
                        Case $randommessage = 2
                            Send($msg2)
                            Send ("{ENTER}")
                            Sleep ($interval)
                        Case $randommessage = 3
                            Send($msg3)
                            Send ("{ENTER}")
                            Sleep ($interval)
                        Case $randommessage = 4
                            Send($msg4)
                            Send ("{ENTER}")
                            Sleep ($interval)
                        Case $randommessage = 5
                            Send($msg5)
                            Send ("{ENTER}")
                            Sleep ($interval)
                        Case $randommessage = 6
                            Send($msg6)
                            Send ("{ENTER}")
                            Sleep ($interval)
                        Case $randommessage = 7
                            Send($msg7)
                            Send ("{ENTER}")
                            Sleep ($interval)
                        Case $randommessage = 8
                            Send($msg8)
                            Send ("{ENTER}")
                            Sleep ($interval)
                        Case $randommessage = 9
                            Send($msg9)
                            Send ("{ENTER}")
                            Sleep ($interval)
                        Case $randommessage = 10
                            Send($msg10)
                            Send ("{ENTER}")
                            Sleep ($interval)
                    EndSelect

the problem: no error, but nothing is displayed....

what am i doing wrong?

any help is highly appreciated

regards,

t0pcraft

Edited by t0pcraft
Posted

Hi!

You should really learn how to use arrays, it will simplify these things a lot!

Dim $messages[5]=["Hello","Good bye","Good morning","Good night","Good afternoon"]

_RandomizeArray($messages)


For $i=0 To Ubound($messages)-1
    Send($messages[$i])
    Send("{ENTER}")
    Sleep(50)
Next
    


Func _RandomizeArray(ByRef $array)
    For $i=0 To Ubound($array)*2
        $rand1=Random(0,Ubound($array)-1,1)
        $rand2=Random(0,Ubound($array)-1,1)
        
        $temp=$array[$rand1]
        $array[$rand1]=$array[$rand2]
        $array[$rand2]=$temp
    Next
EndFunc

:P

Broken link? PM me and I'll send you the file!

Posted

you are not using whole numbers, try this:

int(Random(1, 10))
How about just using the integer flag in the function?
Random(1, 10, 1)
What makes that funny is I know you've been around long enough to know that, Dan!

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted (edited)

thanks for your answers!

i'm trying it out now

edit:

yeah it works!! thanks alot you all

@monoceres

ye arrays are a good solution!

i think i will do that, but not now :P

Edited by t0pcraft

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...