Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    5
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Angry Just not reliable -- ideas?

    Wrote a little bit to give me 18 rands in a scratch.dat file and most of the time it does. It
    does run into the hourglass from time to time and stop short at say 12 rands in scratch.dat.
    Any ideas?

    Code:
    $seen = 0;
        $reps = 1;
        while ($reps < 19)
        {
        $random_number = int(rand(336)) +1;
        if (-e "scratch.dat")
                {
            open (SCR, "scratch.dat") || &CgiDie ("SCRATCH could not be opened while attempting read");
            @scra =<SCR>;
            close (SCR);
                foreach $mine (@scra)
                    {
                chomp($mine);
                ($junk, $num_to_check) = split (/\|/, $mine);
                if ($num_to_check == $random_number)
                        {
                        $seen = 1;
                        }
                    }#end of foreach line
                }#end of if scratch data exists
                if ($seen == 0)
                    {
                    open (SCR, ">>scratch.dat") || &CgiDie ("SCRATCH could not be opened while attempting write");
                    seek(SCR, 0, SEEK_END);
                    print SCR "junk\|$random_number\n";
                    close(SCR);
                    $seen = 0;
                    $reps++;
                    }
            }# End of lets do 18 reps...
        #unlink ("scratch.dat");
        &printout;
        }
    else
        {
        &signin;
            }[/EMAIL]

  • #2
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    5
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Lightbulb

    It struck me, would I have overlooked seen was set to zero before while and once it was
    set to 1, it was not reset?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •