Re: [WebDNA] How to use [function]
This WebDNA talk-list message is from 2012
It keeps the original formatting.
numero = 108660
interpreted = N
texte = Or just grep the whole page:[grep search=[%0A]&replace= ]entire page here ...[/grep]> ... more often when I would prefer > no white space in between lines> you can do it like this> > [hideif [myVar]=1][!]> [/!][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]
class"myclass">[SKU]-[name]
[/return] [/founditems]> [showif [numfound]=0]> [return]Nothing to see here[/return]> [/showif]> [/search]> [/function]> > and on your page> >
> [getResults whichDb=myDb]>
> > and again somewhere else> >
> [getResults whichDb=anotherDb]>
> > > > 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?> > > > 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
Associated Messages, from the most recent to the oldest:
Or just grep the whole page:[grep search=[%0A]&replace= ]entire page here ...[/grep]> ... more often when I would prefer > no white space in between lines> you can do it like this> > [hideif [myVar]=1][!]> [/!][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] class"myclass">[SKU]-[name]
[/return] [/founditems]> [showif [numfound]=0]> [return]Nothing to see here[/return]> [/showif]> [/search]> [/function]> > and on your page> > > [getResults whichDb=myDb]>
> > and again somewhere else> > > [getResults whichDb=anotherDb]>
> > > > 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?> > > > 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
WebDNA Solutions
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:
Setting up shop (1997)
IPADDRESS mystery (2003)
[WebDNA] Froala Editor working with WebDNA (2016)
setting cookies for another domain? (2002)
[append] vs. [appendfile] delta + question? (1997)
Using [showif] within [lineitems] [code fragment] (2000)
WebCatalog stalls (1998)
PIXO with cometsite ... and/or other plugins (1998)
delete after x (1998)
Mac Vs WindowsNT (1997)
Further tests with the infamous shipCost (1997)
[WebDNA] Anyone use this coding style for readability... (2010)
[WebDNA] [session] (2015)
[TaxableTotal] - not working with AOL and IE (1997)
Rotating Banners ... (was LinkExchange) (1997)
Error.html (1997)
Resume Catalog ? (1997)
WebCatalog for guestbook ? (1997)
WebCat2: Items xx to xx shown, etc. (1997)
RE: Signal Raised (1997)