sinkfaze wrote:
...if you select 3 sets of five regular numbers plus 1 bonus, the output is like this...
I'm not trying to be a smartass, but...

That is because the function executed a Stringreplace, replacing all the linefeeds with commas.
The function receives the results from Random.org like this:
Quote:
20-31-43-44-47 / 1
3-9-14-34-43 / 10
4-5-23-40-45 / 17
And it formats it like this by replacing the linefeeds with commas.
Quote:
20-31-43-44-47 / 1,3-9-14-34-43 / 10,4-5-23-40-45 / 17
That first StringReplace in your version of the function does nothing to the data, simply because there are no commas in the data received from Random.org.
Try these three versions of the function:
This one returns the result as it is, without modification:
Code:
randomdotorg_lottery(tickets,num_main,highest_main,num_bonus="0",highest_bonus="0") {
_url:="http://www.random.org/quick-pick/?tickets=" tickets "&lottery=" num_main "x" highest_main "." num_bonus "x" highest_bonus "&format=plain"
httpQuery(_ret:="",_url), VarSetCapacity(_ret,-1)
return _ret
}
This one's copypasted from the library. This produces the format you described:
Code:
randomdotorg_lottery(tickets,num_main,highest_main,num_bonus="0",highest_bonus="0") {
_url:="http://www.random.org/quick-pick/?tickets=" tickets "&lottery=" num_main "x" highest_main "." num_bonus "x" highest_bonus "&format=plain"
httpQuery(_ret:="",_url), VarSetCapacity(_ret,-1)
IfNotInString, _ret, Error:
StringReplace, _ret, _ret, `n, `,, All ;This Stringreplace replaces the linefeeds from the original format with commas
return SubStr(_ret,0,1)="," ? SubStr(_ret,1,StrLen(_ret)-1) : _ret ;trimming the last comma
}
And this is your version of the function with the unnecessary StringReplace commented out.
It still works as expected, because there are no commas in the data received from Random.org:
Code:
randomdotorg_lottery(tickets,num_main,highest_main,num_bonus="0",highest_bonus="0") {
_url := "http://www.random.org/quick-pick/?tickets=" tickets "&lottery="
. num_main "x" highest_main "." num_bonus "x" highest_bonus "&format=plain"
httpQuery(_ret,_url), VarSetCapacity(_ret,-1)
If !InStr(_ret,"Error:") {
_ret := RegExReplace(RegExReplace(_ret,"\b\d\b","0$0"),"\D+/\D+","`t")
;StringReplace, _ret, _ret, `,, `n, All
StringReplace, _ret, _ret, -, %A_Space%, All
}
return _ret
}
This is the flow of how the third function processes the data:
Code:
Data received from Random.org
20-31-43-44-47 / 1
3-9-14-34-43 / 10
4-5-23-40-45 / 17
Your function
Step 1.
20-31-43-44-47 / 01
03-09-14-34-43 / 10
04-05-23-40-45 / 17
Step 2.
20-31-43-44-47 01
03-09-14-34-43 10
04-05-23-40-45 17
Step 3. (= Step 2.: This StringReplace does nothing)
20-31-43-44-47 01
03-09-14-34-43 10
04-05-23-40-45 17
Step 4.
20 31 43 44 47 01
03 09 14 34 43 10
04 05 23 40 45 17
Cheers
gahks