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:
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:
WebDNA Running Out of RAM? (2004)
displaying New products (using [date]) (1997)
[WebDNA] OT - Selling Domain Names? (2009)
alternate location for cookies (2001)
How about this? (1998)
E-Mail Formatting (2000)
Instructions for Digest (1997)
Sorting error (1997)
two unique banners on one page (1997)
WC3 and SSL on NT (1998)
Restricting templates from causing havoc (2000)
Emailer choke (1997)
off topic fetch vs PCS photomaster (1997)
NT Setup (1998)
FREE Stuff .. (2003)
[WebDNA] macOS 10.13.3 and WebDNA Mac Server 8.5.1 - hick-up (2019)
WebCat2b13MacPlugIn - syntax to convert date (1997)
Null Characters (2005)
WebDelivery: One step closer !! (1997)
[WebDNA] [raw] tag with [interpret] question (2010)