473,385 Members | 1,661 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,385 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 1392
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());...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.