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:

Time Tracking (2003) Trouble with formula.db (1997) Stinkin' [Referrer] (1998) emailer w/F2 (1997) [WebDNA] An actual attempt to get WebDNA and MAMP Pro to work - (2018) Calculate UnitShipCost in Formulas.db (1999) Shopping Cart variation... (1997) problems with 2 tags shakur (1997) Free pack for the New UPS ratings and services tool (2000) Custom buttons using site builder (2005) [isfolder] and [filename] (1997) Cold Fusion Buster (1997) WebCat2b12--[searchstring] bug (1997) WebCat hosting providers? (1997) Locking up with WebCatalog... (1997) attacment pdf (2001) [WriteFile] problems (1997) Grant, please help me ... (1997) .hdr files (2004) details (2003)