Re: [WebDNA] SWITCH/CASE or SHOWIF

This WebDNA talk-list message is from

2008


It keeps the original formatting.
numero = 101491
interpreted = N
texte = On 20 Nov 2008, at 20:24, Govinda wrote: >> 1. To go through 100 different choices, is a switch/case more >> efficient or 100 showif statements more efficient? > I dunno, I would guess that one switch case is faster; at least in > other languages, when you evaluate once instead of many times, it's > faster. >> >> >> 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? > anywhere you don't want the line break to appear when webdna spite > out the html then just wrap it with the webdna comment tag, like > this one [!] > [/!] I find coding like this a bit annoying I prefer the newer [function name=myfunction] put stuff in here and it won't show... [text scope=golbal]var1=foo[/text] [text]var2=bar[/text] [return]anything you want displayed[/return] [/function] [myfunction] This example would return "\r \ranything you want displayed" The two carriage returns are the space in between the end of /function and the bit where it was called Worth noting that if you then called the following: var1=[var1] and var2=[var2] this would return var1=foo and var2=[var2] as to reference a variable outside a function, you need to specify [text scope=global] > >> >> >> 3. Does a SWITCH/CASE statement create line breaks for all the >> cases that evaluate to false? > if it does , then try the trick I just mentioned. >> > --------------------------------------------------------- > 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)
On 20 Nov 2008, at 20:24, Govinda wrote: >> 1. To go through 100 different choices, is a switch/case more >> efficient or 100 showif statements more efficient? > I dunno, I would guess that one switch case is faster; at least in > other languages, when you evaluate once instead of many times, it's > faster. >> >> >> 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? > anywhere you don't want the line break to appear when webdna spite > out the html then just wrap it with the webdna comment tag, like > this one [!] > [/!] I find coding like this a bit annoying I prefer the newer [function name=myfunction] put stuff in here and it won't show... [text scope=golbal]var1=foo[/text] [text]var2=bar[/text] [return]anything you want displayed[/return] [/function] [myfunction] This example would return "\r \ranything you want displayed" The two carriage returns are the space in between the end of /function and the bit where it was called Worth noting that if you then called the following: var1=[var1] and var2=[var2] this would return var1=foo and var2=[var2] as to reference a variable outside a function, you need to specify [text scope=global] > >> >> >> 3. Does a SWITCH/CASE statement create line breaks for all the >> cases that evaluate to false? > if it does , then try the trick I just mentioned. >> > --------------------------------------------------------- > 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/ Toby Cox

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:

Re:Searchable Archives (1998) version 2 for NT (1997) Insert Line Feed Character (2004) Help name our technology! I found it (1997) Frames (1997) Running _every_ page through WebCat ? (1997) Comments in db? (1997) How is it done? (1998) 2.0 Info (1997) BBEdit WedDNA Codeless Language Module (2004) Webcatalog 4.0 - When will we be able to beta test it? (2000) Summing fields (1997) Exclude by date - multiple (1997) Finding max value for a field (1997) Grant, please help me ... (1997) PDF template hell (2000) Using Plug-In while running 1.6.1 (1997) [WebDNA] CMS in WEBDNA (2009) WebCat2: Items xx to xx shown, etc. (1997) can WC render sites out? (1997)