Re: Balancing randomness

This WebDNA talk-list message is from

2000


It keeps the original formatting.
numero = 27947
interpreted = N
texte = I think you can do this much easier as I explained in my response last week to the randomness (or lack thereof) of sdir=ra. You can accomplish this with just one additional field and only one additional line of WebDNA and if you are already replacing the records taht you are selecting from the database then it only requires a slight change to your webDNA.In whatever records you are trying to select randomly, add another field. I think I called mine RandomWeight. Let's abbreviate it to [rw] Set this field to some constant value in every record.Then when you want a record from the database, do this:[search db=data.db&eqSKUdata=find_all&RWsort=1&max=1]This will get you the record with the lowest value in [rw] which the first time through this code is just some random record, because all the records have the same value in rw.Then, later in your code, when you're done with this record, include the following:[replace db=data.db&eqSKUdata=[SKU]]RW=[math][rw]+1[/math][/replace]This bumps the value of [RW] by one in this record only. Then the next time you go through the search, you would get some record _except_ the one you just got. Subsequent passes through the database keep returning records with the lowest value of [rw] and incrementing the value of [rw] in each selected record so that the pool of records with the lowest [rw] value keeps decreasing and all records are selected once and only once before being selected again.Does this make sense? Hopefully it does because it works.___Joe____________________________________________________ Joseph D'Andrea JoeDan@West21.com WEST21.com Internet services for the 21st Century http://www.west21.com/ _________________________________________________ ------------------------------------------------------------- Brought to you by CommuniGate Pro - The Buzz Word Compliant Messaging Server. To end your Mail problems go to .This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Associated Messages, from the most recent to the oldest:

    
  1. Re: Balancing randomness (Rob Marquardt 2000)
  2. Re: Balancing randomness (Peter Ostry 2000)
  3. Re: SOLUTION.... Re: Balancing randomness (Rob Marquardt 2000)
  4. Re: Balancing randomness (Christer Olsson 2000)
  5. Re: SOLUTION.... Re: Balancing randomness (Kenneth Grome 2000)
  6. Re: SOLUTION.... Re: Balancing randomness (Rob Marquardt 2000)
  7. SOLUTION.... Re: Balancing randomness (Joseph D'Andrea 2000)
  8. Re[2]: Balancing randomness (Kenneth Grome 2000)
  9. Re: Balancing randomness (Joseph D'Andrea 2000)
  10. Re: Balancing randomness (John Butler 2000)
  11. Re[2]: Balancing randomness (Joseph D'Andrea 2000)
  12. Re: Balancing randomness (Miguel Castaneda 2000)
  13. Re: Balancing randomness (Rob Marquardt 2000)
  14. Re: Balancing randomness (Joseph D'Andrea 2000)
  15. Re[2]: Balancing randomness (jpeacock@univpress.com 2000)
  16. Re[2]: Balancing randomness (jpeacock@univpress.com 2000)
  17. Re: Balancing randomness (Peter Ostry 2000)
  18. Re: Balancing randomness (Rob Marquardt 2000)
  19. Re: Balancing randomness (Joseph D'Andrea 2000)
  20. Re: Balancing randomness (jpeacock@univpress.com 2000)
  21. Balancing randomness (Rob Marquardt 2000)
I think you can do this much easier as I explained in my response last week to the randomness (or lack thereof) of sdir=ra. You can accomplish this with just one additional field and only one additional line of WebDNA and if you are already replacing the records taht you are selecting from the database then it only requires a slight change to your webDNA.In whatever records you are trying to select randomly, add another field. I think I called mine RandomWeight. Let's abbreviate it to [rw] Set this field to some constant value in every record.Then when you want a record from the database, do this:[search db=data.db&eqSKUdata=find_all&RWsort=1&max=1]This will get you the record with the lowest value in [rw] which the first time through this code is just some random record, because all the records have the same value in rw.Then, later in your code, when you're done with this record, include the following:[replace db=data.db&eqSKUdata=[SKU]]RW=[math][rw]+1[/math][/replace]This bumps the value of [RW] by one in this record only. Then the next time you go through the search, you would get some record _except_ the one you just got. Subsequent passes through the database keep returning records with the lowest value of [rw] and incrementing the value of [rw] in each selected record so that the pool of records with the lowest [rw] value keeps decreasing and all records are selected once and only once before being selected again.Does this make sense? Hopefully it does because it works.___Joe____________________________________________________ Joseph D'Andrea JoeDan@West21.com WEST21.com Internet services for the 21st Century http://www.west21.com/ _________________________________________________ ------------------------------------------------------------- Brought to you by CommuniGate Pro - The Buzz Word Compliant Messaging Server. To end your Mail problems go to .This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Joseph D'Andrea

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

Exclamation point (1997) Pithy questions on webcommerce & siteedit (1997) Add to Cart & List of Products (1997) Country & Ship-to address & other fields ? (1997) Automated FTP from Shell (2004) Date search - yes or no (1997) Web Catalog vs. ICAT (1997) Running _every_ page through WebCat-error.html (1997) Help! WebCat2 bug (1997) WebCat2: Items xx to xx shown, etc. (1997) WCS Newbie question (1997) writefile - continued (1997) RE: [WebDNA] WebDNA Showcase? (2008) Couple of questions (1999) Encrypt (1999) WebCat hosting providers? (1997) For those of you not on the WebCatalog Beta... (1997) Problem 2: Prefs file... (1997) Grepping text variable tags (was: No subject given) (2000) redirect from the errorsMessages.db entry (1997)