473,394 Members | 1,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Modify code from random to sequence

Hi, I am trying to modify some code in a toolbar I have for generating
random 'spam' entries on my forum.

I have managed to extract all the relevant files from the firefox .xpi
file and the .jar file, the code of interest initially looks like so
(this was written by someone else and I suspect it was partially taken
from another source prior to that too so I'm unsure if the following
code is all necessary);

function Tools_SpamSeries() {
var seed = _randomSeed();
var qoute = _getQoute();
for(var i=0; i<50; i++) {
_commentCount++;
//_postComment(qoute + " :" + seed + " #" + (i
+1));
_postComment(_commentCount);
}
//alert("Spamming Complete");

As you can tell it currently uses numbers up to 50 but I never
actually get 50 output 'comments', it seems to generate the numbers
then output them randomly and leave a few out.

Ideally I would prefer to have it start at '1' and work its way
sequentially up to '50' - 1,2,3,4,5...48,49,50 - END. (Total 50
comments)

But at present the numbers are all jumbled.

7,12,8,9,16...28,33,35 - END (Total 35 comments for example)

Eventually I would replace the numbers with comments perhaps but I
want to understand the workings of this first (looks quite
straightforward but not enough for me to figure out or find the syntax
required in place of the existing code).
Nov 15 '08 #1
1 1394
G Love wrote:
Hi, I am trying to modify some code in a toolbar I have for generating
random 'spam' entries on my forum.
[...]
function Tools_SpamSeries() {
var seed = _randomSeed();
var qoute = _getQoute();
for(var i=0; i<50; i++) {
_commentCount++;
//_postComment(qoute + " :" + seed + " #" + (i
+1));
_postComment(_commentCount);
}
//alert("Spamming Complete");

As you can tell it currently uses numbers up to 50 but I never
actually get 50 output 'comments', it seems to generate the numbers
then output them randomly and leave a few out.
You do not seem to have initialized _commentCount to begin with, so the
result of _commentCount++ is unknown (may be NaN). The rest of the relevant
code you have either commented out or omitted, so there is no telling what
happens.

That said, if the first _postComment() call was not commented out, then
there might as well be the source of your problem as you use the value of
see, which might be a random number, in the argument. Then again, there is
no telling what _randomSeed() returns as that, too, is not a built-in.

BTW, shouldn't it be "quote" instead?
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Nov 15 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Michael Strorm | last post by:
Hi! I posted a message a while back asking for project suggestions, and decided to go with the idea of creating an adventure game (although it was never intended to be a 'proper' game, rather an...
23
by: Thomas Mlynarczyk | last post by:
I remember there is a programming language where you can initialize the random number generator, so that it can - if you want - give you the exactly same sequence of random numbers every time you...
1
by: steflhermitte | last post by:
Dear cpp-ians, I want to apply a stratified sampling on an image. Following simplified example will explain my problem. The original image I with nrows and ncols is now a vector V of length...
11
by: Lues | last post by:
Hi, I'm trying to protect some data in tables with encription (you know why, don't you ;)) I must confess that I'm not very expirienced in writing code, especially encription code. Can any...
10
by: Johannes Veerkamp | last post by:
hi there, i'm a newbie in c and i'd like to write a programm which generates random numbers from 1 to 10 (integers). can anybody help me out with the correct code? thanx
9
by: Karlo Lozovina | last post by:
Here is it: --- class Human: def __init__(self, eye_one, eye_two): self.eye_one = eye_one self.eye_two = eye_two class Population: def __init__(self):
104
by: fieldfallow | last post by:
Hello all, Is there a function in the standard C library which returns a prime number which is also pseudo-random? Assuming there isn't, as it appears from the docs that I have, is there a...
24
by: pereges | last post by:
I need to generate two uniform random numbers between 0 and 1 in C ? How to do it ? I looked into rand function where you need to #define RAND_MAX as 1 but will this rand function give me ...
26
by: bilgekhan | last post by:
What is the correct method for generating 2 independent random numbers? They will be compared whether they are equal. What about this method: srand(time(0)); int r1 = rand(); srand(rand());...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.