Sign in to follow this  
Followers 0
Generator

Randomize

7 posts in this topic

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

Share this post


Link to post
Share on other sites



Maybe...

$UBound=UBound($Filename) -1

8)


NEWHeader1.png

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Sorry, Val. I wasn't paying attention.. I thought this was pretty self-explanatory.

This is for the dummies.

#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)

Share this post


Link to post
Share on other sites

Maybe...

$UBound=UBound($Filename) -1

8)

Thanks a lot it worked. :whistle:

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