Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Random Numbers

Quote Reply
Random Numbers
It seems the search-function is disabled this morning :-(
I have found a thread about random numbers in cgi-generated pages, but nothing about random in build-pages.
For embedding banners i need both from 0 to 99 for my sql.
Have someone a clue about?
Quote Reply
Re: Random Numbers In reply to
Have searched for random and banner, but have found only the thread about random numbers in cgi-generated pages, nothing about for build pages.

Quote Reply
Re: Random Numbers In reply to
Check the FAQ ... I believe all the threads on that have been indexed there.

------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/








Quote Reply
Re: Random Numbers In reply to
I know it works, because I'm using it.

I think if you do a search in nph_build.cgi for "random" you'll find the places in the code where the numbers are passed or generated.

You'll see a block of code like:

Code:
$OUT{random} = rand (10000);
$OUT{random1} = rand (10000);
$OUT{random2} = rand (10000);
$OUT{random3} = rand (10000);

What that does, is make those three variables available. It assigns them a value that can be reused.

You can also do something like:

Code:
my $banner_random2 = \sub { return int rand (64000); };

What that does is provide a reference to the subroutine, and thus every time you use $banner_random2 you'll get a _different_ number.

This is not good for where you want the same number to be used for both the IMG and A links, which is why you would make the assignment to $random1 which can then be re-used. Each time the subroutine is called, $random1 is reiniitalized, but it maintains the same value for _each_ page.

Help?
Quote Reply
Re: Random Numbers In reply to
Thank you so far; i will try this next days (too many termins outside till then).
Hope i understood it right; i will exactly need the code 3 times; cause the code for the bannerexchange needs 3 different codes but with always the same random-number between 0 and 99.
Quote Reply
Re: Random Numbers In reply to
You'd just need $random1, $random2, and $random3 -- once assigned, they retain their unique random value until reassigned, so within a page you'd be able to have 3 separate banner ads with three separate codes.

Quote Reply
Re: Random Numbers In reply to
That's a good mod! But it's a big one. It would need to be an external newsletter program. You'd have to set user preferences, and maybe have to keep a "preferences" table. Then you'd have to read the values for the user with each automated action.

It's something to think about after the next release. A lot of neat things seem to be planned, and they will help make this sort of upgrade much easier.

Quote Reply
Re: Random Numbers In reply to
My bad english! Thank you again. I ll try it as you write. I ment a+ Rand1, b+ Rand 1, C+ Rand 1; it is ok, so far. i will post at weekend.

But just another thing you may have a helping hand for me:

We imagine a links has 2000 Cats; no user wants to get with the mailing ALL new entrees.

So i m thinking about a solution, how to make for every user an automate generated list to choose for which cats he wants to know the new entrees.
(We plan a new links sql, not for URLs, but for text-entrees and the user always wants to know the new entrees for only a few themes)