Re: [WebDNA] Issue with including functions

This WebDNA talk-list message is from

2011


It keeps the original formatting.
numero = 107061
interpreted = N
texte = William DeVaul wrote: > I am trying to include files that define various functions in a way > that keeps my code from being cluttered. I want to include some > functions conditionally. The file /includes/vendor.inc does exist. > > First, I tried: > > [function name=include_if_exists] > [showif [fileinfo file=[file]][exists][/fileinfo]=T][return][include > file=[file]][/return][/showif] > [/function] > > [include_if_exists file=/includes/vendor.inc] > > That did not work because the functions in the included file were (I'm > guessing here) within the namespace of the function > "include_if_exists". Hi William, this is where scoping comes in handy. Unfortunately, this stuff is not documented well at all.. it was some newer stuff that was not given the time to be documented properly. You can explicitly set scoping... so you have options.. you can either set the scope of your results of your functions (within vendor.inc) [text scope=global][someresultvar][/text] [return][:global:someresult][/return] etc etc.. or, what has never been documented perhaps, the use of the scope param within function... [function name=blah&scope=global] ** note: I discovered this use on my own and haven't tested it thoroughly.. so use at your own risk ** Anyway, the scope=global,local,insecure is some of the newer stuff and appears to work in many of the contexts... though undocumented. Donovan -- Donovan Brooke **[Square Bracket Utopia]** Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] Issue with including functions (Govinda 2011)
  2. Re: [WebDNA] Issue with including functions (Donovan Brooke 2011)
  3. [WebDNA] Issue with including functions (William DeVaul 2011)
William DeVaul wrote: > I am trying to include files that define various functions in a way > that keeps my code from being cluttered. I want to include some > functions conditionally. The file /includes/vendor.inc does exist. > > First, I tried: > > [function name=include_if_exists] > [showif [fileinfo file=[file]][exists][/fileinfo]=T][return][include > file=[file]][/return][/showif] > [/function] > > [include_if_exists file=/includes/vendor.inc] > > That did not work because the functions in the included file were (I'm > guessing here) within the namespace of the function > "include_if_exists". Hi William, this is where scoping comes in handy. Unfortunately, this stuff is not documented well at all.. it was some newer stuff that was not given the time to be documented properly. You can explicitly set scoping... so you have options.. you can either set the scope of your results of your functions (within vendor.inc) [text scope=global][someresultvar][/text] [return][:global:someresult][/return] etc etc.. or, what has never been documented perhaps, the use of the scope param within function... [function name=blah&scope=global] ** note: I discovered this use on my own and haven't tested it thoroughly.. so use at your own risk ** Anyway, the scope=global,local,insecure is some of the newer stuff and appears to work in many of the contexts... though undocumented. Donovan -- Donovan Brooke **[Square Bracket Utopia]** 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:

SSL problems (1998) Banners and sort of random display (1997) WebCat2b12 CGI Mac -- Problems propagating the cart through frames...still (1997) Webcatalog [blank] Problem (1999) WebCatb15 Mac CGI -- [purchase] (1997) trouble updating records in database (1998) Time Remaining? (1998) ANNC: BannerSleuth v2.0 Beta 1 (1999) WCS Newbie question (1997) [math date] with non-US date format (2000) IIS Brain Dead (1998) WebCatalog Hosting (1996) Configuring E-mail (1997) Next X hits (1996) Using Plug-In while running 1.6.1 (1997) Upgrading old WebCat Database Files (1997) More on the email templates (I like it) (1997) U&P IIS concept (1998) [shell] (2005) Kaaaaahhhhhhhnnnnnnn! (1997)