Re: [WebDNA] How to use [function]

This WebDNA talk-list message is from

2012


It keeps the original formatting.
numero = 108667
interpreted = N
texte = Banahan wrote: > Hi, > > I have been spending hours digging in Govinda great job in > WebdnaCodeSparker. > > I must confess I have never been using the [function] and I now > wondering how to use it... > I went thought the doc, it clear to me how to send variable to a > function that will execute it. > > But How to use function with a search contexts? [snip] Lawrence, if you are on 6x, spend some time in the IDE if you want to learn about Functions. webdna.us is lacking in instructions for the use of the function context. Functions, with use of [return], as Toby suggested, are great for removing white space. However, they have *many* other uses as well. They provide innate variable scoping. They are great for creating organized libraries of common bits of code that can be called repeatedly as WebDNA Tags. However, as Ken suggested, it's not a required learning to be able to do things in WebDNA. Functions are kind of a comfort level step. Ken, you could make a function out of your white space code! :-) (I would use just one grep though) ------------------------ [function name=removewhitespace] [grep search=[%0A%0D%09]&replace=]| This is a page with a  bunch of white space. |[/grep][/function] [removewhitespace] ------------------------- You could also automate it... I know Chris stated that he was deprecating the pre/post parse scripts at one point.. so not sure if they are there in WebDNA7 and if they will be supported in the future.. but in CICADA (my much more preferred edition ;-) ), you could automate white space removal by using the postparsescript... just add this to the script. ------------------------- [grep search=[%0A%0D%09]&replace=][WEBDNA_TEMPLATE_RESULTS][/grep] ------------------------- Or, for more control... you could automate white space removal for certain templates only... First, define a removewhitespace function in the preparse script (in the include file that is called by the preparse script): ------------------------- [!] ** removes white space other than spaces ** [/!] [function name=removewhitespace] [return][grep search=[%0A%0D%09]&replace=][params_string][/grep][/return] [/function] ------------------------- Then utilize it in the post parse script. ------------------------- PostParseScript [if "[url][thisurl][/url]" ^ "[url][/url]"] [then] [removewhitespace [url][WEBDNA_TEMPLATE_RESULTS][/url]] [/then] [else] [WEBDNA_TEMPLATE_RESULTS] [/else] [/if] (not tested, but should work) ---------------------------- I should finally note that you should be careful in removing white space globally as it is not hard to remove desired characters by mistake... I prefer Toby's method.. much more controlled. Donovan -- Donovan Brooke Euca Design Center www.euca.us 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)
Banahan wrote: > Hi, > > I have been spending hours digging in Govinda great job in > WebdnaCodeSparker. > > I must confess I have never been using the [function] and I now > wondering how to use it... > I went thought the doc, it clear to me how to send variable to a > function that will execute it. > > But How to use function with a search contexts? [snip] Lawrence, if you are on 6x, spend some time in the IDE if you want to learn about Functions. webdna.us is lacking in instructions for the use of the function context. Functions, with use of [return], as Toby suggested, are great for removing white space. However, they have *many* other uses as well. They provide innate variable scoping. They are great for creating organized libraries of common bits of code that can be called repeatedly as WebDNA Tags. However, as Ken suggested, it's not a required learning to be able to do things in WebDNA. Functions are kind of a comfort level step. Ken, you could make a function out of your white space code! :-) (I would use just one grep though) ------------------------ [function name=removewhitespace] [grep search=[%0A%0D%09]&replace=]| This is a page with a  bunch of white space. |[/grep][/function] [removewhitespace] ------------------------- You could also automate it... I know Chris stated that he was deprecating the pre/post parse scripts at one point.. so not sure if they are there in WebDNA7 and if they will be supported in the future.. but in CICADA (my much more preferred edition ;-) ), you could automate white space removal by using the postparsescript... just add this to the script. ------------------------- [grep search=[%0A%0D%09]&replace=][WEBDNA_TEMPLATE_RESULTS][/grep] ------------------------- Or, for more control... you could automate white space removal for certain templates only... First, define a removewhitespace function in the preparse script (in the include file that is called by the preparse script): ------------------------- [!] ** removes white space other than spaces ** [/!] [function name=removewhitespace] [return][grep search=[%0A%0D%09]&replace=][params_string][/grep][/return] [/function] ------------------------- Then utilize it in the post parse script. ------------------------- PostParseScript [if "[url][thisurl][/url]" ^ "[url][/url]"] [then] [removewhitespace [url][WEBDNA_TEMPLATE_RESULTS][/url]] [/then] [else] [WEBDNA_TEMPLATE_RESULTS] [/else] [/if] (not tested, but should work) ---------------------------- I should finally note that you should be careful in removing white space globally as it is not hard to remove desired characters by mistake... I prefer Toby's method.. much more controlled. Donovan -- Donovan Brooke Euca Design Center www.euca.us Donovan Brooke

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:

Personal Web Server combined with Webcatalog 2.1 (1998) All questions are welcome on this list (1997) emailer don't work (1998) RE: is sku a REQUIRED field on NT (1997) WebCat2: Formulas.db question (1997) need to delete a database remotely (2000) Emailer setup (1997) RE: Clearing orders and database help! (1997) New NT beta available (1997) t or f (1997) [CART] inside a [LOOP] (1997) [WebDNA] Successful, working WebDNA7/CentOS install? (2013) Some Questions (1997) [WebDNA] listfiles weirdness? (2018) Problems with [Search] param - Mac Plugin b15 (1997) comparison to Lasso 6 or 7 (2004) Opinion: [input] should be called [output] ... (1997) SQL on Linux - Howto? (2000) authnet good news (2003) Handy Browser Counter Tip (1997)