Sign in to follow this  
Followers 0
hlstriker

Random Variable?

7 posts in this topic

Is it possible to have a few variables, then have the send command use 1 of the variables?

Example:

I want a variable that contains different colors such as... red, purple, green, blue, and orange.

Then I would use the send command...

Send( "The random color is... " & $random )

Now is there any way I can get $random to display a random color when the send command is run?

Thanks in advance ;)!

Share this post


Link to post
Share on other sites



Heres how I would do it:

$random = Random(1, 5, 1)
If $random = 1 Then
   Send("blue")
ElseIf $random = 2 Then
   Send("red")
ElseIf $random = 3 Then
   Send("orange")
ElseIf $random = 4 Then
   Send("yellow")
Else
   Send("green")
EndIf

FootbaG

Share this post


Link to post
Share on other sites

This might work a little better for you ;)

Dim $aColors[4] = ['blue', 'red', 'green', 'yellow']
$index = Random(0, UBound($aColors) - 1, 1)
MsgBox(0, $index, $aColors[$index])

Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

Ok Mr. SmartyPants! Haha, only messin' ;)

I knew there was a better way.


FootbaG

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

:P

I've been working with php lately (reworking a school site from pure html to simple php stuff), so I've had to work with easy modifications to the site (god bless csv files :mad2:). I guess it gets you thinking of how not to use if...then statements for every option ;)

Edited by MSLx Fanboy

Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0