I can't get my head round how to best do something...
Let's say have these functions abc1(), abc2(), abc3()
I want to call one of these functions by random.
So I want to run abcx()
Where x is replaced by a randomly generated number
How can I do this?
Thanks
How to a call a function with a number at the end
Re: How to a call a function with a number at the end
Code: Select all
abc%therandomlygeneratednumber%()
Re: How to a call a function with a number at the end
Like this
Is it really necessary to have the 3 functions? are you sure that you can't just set up a test in one function? i.e
Code: Select all
#SingleInstance,Force
Numpad1::
Random,x,1,3
abc%x%()
return
abc1(){
msgbox, in abc1
}
abc2(){
msgbox, in abc2
}
abc3(){
msgbox, in abc3
}
*ESC::ExitApp
Code: Select all
abc(x){
if(x=1){
do this
}else if(x=2){
do this
}else {
something else
}
}
Re: How to a call a function with a number at the end
Thanks guys
Perfect
Yes! I need to run code like this
I'm just playing around with something
Perfect
Yes! I need to run code like this
I'm just playing around with something
Re: How to a call a function with a number at the end
For consistency with Hellbent's 1st example, it might be better to show the 2nd example in a way similar to the first one.Hellbent wrote: ↑15 Jun 2019, 20:56Is it really necessary to have the 3 functions? are you sure that you can't just set up a test in one function? i.e
Code: Select all
abc(x){ if(x=1){ do this }else if(x=2){ do this }else { something else } }
Code: Select all
#SingleInstance,Force
^s::
Loop
{
Random,x,1,3
abc(x)
}
return
abc(x)
{
if(x=1)
{
msgbox, in abc1
}
else if(x=2)
{
msgbox, in abc2
}
else
{
msgbox, in abc3
}
}
*ESC::ExitApp
Who is online
Users browsing this forum: No registered users and 248 guests