Random Number

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
samhale
Posts: 24
Joined: Sun Mar 30, 2008 9:28 pm

Random Number

Post by samhale » Fri Oct 10, 2008 4:15 pm

Is there a way I can make iopus generate a random number (1-99999999999999999999999999999999)
and then make it post it, so it would be like this:

TAG POS=1 TYPE=TEXTAREA FORM=NAME:NoFormName ATTR=ID:Message CONTENT=$randomnumber?

Cheers,
Sam
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Re: Random Number

Post by Tech Support » Fri Oct 10, 2008 9:58 pm

1. If you use the iMacros Scripting Edition please see this VBS script. It does exactly what you need :) And with iimInit ("-fx") can use Firefox instead of the iMacros Browser.

2. In iMacros for Firefox itself you can use basically the same approach with the Javascript interface.

To generate a random number in JavaScript, simply use the following code:

Code: Select all

var randomnumber=Math.floor(Math.random()*11)
where 11 dictates that the random number will fall between 0-10. To increase the range to, say, 100, simply change 11 to 101 instead.

Some of you may be curious as to why Math.floor(), instead of Math.round(), is used in the above code. While both successfully round off its containing parameter to an integer within the designated range, Math.floor does so more "evenly", so the resulting integer isn't lopsided towards either end of the number spectrum. In other words, a more random number is returned using Math.floor().
samhale
Posts: 24
Joined: Sun Mar 30, 2008 9:28 pm

Re: Random Number

Post by samhale » Sat Oct 11, 2008 9:11 am

Cheers,
but I don't understand how you enter this into an iim, and then post that number into a text box.

Thanks- Sam
dharmendra2000
Posts: 214
Joined: Fri Jul 04, 2008 1:28 pm
Location: Ahmedabad
Contact:

Re: Random Number

Post by dharmendra2000 » Sat Oct 11, 2008 9:21 am

var randomnumber=Math.floor(Math.random()*11)

This will generate random number and assign it to "randomnumber" variable

Now use below command......
iimSet("rnumber", randomnumber);
iimPlay("yourmacro.iim")

Now you can user "rnumber" where you want to use generated random number.

Cheers,
Dharmesh Uteshiya
http://www.dharmesh-uteshiya.co.nr
Gelfer
Posts: 6
Joined: Thu Nov 05, 2009 11:19 pm

Re: Random Number

Post by Gelfer » Thu Nov 05, 2009 11:50 pm

dharmendra2000 wrote:var randomnumber=Math.floor(Math.random()*11)

This will generate random number and assign it to "randomnumber" variable

Now use below command......
iimSet("rnumber", randomnumber);
iimPlay("yourmacro.iim")

Now you can user "rnumber" where you want to use generated random number.

Cheers,
Dharmesh Uteshiya
http://www.dharmesh-uteshiya.co.nr
This doesn't work for me.... I tried using a random code generator site but when I extract the data it adds a space at the end of the code but is there any way I can get rid of the space? I tried using the {BACKSPACE} function but that doesn't work

this is the site http://www.dave-reed.com/Nifty/randSeq.html
SorenC
Posts: 36
Joined: Wed Oct 28, 2009 4:33 pm

Re: Random Number

Post by SorenC » Sun Nov 08, 2009 1:25 pm

dharmendra2000 wrote:var randomnumber=Math.floor(Math.random()*11)

This will generate random number and assign it to "randomnumber" variable

Now use below command......
iimSet("rnumber", randomnumber);
iimPlay("yourmacro.iim")

Now you can user "rnumber" where you want to use generated random number.

Cheers,
Dharmesh Uteshiya
http://www.dharmesh-uteshiya.co.nr
Hey Dharmesh.

Would this work for the random wait time generator?. If so, how would i edit it, to work and put it into my macro for FF?.

Im trying to get the wait time, to be between 60secs and 400 secs. With a random number between that. :)
(NIKSU)
Posts: 4
Joined: Thu Feb 25, 2010 6:08 pm

Re: Random Number

Post by (NIKSU) » Sun Mar 07, 2010 1:11 pm

Dont works T_T omg...i need help again...
so i creat in FF imacros js file.
In .js file i have this .
var randomnumber=Math.floor(Math.random()*101)
iimSet("rnumber", randomnumber);
iimPlay("autoreg.iim")
So in autoreg.iim i set in reg.form in name
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:http://narutowars.ru/register.php?action=register ATTR=ID:fld1 CONTENT=rnumber
But he don't generate the randoms numberst between 101...
omg what i do wrong?
super_hiro
Posts: 15
Joined: Tue Feb 23, 2010 2:06 pm

Re: Random Number

Post by super_hiro » Tue Mar 09, 2010 1:06 am

Hi,

I'm a very beginner at this, but I also want to generate a random number.
In my script, I want to make it WAIT a random number of seconds.

What do I do for this to work on my .iim?

Do I create two .js script? One with

"var randomnumber=Math.floor(Math.random()*101)"

and another to actually run the iim?

"iimSet("rnumber", randomnumber);
iimPlay("autoreg.iim")"

If this is the case, what do I input in the .iim to load this script?

I want it to insert in "WAIT SECONDS="
Post Reply