Re: if else problem

This WebDNA talk-list message is from

2003


It keeps the original formatting.
numero = 54712
interpreted = N
texte = While there are certainly limitations to the switch/case context, it is=20= extremely useful and efficient in situations where you are comparing=20 one variable to a fixed list of possible values (plus a default). It's=20= kinda like a [lookup] vs. a [search]... if you have something tricker=20 to do than the switch/case handles, then use showif/hideif or=20 if/then/else instead. But don't ignore switch/case as a useful tool,=20 because, like [lookup] it will be faster to write and to execute in the=20= right situations. Brian On Dec 5, 2003, at 5:05 PM, Kenneth Grome wrote: >> Here's one more option, and the one that I would personally choose=20 >> for your situation, which presents an excellent example of when to=20 >> use a switch/case context: >> >> [switch value=3D[url][currency][/url]] >> [case value=3DUSD][text]priceDisplay=3D$[format=20 >> 10.2f][USDcost][/format][/text][/case] >> [case value=3DEUR][text]priceDisplay=3D=A4[format=20 >> 10.2f][EURcost][/format][/text][/case] >> [case value=3DJPY][text]priceDisplay=3D=A5[format=20 >> 10.2f][JPYcost][/format][/text][/case] >> [default][text]priceDisplay=3D=A3[format=20 >> 10.2f][PRICE][/format][/text][/default] >> [/switch] > > > I agree, the switch/case solution is actually the best (or at least=20 > it's the easiest to understand) provided you're using version 4.x and=20= > above. I would have suggested it myself except that I almost never=20 > use switch/case. I have in fact become quite adept at using=20 > showif/hideif in innovative ways to achieve the same results, and=20 > because of this I seldom use if/then/else as well ... :) > > By the way, I would like to provide one important word of warning = here: > > The way switch/case works in webdna is to display ALL the matching=20 > cases, not just the first matching case. This is NOT the way=20 > switch/case works in other popular software products! > > In the other software I've used, only the FIRST matching case is = shown. > > I was very disappointed to learn that I could not use webdna's=20 > switch/case to select only the first match from a long list of=20 > options. And although I'm sure one could be added, there is *still*=20= > no preference (not even an optional "match=3Dfirst" parameter) that=20 > would make it display only the first match. > > This is the biggest reason why I never use switch/case myself. > > :( > --=20 > > Kenneth Grome -- Brian Fries, BrainScan Software -- http://www.brainscansoftware.com=20= -- ------------------------------------------------------------- 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://webdna.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: if else problem ( John Peacock 2003)
  2. Re: if else problem ( Brian Fries 2003)
  3. Re: if else problem ( Kenneth Grome 2003)
  4. Re: if else problem ( Brian Fries 2003)
  5. Re: if else problem ( "RichC" 2003)
  6. Re: if else problem ( Alan White 2003)
  7. Re: if else problem ( Kenneth Grome 2003)
  8. Re: if else problem ( Alan White 2003)
  9. Re: if else problem ( Rob Marquardt 2003)
  10. Re: if else problem :- Version1 ( Donovan Brooke 2003)
  11. Re: if else problem: Version 2 ( "Erol Guneri" 2003)
  12. Re: if else problem: Version 2 ( Alan White 2003)
  13. Re: if else problem :- Version1 ( Alan White 2003)
  14. Re: if else problem ( Donovan Brooke 2003)
  15. Re: if else problem ( Alan White 2003)
  16. Re: if else problem ( Gary Krockover 2003)
  17. Re: if else problem ( Alan White 2003)
  18. Re: if else problem ( Brian Fries 2003)
  19. Re: if else problem ( Brian Fries 2003)
  20. Re: if else problem ( Alan White 2003)
  21. Re: if else problem ( Brian Fries 2003)
  22. Re: if else problem ( "Erol Guneri" 2003)
  23. if else problem ( Alan White 2003)
While there are certainly limitations to the switch/case context, it is=20= extremely useful and efficient in situations where you are comparing=20 one variable to a fixed list of possible values (plus a default). It's=20= kinda like a [lookup] vs. a [search]... if you have something tricker=20 to do than the switch/case handles, then use showif/hideif or=20 if/then/else instead. But don't ignore switch/case as a useful tool,=20 because, like [lookup] it will be faster to write and to execute in the=20= right situations. Brian On Dec 5, 2003, at 5:05 PM, Kenneth Grome wrote: >> Here's one more option, and the one that I would personally choose=20 >> for your situation, which presents an excellent example of when to=20 >> use a switch/case context: >> >> [switch value=3D[url][currency][/url]] >> [case value=3DUSD][text]priceDisplay=3D$[format=20 >> 10.2f][USDcost][/format][/text][/case] >> [case value=3DEUR][text]priceDisplay=3D=A4[format=20 >> 10.2f][EURcost][/format][/text][/case] >> [case value=3DJPY][text]priceDisplay=3D=A5[format=20 >> 10.2f][JPYcost][/format][/text][/case] >> [default][text]priceDisplay=3D=A3[format=20 >> 10.2f][PRICE][/format][/text][/default] >> [/switch] > > > I agree, the switch/case solution is actually the best (or at least=20 > it's the easiest to understand) provided you're using version 4.x and=20= > above. I would have suggested it myself except that I almost never=20 > use switch/case. I have in fact become quite adept at using=20 > showif/hideif in innovative ways to achieve the same results, and=20 > because of this I seldom use if/then/else as well ... :) > > By the way, I would like to provide one important word of warning = here: > > The way switch/case works in webdna is to display ALL the matching=20 > cases, not just the first matching case. This is NOT the way=20 > switch/case works in other popular software products! > > In the other software I've used, only the FIRST matching case is = shown. > > I was very disappointed to learn that I could not use webdna's=20 > switch/case to select only the first match from a long list of=20 > options. And although I'm sure one could be added, there is *still*=20= > no preference (not even an optional "match=3Dfirst" parameter) that=20 > would make it display only the first match. > > This is the biggest reason why I never use switch/case myself. > > :( > --=20 > > Kenneth Grome -- Brian Fries, BrainScan Software -- http://www.brainscansoftware.com=20= -- ------------------------------------------------------------- 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://webdna.smithmicro.com/ Brian Fries

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:

Nested vs conditional (1997) trouble updating records in database (1998) Thanks ! (1997) MasterCounter Help (1998) docs for WebCatalog2 (1997) Can't use old cart file (was One more try) (1997) Typhoon Pro Admin and Problems (2001) WebCatalog f2 Installation (1997) WebCat2_Mac RETURNs in .db (1997) [WebDNA] ReturnRAW problem with Safari (2015) Showif with an or (2003) New Cart No. on same page (2003) if else problem (2003) [OT] Who's got a cool link (2002) Format of Required fields error message (1997) Sendmail (1997) how do ye do this?????? (2001) WCS Newbie question (1997) Intermitent problem using [referrer] (1997) AOL and webcat (1998)