Jump to content

Randomize


Recommended Posts

Hi everyone

I am new to Autoit and this is my first language

I wanted to randomize the filename that it will create

So it goes like this:

#Include<Array.au3>
$Filename=_Arraycreate("\Boot.ini","\system.ini","\windows config.ini","\config.ini")
$UBound=UBound($Filename,0)
$Random=Random(0,$UBound)

And the $Random is my filename, but it doesn't work, the name is always boot.ini, when I tried to display the $Random with a msg box, it shows 0.464646 or 0.4646 etc.

So I am wondering if you guys will help me get through this.

Thanks alot. :whistle:

Generator

Link to comment
Share on other sites

Thanks for the help :whistle:

But after I run it for few times, this error came up

==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$Random=$Filename[Random(0,$UBound,1)]

$Random=^ ERROR

At that line, any way I can fix this?

Thanks for helping

#Include<Array.au3>
$Filename=_Arraycreate("\Boot.ini","\system.ini","\windows config.ini","\config.ini")
$UBound=UBound($Filename)-1
$Random=$Filename[Random(0,$UBound,1)]
MsgBox(0, "", $Random)

Added -1, UBound always adds one

$arr[0] = "a"

$arr[1] = "b"

It would return a 2 because there are two values in there. But $arr[2] isn't there!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...