Re: [REPLACE] inside [FOUNDITEMS]

This WebDNA talk-list message is from

1998


It keeps the original formatting.
numero = 19178
interpreted = N
texte = >2.1.6 through 3.0b4, MAC PI > >I discovered something today and I'm not sure if it's a bug or a feature: > >Let's say I have a record with SKU=666 and INV=30, > >[SEARCH db=my.db&eqSKUdatarq=666] >[FOUNDITEMS] >[INV]

>[REPLACE db=my.db&eqSKUdatarq=666]INV=100[/REPLACE] >[INV] >[/FOUNDITEMS] >[/SEARCH] > >returns: >30 >100 > >I expected: >30 >30 > >I never expected that the [REPLACE] would change my [FOUNDITEMS] results. >I thought it would replace the value in the database but leave the returned >values of my [SEARCH] untouched. This could (and has) caused quite a few >logic errors in some scripts. > >Has this been going on for long? Yes! This problem has *always* been there.It is unfortunately still NOT documented, but it is nevertheless a very BAD practice to use delete or replace contexts inside founditems loops. The reason has to do with the way the founditems loop works. It uses the [index] value of the found items in a way that causes it to fail when *any* of the index values change during the looping process. So, since replace and delete are the two actions that can change the relative index values of the items inside the loop, you should NEVER use delete or replace inside a founditems context.Sincerely, Ken Grome 808-737-6499 WebDNA Solutions mailto:ken@webdna.net http://www.webdna.net Associated Messages, from the most recent to the oldest:

    
  1. Re: [REPLACE] inside [FOUNDITEMS] (Kenneth Grome 1998)
  2. Re: [REPLACE] inside [FOUNDITEMS] (Peter Ostry 1998)
  3. Re: [REPLACE] inside [FOUNDITEMS] (Michael Winston 1998)
  4. Re: [REPLACE] inside [FOUNDITEMS] (Kenneth Grome 1998)
  5. Re: [REPLACE] inside [FOUNDITEMS] (Bob Minor 1998)
  6. Re: [REPLACE] inside [FOUNDITEMS] (PCS Technical Support 1998)
  7. Re: [REPLACE] inside [FOUNDITEMS] (Michael Winston 1998)
  8. Re: [REPLACE] inside [FOUNDITEMS] (PCS Technical Support 1998)
  9. Re: [REPLACE] inside [FOUNDITEMS] (Dave MacLeay 1998)
  10. Re: [REPLACE] inside [FOUNDITEMS] (PCS Technical Support 1998)
  11. Re: [REPLACE] inside [FOUNDITEMS] (Kenneth Grome 1998)
  12. RE: [REPLACE] inside [FOUNDITEMS] (Olin 1998)
  13. [REPLACE] inside [FOUNDITEMS] (Michael Winston 1998)
  14. Re: [REPLACE] inside [FOUNDITEMS] (Dave MacLeay 1998)
  15. RE: [REPLACE] inside [FOUNDITEMS] (Olin 1998)
>2.1.6 through 3.0b4, MAC PI > >I discovered something today and I'm not sure if it's a bug or a feature: > >Let's say I have a record with SKU=666 and INV=30, > >[SEARCH db=my.db&eqSKUdatarq=666] >[founditems] >[INV]

>[REPLACE db=my.db&eqSKUdatarq=666]INV=100[/REPLACE] >[INV] >[/FOUNDITEMS] >[/SEARCH] > >returns: >30 >100 > >I expected: >30 >30 > >I never expected that the [replace] would change my [founditems] results. >I thought it would replace the value in the database but leave the returned >values of my [search] untouched. This could (and has) caused quite a few >logic errors in some scripts. > >Has this been going on for long? Yes! This problem has *always* been there.It is unfortunately still NOT documented, but it is nevertheless a very BAD practice to use delete or replace contexts inside founditems loops. The reason has to do with the way the founditems loop works. It uses the [index] value of the found items in a way that causes it to fail when *any* of the index values change during the looping process. So, since replace and delete are the two actions that can change the relative index values of the items inside the loop, you should NEVER use delete or replace inside a founditems context.Sincerely, Ken Grome 808-737-6499 WebDNA Solutions mailto:ken@webdna.net http://www.webdna.net Kenneth Grome

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:

FYI: virus alert (1996) WCS Newbie question (1997) problems with WebCat-Plugin () Sorting by date (1997) Three new problems, maybe a fourth (1997) credit card - Revised (1997) Organisation website (2005) ACGI processing for .html (1997) FS WebCatalaog license (2000) Affiliate Marketing Question #2 (1998) [WebDNA] Crashing Database (2011) Dumb Question about Docs (1997) [WebDNA] listfiles on linux server (2011) Emailer help....! (1997) Just Testing (1997) setcookie getcookie on the same page (2003) suffix mapping for NT? (1997) off topic - dna snipets (1997) All of a Sudden Type 2 errors (1999) WebCatb15 Mac CGI -- [purchase] (1997)