Re: [WebDNA] SWITCH/CASE or SHOWIF

This WebDNA talk-list message is from

2008


It keeps the original formatting.
numero = 101493
interpreted = N
texte = Thanks! I've decided to go with the switch/case statements. It looks like it doesn't add any line breaks to the code. I didn't try the SHOWIF method. Dan Strong wrote: > FWIW, I tested both sets of code below and saw absolutely ZERO > difference in performance. > -Dan > > > On Thu, 20 Nov 2008 12:44:21 -0800 > "Dan Strong" wrote: >> On Thu, 20 Nov 2008 14:53:13 -0500 >> Ki Song wrote: >>> We have about a 100 different brands at our store. >>> Some brands have "static" brand pages (brand/index.html) while others >>> have "dynamic" brand pages (dynamic.tpl?brand=somebrand). >>> >>> 1. To go through 100 different choices, is a switch/case more >>> efficient or 100 showif statements more efficient? >> >> My instict is that switch/case would be faster since it seems to be a >> "single" operation vs 100 [showif] operations, but it is untested and >> based on nothing but my own buest guess. >> >> Try a test similar to these and wrap [elapsedtime] around them or >> compare the start [time] to the end [time]: >> >> [text]x=[math]ceil([RANDOM format=float]*(100))[/math][/text] >> >> [Switch value=[x]] >> [loop start=1&end=100] >> [Case value=[index]]The value of x is [x][/Case] >> [/loop] >> [Default] >> [!]--The "default" case is probably not needed here since one of >> these cases will *always* be true, but hey, I still end my [search]es >> w/ [/search] --[/!] >> [/Default] >> [/Switch] >> >> ------------ >> >> [text]x=[math]ceil([RANDOM format=float]*(100))[/math][/text] >> >> [loop start=1&end=100] >> [showif [x]=[index]]The value of x is [x][/showif] >> [/loop] >> >> I'd be curious to see what the results are. >> >>> 2. In the final generated HTML code, when 100 SHOWIF statements are >>> processed, but only 1 is actually shown, the other 99 SHOWIF >>> statements create line breaks. Is there a way to prevent the line >>> breaks from showing up if a showif does not evaluate to true? >> >> I got this one from someone on the list: >> >> Wrap all "line-breaky" code like this: >> >> [getchars start=1&end=&trim=both] >> [grep search=[%0D%0A][%0D%0A%09]*&replace=%0D] >> ... your line-breaky code goes here ... >> [/grep] >> [/getchars] >> >>> >>> 3. Does a SWITCH/CASE statement create line breaks for all the cases >>> that evaluate to false? >> >> Dunno, but if so, wrap like above. >> -Dan > --------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > archives: http://mail.webdna.us/list/talk@webdna.us > old archives: http://dev.webdna.us/TalkListArchive/ > Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] SWITCH/CASE or SHOWIF (Ki Song 2008)
  2. Re: [WebDNA] SWITCH/CASE or SHOWIF ("Dan Strong" 2008)
  3. Re: [WebDNA] SWITCH/CASE or SHOWIF (Toby Cox 2008)
  4. Re: [WebDNA] SWITCH/CASE or SHOWIF (Govinda 2008)
  5. Re: [WebDNA] SWITCH/CASE or SHOWIF ("Dan Strong" 2008)
  6. Re: [WebDNA] SWITCH/CASE or SHOWIF (Ki Song 2008)
  7. Re: [WebDNA] SWITCH/CASE or SHOWIF (Govinda 2008)
  8. [WebDNA] SWITCH/CASE or SHOWIF (Ki Song 2008)
Thanks! I've decided to go with the switch/case statements. It looks like it doesn't add any line breaks to the code. I didn't try the SHOWIF method. Dan Strong wrote: > FWIW, I tested both sets of code below and saw absolutely ZERO > difference in performance. > -Dan > > > On Thu, 20 Nov 2008 12:44:21 -0800 > "Dan Strong" wrote: >> On Thu, 20 Nov 2008 14:53:13 -0500 >> Ki Song wrote: >>> We have about a 100 different brands at our store. >>> Some brands have "static" brand pages (brand/index.html) while others >>> have "dynamic" brand pages (dynamic.tpl?brand=somebrand). >>> >>> 1. To go through 100 different choices, is a switch/case more >>> efficient or 100 showif statements more efficient? >> >> My instict is that switch/case would be faster since it seems to be a >> "single" operation vs 100 [showif] operations, but it is untested and >> based on nothing but my own buest guess. >> >> Try a test similar to these and wrap [elapsedtime] around them or >> compare the start [time] to the end [time]: >> >> [text]x=[math]ceil([RANDOM format=float]*(100))[/math][/text] >> >> [Switch value=[x]] >> [loop start=1&end=100] >> [Case value=[index]]The value of x is [x][/Case] >> [/loop] >> [Default] >> [!]--The "default" case is probably not needed here since one of >> these cases will *always* be true, but hey, I still end my [search]es >> w/ [/search] --[/!] >> [/Default] >> [/Switch] >> >> ------------ >> >> [text]x=[math]ceil([RANDOM format=float]*(100))[/math][/text] >> >> [loop start=1&end=100] >> [showif [x]=[index]]The value of x is [x][/showif] >> [/loop] >> >> I'd be curious to see what the results are. >> >>> 2. In the final generated HTML code, when 100 SHOWIF statements are >>> processed, but only 1 is actually shown, the other 99 SHOWIF >>> statements create line breaks. Is there a way to prevent the line >>> breaks from showing up if a showif does not evaluate to true? >> >> I got this one from someone on the list: >> >> Wrap all "line-breaky" code like this: >> >> [getchars start=1&end=&trim=both] >> [grep search=[%0D%0A][%0D%0A%09]*&replace=%0D] >> ... your line-breaky code goes here ... >> [/grep] >> [/getchars] >> >>> >>> 3. Does a SWITCH/CASE statement create line breaks for all the cases >>> that evaluate to false? >> >> Dunno, but if so, wrap like above. >> -Dan > --------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > archives: http://mail.webdna.us/list/talk@webdna.us > old archives: http://dev.webdna.us/TalkListArchive/ > Ki Song

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:

Country & Ship-to address & other fields ? (1997) cookies and [returnraw] (1997) Authorize.net, SIM, tcpconnect and applescript (2003) WriteFile and returns... (2000) wc 2 pro users - sites, quotes wanted (1997) What really killed WebDNA? (2007) Progress !! WAS: Trouble with formula.db (1997) Sort Order on a page search (1997) WebCat2 beta 11 - new prefs ... (1997) Error Log.db --however (1997) FREE Web Server Monitor FREE (1997) Configuring E-mail (1997) [text show=f&secure=t] or ...? (2000) WebCat2b13MacPlugIn - [showif][search][/showif] (1997) foriegn characters and webcatalog (1997) DON'T use old cart file! (1997) Logging purchases (1997) Problems with [Search] param - Mac Plugin b15 (1997) [WebDNA] Character encoding / entity database? (2009) [WebDNA] COMMITDATABASE in linux unix 64bits FastCGI version 8.6 (2020)