Re: Don't know if this is a sily question...
This WebDNA talk-list message is from 2003
It keeps the original formatting.
numero = 50789
interpreted = N
texte = Heh ... I wouldn't even want to try this with a text variable. Good example, by the way!:)>Ok, Ken... here's a quick and easy example. Count the total size of >all the files in a folder and its sub-folders - to an unlimited >folder depth.>>Using a recursive function, it took me about 5 minutes to write >this, and it worked correctly on my first test:>>---begin code--->[function name=FolderSize]> [math show=F]totSize=0[/math]> [listfiles path=[url][theFolder][/url]]> [if [isfile]=T][then]> [math show=F]totSize=totSize+[size][/math]> [/then][else]> [math show=F]totSize=totSize+[FolderSize >thefolder=[url][theFolder][filename][/url]][/math]> [/else][/if]> [/listfiles]>> [return][totSize][/return]>[/function]>>[text]myFolder=/[/text][!]Change this to any folder path, but make >sure to leave a trailing slash[/!]>[FolderSize theFolder=[url][myFolder][/url]] total bytes in [myFolder]>---end code--->>Time yourself performing the same task using a text variable >solution. It can be done (I've done similar in the past), but it >will take considerably more time for the initial coding and for >testing and debugging. The text solution would need to be in an >include file to accept a parameter, you'd need to hand-code a >solution to handle recursive scope problems, and you'd need to be >careful not to use any variable names in your include file that may >be used by the rest of your code. That's what I mean by careful >crafting.>>I'm working on a WebDNA 5 solution for performing mirrored and >incremental backups of my web sites now. I'd been planning to do >this for a long time, but it was not feasible to develop it under >WebDNA 4 - recursive functions in WebDNA 5 have made it much easier >to code and less prone to programming errors.>>- brian>>On Thursday, May 29, 2003, at 07:36 PM, Kenneth Grome wrote:>>>I'm not sure what you mean by careful crafting when all you have >>to do is wrap a [raw] context around the text variable value. >>There's nothing in this simple task that I would consider careful >>crafting any more than any other common webdna coding task.>>>>Also, you seem to be suggesting that the function solution can >>perform 'recursively' but the text variable solution cannot. I >>have to disagree with this. I have never seen a situation in which >>the text variable solution does not work recursively. Do you have >>an example that you can post to the list so we can see what you're >>talking about here?>>>>My conclusion is that the text variable solution does the exact >>same thing as the function solution -- and it works in v4 and v5 -- >>unlike the function solution which works ONLY in v5.>>>>Oh, and if there is any question as to the use of the text variable >>solution in multiple pages, it is a simple task to put the code >>into an include file -- so it can be included in *any* webdna >>template on the same server.>>>>Furthermore the text variable solution can be used on multiple >>webdna servers -- by using tcpconnect to retrieve the template that >>has the text variable code in it, and then interpreting that code >>inside the local webdna template on the local server.>>>>>>>Yes, the text variable method is a useful technique, but takes >>>careful crafting. I also have used similar techniques for years, >>>but the new [function] context makes it sooo much easier, >>>especially when you get more complex with the reusable code >>>blocks, and when you want to do something recursive. It's worth >>>the price of admission for me.>>>>>>- brian>>>>>>On Thursday, May 29, 2003, at 10:18 AM, Kenneth Grome wrote:>>>>>>>>As a related comment, using WebDNA 5 I find myself more often >>>>>using [function]s where I used to use [include]s to handle >>>>>recurring tasks. The formal use of parameters, the local scope >>>>>variables, and the ability to define functions within the page >>>>>itself as well as in a shared include file are compelling >>>>>features.>>>>>>>>>>As a simple example:>>>>>>>>>>[function name=MyLink]>>>>>[return]
>>>>db=....&value=[thevalue]&returnfield=ID]>[lookup >>>>>db=....&value=[thevalue]&returnfield=title][/return]>>>>>[/function]>>>>>>>>>>[search ...]>>>>>[founditems]>>>>>[MyLink thevalue=[whatever]]>>>>>[/founditems]>>>>>[/search]>>>>>>>>>>- brian>>>>>>>>>>>>I've been doing something similar for years, without v5's function context:>>>>>>>>[text]myLink=[raw]
>>>db=....&value=[thevalue]&returnfield=ID]>[lookup >>>>db=....&value=[thevalue]&returnfield=title][/raw][/text]>>>>>>>>[search ...]>>>>[founditems]>>>>[myLink]>>>>[/founditems]>>>>[/search]>>>>>>>>This has always been an easy way to create a variable once at the >>>>top of the page, and then use it any number of times further down >>>>on the same page -- while preventing the webdna code inside the >>>>text variable from being interpreted until the variable tag is >>>>used further down on the page -- such as inside the founditems >>>>context in this example.>>>>-->>>>>>>>Sincerely,>>>>Kenneth Grome>>>------------------------------------------------------------->This message is sent to you because you are subscribed to> the mailing list
.>To unsubscribe, E-mail to: >To switch to the DIGEST mode, E-mail to >>Web Archive of this list is at: http://webdna.smithmicro.com/-- Sincerely,Kenneth Grome-------------------------------------------------------------My programmers will write WebDNA code for you at $27 an hour!--------------------------------------------------------------------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list .To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/
Associated Messages, from the most recent to the oldest:
Heh ... I wouldn't even want to try this with a text variable. Good example, by the way!:)>Ok, Ken... here's a quick and easy example. Count the total size of >all the files in a folder and its sub-folders - to an unlimited >folder depth.>>Using a recursive function, it took me about 5 minutes to write >this, and it worked correctly on my first test:>>---begin code--->[function name=FolderSize]> [math show=F]totSize=0[/math]> [listfiles path=[url][theFolder][/url]]> [if [isfile]=T][then]> [math show=F]totSize=totSize+[size][/math]> [/then][else]> [math show=F]totSize=totSize+[FolderSize >thefolder=[url][theFolder][filename][/url]][/math]> [/else][/if]> [/listfiles]>> [return][totSize][/return]>[/function]>>[text]myFolder=/[/text][!]Change this to any folder path, but make >sure to leave a trailing slash[/!]>[FolderSize theFolder=[url][myFolder][/url]] total bytes in [myFolder]>---end code--->>Time yourself performing the same task using a text variable >solution. It can be done (I've done similar in the past), but it >will take considerably more time for the initial coding and for >testing and debugging. The text solution would need to be in an >include file to accept a parameter, you'd need to hand-code a >solution to handle recursive scope problems, and you'd need to be >careful not to use any variable names in your include file that may >be used by the rest of your code. That's what I mean by careful >crafting.>>I'm working on a WebDNA 5 solution for performing mirrored and >incremental backups of my web sites now. I'd been planning to do >this for a long time, but it was not feasible to develop it under >WebDNA 4 - recursive functions in WebDNA 5 have made it much easier >to code and less prone to programming errors.>>- brian>>On Thursday, May 29, 2003, at 07:36 PM, Kenneth Grome wrote:>>>I'm not sure what you mean by careful crafting when all you have >>to do is wrap a [raw] context around the text variable value. >>There's nothing in this simple task that I would consider careful >>crafting any more than any other common webdna coding task.>>>>Also, you seem to be suggesting that the function solution can >>perform 'recursively' but the text variable solution cannot. I >>have to disagree with this. I have never seen a situation in which >>the text variable solution does not work recursively. Do you have >>an example that you can post to the list so we can see what you're >>talking about here?>>>>My conclusion is that the text variable solution does the exact >>same thing as the function solution -- and it works in v4 and v5 -- >>unlike the function solution which works ONLY in v5.>>>>Oh, and if there is any question as to the use of the text variable >>solution in multiple pages, it is a simple task to put the code >>into an include file -- so it can be included in *any* webdna >>template on the same server.>>>>Furthermore the text variable solution can be used on multiple >>webdna servers -- by using tcpconnect to retrieve the template that >>has the text variable code in it, and then interpreting that code >>inside the local webdna template on the local server.>>>>>>>Yes, the text variable method is a useful technique, but takes >>>careful crafting. I also have used similar techniques for years, >>>but the new [function] context makes it sooo much easier, >>>especially when you get more complex with the reusable code >>>blocks, and when you want to do something recursive. It's worth >>>the price of admission for me.>>>>>>- brian>>>>>>On Thursday, May 29, 2003, at 10:18 AM, Kenneth Grome wrote:>>>>>>>>As a related comment, using WebDNA 5 I find myself more often >>>>>using [function]s where I used to use [include]s to handle >>>>>recurring tasks. The formal use of parameters, the local scope >>>>>variables, and the ability to define functions within the page >>>>>itself as well as in a shared include file are compelling >>>>>features.>>>>>>>>>>As a simple example:>>>>>>>>>>[function name=MyLink]>>>>>[return]>>>>db=....&value=[thevalue]&returnfield=ID]>[lookup >>>>>db=....&value=[thevalue]&returnfield=title]
[/return]>>>>>[/function]>>>>>>>>>>[search ...]>>>>>[founditems]>>>>>[MyLink thevalue=[whatever]]>>>>>[/founditems]>>>>>[/search]>>>>>>>>>>- brian>>>>>>>>>>>>I've been doing something similar for years, without v5's function context:>>>>>>>>[text]myLink=[raw]>>>db=....&value=[thevalue]&returnfield=ID]>[lookup >>>>db=....&value=[thevalue]&returnfield=title]
[/raw][/text]>>>>>>>>[search ...]>>>>[founditems]>>>>[myLink]>>>>[/founditems]>>>>[/search]>>>>>>>>This has always been an easy way to create a variable once at the >>>>top of the page, and then use it any number of times further down >>>>on the same page -- while preventing the webdna code inside the >>>>text variable from being interpreted until the variable tag is >>>>used further down on the page -- such as inside the founditems >>>>context in this example.>>>>-->>>>>>>>Sincerely,>>>>Kenneth Grome>>>------------------------------------------------------------->This message is sent to you because you are subscribed to> the mailing list .>To unsubscribe, E-mail to: >To switch to the DIGEST mode, E-mail to >>Web Archive of this list is at: http://webdna.smithmicro.com/-- Sincerely,Kenneth Grome-------------------------------------------------------------My programmers will write WebDNA code for you at $27 an hour!--------------------------------------------------------------------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list .To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/
Kenneth Grome
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:
How does the Globals folder work? (2000)
Logic Help Needed (2003)
Help formatting search results w/ table (1997)
taxRate is fine but taxTotal isn't (1997)
Date search - yes or no (1997)
Help name our technology! I found it (1997)
Smith Micro SUPPORT? (2000)
Parsing args without ? (2003)
MySQL TIME_FORMAT (2005)
Ads.db (1997)
[purchase] (1999)
Many $WebCat.exe processes (1998)
WebCat2 several catalogs? (1997)
Showif, Hideif reverse logic ? (1997)
WebCat2b13 Mac plugin - [sendmail] and checkboxes (1997)
F3 crashing server (1997)
WebCat2 - Getting to the browser's username/password data (1997)
WebCatalog2 Feature Feedback (1996)
Simple way to create unique SKU (1997)
Multiple download orders of the same product? (1997)