Re: [WebDNA] How to use [function]

This WebDNA talk-list message is from

2012


It keeps the original formatting.
numero = 108666
interpreted = N
texte = This is a multi-part message in MIME format. --------------050908010009030606040607 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Thanks Toby an Kenneth, I will continue digging with your examples -Lawrence Toby Cox a =E9crit : > Lawrence > > I tend to use functions where I have a complicated bit of logic (either= within or without a search context), more often when I would prefer no w= hite space in between lines > > you can do it like this > > > [hideif [myVar]=3D1][!] > [/!][text]myNewVar=3D100[/text][!] > [/!][/hideif] > > is the same as this > > [function name=3DgenerateNewVar] > [hideif [myVar]=3D1] > [text scope=3Dglobal]myNewVar=3D100[/text] > [/hideif] > [return][/return] > [/function][generateNewVar] > > > I find the 2nd one easier to read. > > It is especially handy when generating XML, I find. > > Alternatively I would use it for text translation - [translateMyText te= xtToTranslate=3D[myDateVar]&language=3Dfrench] - and MySQL functions - so= mehow it's easier to print out [findMyRecords myVar=3D1] than do all the = steps necessary for > > > Normally a repeated bit of logic where the output is always in the same= format, but small input elements change is where I would use it most. In= the example you have given, I would almost always write this as inline c= ode. If, however, you wanted to have a find function that always printed = the results out in the same manner, you could do the following: > > > > [function name=3DgetResults] > [search db=3D[whichDb].db&&neSKUdata=3D[blank]] > [founditems] > [return]
[SKU]-[name]
[/return] > [/founditems] > [showif [numfound]=3D0] > [return]Nothing to see here[/return] > [/showif] > [/search] > [/function] > > and on your page > >
> [getResults whichDb=3DmyDb] >
> > and again somewhere else > >
> [getResults whichDb=3DanotherDb] >
> > > > Hope this helps.... > > > TC > > >> Toby, >> I'm trying to understand in which case I should use the [function] or= not. >> Your example is clear, It looks like it would be nice to have all the = webdna code in separate files, and have only the result called in the pag= e, that would make page codes clear. >> for the break/stop the documentation says : >> "'The [return] context does NOT 'break out' of a function call, so it = is possible to use one or more [return] contexts to 'tailor' the function= s output." >> >> Kenneth, >> how would you use an array with this kind of search function? >> >> Thanks >> Lawrence > > --------------------------------------------------------- > 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 > Bug Reporting: support@webdna.us --------------050908010009030606040607 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Thanks Toby an Kenneth,
I will continue digging with your examples
-Lawrence

Toby Cox a écrit :
LawrenceI tend to use functions where I have a complicated bit of logic (either within or without a search context), more often when I would prefer no white space in between linesyou can do it like this[hideif [myVar]=1][!]<!-- comment here to avoid generating line break -->  [/!][text]myNewVar=100[/text][!][/!][/hideif]is the same as this[function name=generateNewVar]  [hideif [myVar]=1]    [text scope=global]myNewVar=100[/text]  [/hideif][return][/return][/function][generateNewVar]I find the 2nd one easier to read.It is especially handy when generating XML, I find.Alternatively I would use it for text translation - [translateMyText textToTranslate=[myDateVar]&language=french] - and MySQL functions - somehow it's easier to print out [findMyRecords myVar=1] than do all the steps necessary for Normally a repeated bit of logic where the output is always in the same format, but small input elements change is where I would use it most. In the example you have given, I would almost always write this as inline code. If, however, you wanted to have a find function that always printed the results out in the same manner, you could do the following:[function name=getResults]  [search db=[whichDb].db&&neSKUdata=[blank]]    [founditems]      [return]<div class"myclass">[SKU]-[name]</div>[/return]    [/founditems]    [showif [numfound]=0]      [return]Nothing to see here[/return]    [/showif]  [/search][/function]and on your page<div class="resultsContainer">  [getResults whichDb=myDb]</div>and again somewhere else<div class="resultsContainer">  [getResults whichDb=anotherDb]</div>Hope this helps....TC
Toby, I'm trying to understand in which case I should use the  [function] or not.Your example is clear, It looks like it would be nice to have all the webdna code in separate files, and have only the result called in the page, that would make page codes clear. for the break/stop the documentation says :"'The [return] context does NOT 'break out' of a function call, so it is possible to use one or more [return] contexts to 'tailor' the functions output. "Kenneth, how would you use an array with this kind of search function?ThanksLawrence
---------------------------------------------------------This message is sent to you because you are subscribed tothe mailing list <talk@webdna.us>.To unsubscribe, E-mail to: <talk-leave@webdna.us>archives: http://mail.webdna.us/list/talk@webdna.usBug Reporting: support@webdna.us
--------------050908010009030606040607-- Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] How to use [function] (Govinda 2012)
  2. Re: [WebDNA] How to use [function] (Donovan Brooke 2012)
  3. Re: [WebDNA] How to use [function] (Banahan 2012)
  4. Re: [WebDNA] How to use [function] (Toby Cox 2012)
  5. Re: [WebDNA] How to use [function] (WebDNA Solutions 2012)
  6. Re: [WebDNA] How to use [function] (Toby Cox 2012)
  7. Re: [WebDNA] How to use [function] (WebDNA Solutions 2012)
  8. Re: [WebDNA] How to use [function] (Banahan 2012)
  9. Re: [WebDNA] How to use [function] (Toby Cox 2012)
  10. Re: [WebDNA] How to use [function] (WebDNA Solutions 2012)
  11. Re: [WebDNA] How to use [function] (Banahan 2012)
  12. Re: [WebDNA] How to use [function] (WebDNA Solutions 2012)
  13. [WebDNA] How to use [function] (Banahan 2012)
