Re: Coding Technique

This WebDNA talk-list message is from

2000


It keeps the original formatting.
numero = 32627
interpreted = N
texte = You may have missed a discussion that has been going on as recently as yesterday on this list. Look for the subject line: Too many webcat comments. [WAS- Large founditems loops]There have been reports of this method causing problems.Mike> This is such a great idea, I have to tell you all. (Maybe it's all old hat.) > > Often times you need to use several lines of code to set a value. Like > this: > > [search db=admin/product.db&eqSKUdata=[theSKU]][founditems] > [text]thePrice=[price][/text] > [showif [qty]>[level2]][text]thePrice=[price2][/text][/showif] > [showif [qty]>[level3]][text]thePrice=[price3][/text][/showif] > [/founditems][/search][thePrice] > > The problem if this is in an include file and you do something like > > [text]finalPrice=[include priceCalc.tmpl][/text] > > All those Return characters get added to your value, messing up the > calculations. So what do you do? You take out the Returns, and you get > code that looks like this: > > [search db=admin/product.db&eqSKUdata=[theSKU]][founditems][text] > thePrice=[price][/text][showif [qty]>[level2]][text]thePrice=[pri > ce2][/text][/showif][showif [qty]>[level3]][text]thePrice=[price3 > ][/text][/showif][/founditems][/search][thePrice] > > (All on one line...) > > You can't read it very easily or debug it without adding the returns back > in. The solution is to use WebDNA comments! Then you get to keep the > readable code. You can also put in comments if you want! > > > [search db=admin/product.db&eqSKUdata=[theSKU]][founditems][!] > [/!][text]thePrice=[price][/text][!] This is the standard price > [/!][showif [qty]>[level2]][text]thePrice=[price2][/text][/showif][!] > [/!][showif [qty]>[level3]][text]thePrice=[price3][/text][/showif][!] > [/!][/founditems][/search][thePrice] > > or even line numbers.... > > [search db=admin/product.db&eqSKUdata=[theSKU]][founditems][!] > 1: [/!][text]thePrice=[price][/text][!] > 2: [/!][showif [qty]>[level2]][text]thePrice=[price2][/text][/showif][!] > 3: [/!][showif [qty]>[level3]][text]thePrice=[price3][/text][/showif][!] > [/!][/founditems][/search][thePrice] > > One of my employees came up with this while coding an export into a fixed > width format file. Now I use it all the time. Just make sure you match the > [!] with the [/!] > > > Phil Marshall ------------------------------------------------------------- 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 Web Archive of this list is at: http://search.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: Coding Technique (Mike Davis 2000)
  2. Re: Coding Technique (Kenneth Grome 2000)
  3. Coding Technique (Phil Marshall 2000)
You may have missed a discussion that has been going on as recently as yesterday on this list. Look for the subject line: Too many webcat comments. [WAS- Large founditems loops]There have been reports of this method causing problems.Mike> This is such a great idea, I have to tell you all. (Maybe it's all old hat.) > > Often times you need to use several lines of code to set a value. Like > this: > > [search db=admin/product.db&eqSKUdata=[theSKU]][founditems] > [text]thePrice=[price][/text] > [showif [qty]>[level2]][text]thePrice=[price2][/text][/showif] > [showif [qty]>[level3]][text]thePrice=[price3][/text][/showif] > [/founditems][/search][thePrice] > > The problem if this is in an include file and you do something like > > [text]finalPrice=[include priceCalc.tmpl][/text] > > All those Return characters get added to your value, messing up the > calculations. So what do you do? You take out the Returns, and you get > code that looks like this: > > [search db=admin/product.db&eqSKUdata=[theSKU]][founditems][text] > thePrice=[price][/text][showif [qty]>[level2]][text]thePrice=[pri > ce2][/text][/showif][showif [qty]>[level3]][text]thePrice=[price3 > ][/text][/showif][/founditems][/search][thePrice] > > (All on one line...) > > You can't read it very easily or debug it without adding the returns back > in. The solution is to use WebDNA comments! Then you get to keep the > readable code. You can also put in comments if you want! > > > [search db=admin/product.db&eqSKUdata=[theSKU]][founditems][!] > [/!][text]thePrice=[price][/text][!] This is the standard price > [/!][showif [qty]>[level2]][text]thePrice=[price2][/text][/showif][!] > [/!][showif [qty]>[level3]][text]thePrice=[price3][/text][/showif][!] > [/!][/founditems][/search][thePrice] > > or even line numbers.... > > [search db=admin/product.db&eqSKUdata=[theSKU]][founditems][!] > 1: [/!][text]thePrice=[price][/text][!] > 2: [/!][showif [qty]>[level2]][text]thePrice=[price2][/text][/showif][!] > 3: [/!][showif [qty]>[level3]][text]thePrice=[price3][/text][/showif][!] > [/!][/founditems][/search][thePrice] > > One of my employees came up with this while coding an export into a fixed > width format file. Now I use it all the time. Just make sure you match the > [!] with the [/!] > > > Phil Marshall ------------------------------------------------------------- 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 Web Archive of this list is at: http://search.smithmicro.com/ Mike Davis

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:

password authentication schemes (2003) problems with 2 tags (1997) won't serve .tpl -index.tpl gone, made test.tpl (2000) Still trying to email... (1998) How to Sort Summ data ? (1997) WC1.6 to WC2 date formatting (1997) Bug? (1997) NT vs Mac (1997) Need relative path explanation (1997) E-mail Attachments (1997) OT: Regex Help (2005) Sending E-mail (1997) WebCatalog for Postcards ? (1997) RE: protect tag not working (1998) Getting it as [raw] (2004) Plugin or CGI or both (1997) Fwd: Problems with Webcatalog Plug-in (1997) WCS Newbie question (1997) Progress !! WAS: Trouble with formula.db (1997) [WebDNA] Help with STMP Setup using Authentication with Google (2016)