Random array sometimes parses nothing ? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
chango
Posts: 30
Joined: 27 May 2017, 12:10

Random array sometimes parses nothing ?

15 Mar 2018, 10:15

I have made and used some random output to text arrays with help from the forum. What I have found is that sometimes the array out puts nothing randomly the carries on and outputs the next array value fine.

I'm using this :

AtArray4 := ["1 ","2 ","3 ","4 "]
Random, Rand, % AtArray4.MiniIndex(), % AtArray4.MaxIndex()

It work fine but like I said it sometimes does not output anything.
So I have 5 arrays randomly outputting 1 - 5 on a loop 6 times.
this will happen

13435
114
2345
2112
34
12452

etc

I think the random output must be 0-5 thus having 6 possibility's for the output ? How do I set it to 1-5 please ?
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Random array sometimes parses nothing ?  Topic is solved

15 Mar 2018, 10:21

You have a typo in your code, should be:

Code: Select all

AtArray4.MinIndex()
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
chango
Posts: 30
Joined: 27 May 2017, 12:10

Re: Random array sometimes parses nothing ?

15 Mar 2018, 10:32

Odlanir wrote:You have a typo in your code, should be:

Code: Select all

AtArray4.MinIndex()
That did it .. so many thanks Odlanir :)
Marrow
Posts: 21
Joined: 02 Oct 2017, 06:31

Re: Random array sometimes parses nothing ?

15 Mar 2018, 10:38

That's crazy :wtf: I just copied your code to test it and it works with the typo:

Code: Select all

AtArray4 := ["1","2","3","4","5"]
Loop, 6 {
	Loop, 5 {
		Random, v%A_Index%, % AtArray4.MiniIndex(), % AtArray4.MaxIndex()
}
	x%A_Index% = %v1%%v2%%v3%%v4%%v5%
}
msgbox %x1%`n%x2%`n%x3%`n%x4%`n%x5%`n%x6%
ExitApp
Returns:
54551
53230
33423
51554
25302
00115

/edit: Ah I got your question wrong, thought you have too short strings
chango
Posts: 30
Joined: 27 May 2017, 12:10

Re: Random array sometimes parses nothing ?

15 Mar 2018, 10:45

Marrow wrote:That's crazy :wtf: I just copied your code to test it and it works with the typo:

Code: Select all

AtArray4 := ["1","2","3","4","5"]
Loop, 6 {
	Loop, 5 {
		Random, v%A_Index%, % AtArray4.MiniIndex(), % AtArray4.MaxIndex()
}
	x%A_Index% = %v1%%v2%%v3%%v4%%v5%
}
msgbox %x1%`n%x2%`n%x3%`n%x4%`n%x5%`n%x6%
ExitApp
Returns:
54551
53230
33423
51554
25302
00115

/edit: Ah I got your question wrong, thought you have too short strings
LOL typo's are the fecking bane of my programming life lol :) the type correction did the trick though :)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], macromint, peter_ahk and 335 guests