Generator Posted March 27, 2007 Posted March 27, 2007 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. Generator
xcal Posted March 27, 2007 Posted March 27, 2007 Whoa... you waited a whole 9 minutes?! I can't believe people weren't all over this... How To Ask Questions The Smart Way
jvanegmond Posted March 27, 2007 Posted March 27, 2007 #Include<Array.au3> $Filename=_Arraycreate("\Boot.ini","\system.ini","\windows config.ini","\config.ini") $UBound=UBound($Filename) $Random=$Filename[Random(0,$UBound,1)] MsgBox(0, "", $Random) github.com/jvanegmond
McGod Posted March 27, 2007 Posted March 27, 2007 Thanks for the help 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! [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u]
jvanegmond Posted March 27, 2007 Posted March 27, 2007 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) github.com/jvanegmond
Generator Posted March 27, 2007 Author Posted March 27, 2007 Maybe... $UBound=UBound($Filename) -1 8)Thanks a lot it worked.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now