Hi i was practicing with an array trying to generate a random fictitious name for a company like this
Which works and returns the name but occasionaly i get a result like this
Is there a way to prevent this negative number ?
What im trying to end up with is a randomly generated name for a file, obviously there will be larger lists of names in the final working model
[ autoit ]
#include <Array.au3> ; [ 0 1 2 3 4 ] [ 0 1 2 3 4 ] [ 0 1 2 3 4 ] Local $avArray[3][5] = [["Cloud", "Harvard", "Downtown", "Trent", "Compton"],["Transport Ltd", "Paper Ltd", "Construction", "Builders", "Tarmac Co"],["Invoice", "Statement", "Quote", "Bill", "Demand"]] ;~ _ArrayDisplay($avArray, "$avArray as a 2D array, transposed", -1, 1) $no = Round(Random(Default, 4),0) ConsoleWrite($no & @CRLF) $no1 = Round(Random(Default, 4),0) ConsoleWrite($no1 & @CRLF) $no2 = Round(Random(Default, 4),0) ConsoleWrite($no2 & @CRLF) ConsoleWrite( $avArray[0][$no] & " " & $avArray[1][$no1] & " " & $avArray[2][$no2] & @CRLF)
Which works and returns the name but occasionaly i get a result like this
[ autoit ]
2 2 -1 C:\Users\J\Desktop\_ArrayTest.au3 (14) : ==> Array variable subscript badly formatted.: ConsoleWrite( $avArray[0][$no] & " " & $avArray[1][$no1] & " " & $avArray[2][$no2] & @CRLF) ConsoleWrite( $avArray[0][$no] & " " & $avArray[1][$no1] & " " & $avArray[2][^ ERROR
Is there a way to prevent this negative number ?
What im trying to end up with is a randomly generated name for a file, obviously there will be larger lists of names in the final working model