This is a multi-part message in MIME format. --------------050908010009030606040607 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Thanks Toby an Kenneth, I will continue digging with your examples -Lawrence Toby Cox a =E9crit : > Lawrence > > I tend to use functions where I have a complicated bit of logic (either= within or without a search context), more often when I would prefer no w= hite space in between lines > > you can do it like this > > > [hideif [myVar]=3D1][!] > [/!][text]myNewVar=3D100[/text][!] > [/!][/hideif] > > is the same as this > > [function name=3DgenerateNewVar] > [hideif [myVar]=3D1] > [text scope=3Dglobal]myNewVar=3D100[/text] > [/hideif] > [return][/return] > [/function][generateNewVar] > > > I find the 2nd one easier to read. > > It is especially handy when generating XML, I find. > > Alternatively I would use it for text translation - [translateMyText te= xtToTranslate=3D[myDateVar]&language=3Dfrench] - and MySQL functions - so= mehow it's easier to print out [findMyRecords myVar=3D1] than do all the = steps necessary for > > > Normally a repeated bit of logic where the output is always in the same= format, but small input elements change is where I would use it most. In= the example you have given, I would almost always write this as inline c= ode. If, however, you wanted to have a find function that always printed = the results out in the same manner, you could do the following: > > > > [function name=3DgetResults] > [search db=3D[whichDb].db&&neSKUdata=3D[blank]] > [founditems] > [return]
[SKU]-[name]
[/return] > [/founditems] > [showif [numfound]=3D0] > [return]Nothing to see here[/return] > [/showif] > [/search] > [/function] > > and on your page > >
> [getResults whichDb=3DmyDb] >
> > and again somewhere else > >
> [getResults whichDb=3DanotherDb] >
> > > > Hope this helps.... > > > TC > > >> Toby, >> I'm trying to understand in which case I should use the [function] or= not. >> Your example is clear, It looks like it would be nice to have all the = webdna code in separate files, and have only the result called in the pag= e, that would make page codes clear. >> for the break/stop the documentation says : >> "'The [return] context does NOT 'break out' of a function call, so it = is possible to use one or more [return] contexts to 'tailor' the function= s output." >> >> Kenneth, >> how would you use an array with this kind of search function? >> >> Thanks >> Lawrence > > --------------------------------------------------------- > 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 > Bug Reporting: support@webdna.us --------------050908010009030606040607 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Thanks Toby an Kenneth,
I will continue digging with your examples
-Lawrence

Toby Cox a écrit :
LawrenceI tend to use functions where I have a complicated bit of logic (either within or without a search context), more often when I would prefer no white space in between linesyou can do it like this[hideif [myVar]=1][!]<!-- comment here to avoid generating line break -->  [/!][text]myNewVar=100[/text][!][/!][/hideif]is the same as this[function name=generateNewVar]  [hideif [myVar]=1]    [text scope=global]myNewVar=100[/text]  [/hideif][return][/return][/function][generateNewVar]I find the 2nd one easier to read.It is especially handy when generating XML, I find.Alternatively I would use it for text translation - [translateMyText textToTranslate=[myDateVar]&language=french] - and MySQL functions - somehow it's easier to print out [findMyRecords myVar=1] than do all the steps necessary for Normally a repeated bit of logic where the output is always in the same format, but small input elements change is where I would use it most. In the example you have given, I would almost always write this as inline code. If, however, you wanted to have a find function that always printed the results out in the same manner, you could do the following:[function name=getResults]  [search db=[whichDb].db&&neSKUdata=[blank]]    [founditems]      [return]<div class"myclass">[SKU]-[name]</div>[/return]    [/founditems]    [showif [numfound]=0]      [return]Nothing to see here[/return]    [/showif]  [/search][/function]and on your page<div class="resultsContainer">  [getResults whichDb=myDb]</div>and again somewhere else<div class="resultsContainer">  [getResults whichDb=anotherDb]</div>Hope this helps....TC
Toby, I'm trying to understand in which case I should use the  [function] or not.Your example is clear, It looks like it would be nice to have all the webdna code in separate files, and have only the result called in the page, that would make page codes clear. for the break/stop the documentation says :"'The [return] context does NOT 'break out' of a function call, so it is possible to use one or more [return] contexts to 'tailor' the functions output. "Kenneth, how would you use an array with this kind of search function?ThanksLawrence
---------------------------------------------------------This message is sent to you because you are subscribed tothe mailing list <talk@webdna.us>.To unsubscribe, E-mail to: <talk-leave@webdna.us>archives: http://mail.webdna.us/list/talk@webdna.usBug Reporting: support@webdna.us
--------------050908010009030606040607-- Banahan

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:

.html with IIS4 (1999) Re:Email (1998) Big Databases (1997) Content search & results (2008) Can't Update records (1997) RE: type 2 errors with ssl server (1997) Separate SSL Server (1997) Logging users (1998) Image maps/Webcat (1997) WebCat2b13MacPlugIn - [include] (1997) MacWEEK article help needed (1996) WebCat2b13MacPlugIn - [showif][search][/showif] (1997) Append File help needed (2000) View order not right (1997) Aaron kant add (or whatever it was) (2000) WebCat on Alpha? (1997) Banners and sort of random display (1997) WebCat2b13MacPlugin - nested [xxx] contexts (1997) PCS Frames (1997) Email problem.. (2004)