Modify code from random to sequence

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • G Love

    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_SpamSerie s() {
    var seed = _randomSeed();
    var qoute = _getQoute();
    for(var i=0; i<50; i++) {
    _commentCount++ ;
    //_postComment(qo ute + " :" + seed + " #" + (i
    +1));
    _postComment(_c ommentCount);
    }
    //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...2 8,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).
  • Thomas 'PointedEars' Lahn

    #2
    Re: Modify code from random to sequence

    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_SpamSerie s() {
    var seed = _randomSeed();
    var qoute = _getQoute();
    for(var i=0; i<50; i++) {
    _commentCount++ ;
    //_postComment(qo ute + " :" + seed + " #" + (i
    +1));
    _postComment(_c ommentCount);
    }
    //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, <f806at$ail$1$8 300dec7@news.de mon.co.uk>

    Comment

    Working...