Help - Search - Members - Calendar
Full Version: random number + delaytill (or something...)
AC Tools Everything Macro > AC Tool > AC Tool Discussion
Xaith
i need to make a random number from 1 to say... 10.
how is it done?

also, there's a delayuntill (or something among the lines) function.
is it possible to make something like
CODE

constants
warning = 0
random_number = 0
end

showmessage $warning = warning, OK, click ok when ready
delayuntill ok is clicked //or something like that...
makerandomnumber $random_number = 1 => $random_number =< 10 //not the actual command... is it? (side note: => and =< are actually from C++.)
end




side note: the question would be easier to explain if i knew what's the code going to be, but i don't, it's 3 am and i'm too tired to think of a
logical peice of code for the question.
i don't even think half of that is actool worthy >.>;;
Bear
QUOTE(Xaith @ Aug 9 2007, 08:24 PM) *
i need to make a random number from 1 to say... 10.
how is it done?


CODE
Constants
  x=
End

Loop 20
  Compute X = Ceil( Random(0) * 10 )
  Timestamp X ( $X )
End



Run that then look at your Test Log tab.
Compex
QUOTE(Bear @ Aug 9 2007, 09:05 PM) *
QUOTE(Xaith @ Aug 9 2007, 08:24 PM) *
i need to make a random number from 1 to say... 10.
how is it done?


CODE
Constants
  x=
End

Loop 20
  Compute X = Ceil( Random(0) * 10 )
  Timestamp X ( $X )
End



Run that then look at your Test Log tab.


Thanks, I also had this problem and you solved it. But now say you want that same randomly generated number ($X) to be keyed in later in the macro. How would u do this without generating another random number when using the $X command?
Ahk
You'll need to store the random number into a variable, list, or dataset...

SetConst RndNumber = $X

ListAdd lstRand, $X

DSAppend DSRand
SetConst DSRand[Rand] = $X
DSPost DSRand

Note that if you use a variable like the first piece of code, it will only be able to store one number, so if you generate again and store that new value into RndNumber it will be a different random number.

The list or dataset would be capable of storing multiple values and then you could read whichever one you wanted to be typed at a later time.

The ShowMessage command should already practically 'pause' the macro until OK is pressed so you won't need a delay.
Compex
Nice, thx. laugh.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.