Creates a new thread to execute WebDNA simultaneously with the current template.
[spawn]Some Complex WebDNA[/spawn]The HTML output from within a Spawn context is never displayed to the browser. While this may seem unhelpful at first, realize that the purpose of Spawn is to allow you to execute very lengthy operations without forcing the visitor to wait for them. The WebDNA in the spawned context could update a database several minutes later, wait for a 15 second credit card operation, create a WebDelivery file, flush a database to disk or many other useful things.
Before the spawn [elapsedtime]
[spawn]
-- Some WebDNA that takes a long time to finish
[loop start=1&endP00][showif 1=1][/showif][/loop]
[/spawn]
After the spawn [elapsedtime]
the elapsedtime is very small, even though the loop inside the spawn could take several seconds. This is because your web browser sees the results of the template before the spawned WebDNA is finished.
Here are some common mistakes you should avoid:
Incorrect | Correct |
---|---|
[loop start=1&end=10] | [loop start=1&end=10] |
Why | |
Remember spawn might start executing long after the original template that was created has gone away. spawn has no idea what the value of [index] is, because that comes from the outer [loop] context, which really 'belongs' to the now-gone exterior template. The correct method is to create a math variable to hold the [index] value, because spawn does keep a copy of all the math variables in existence when it was created. | |
Incorrect | Correct |
[search blah] | [search blah&max=10] |
Why | |
This is bad for two reasons. Similar to the first example, spawn has no idea what the database field values are, because it is not truly inside the [founditems] context. Second, be very careful you do no create too many spawns -- they can use a lot of memory, and in this case if the [founditems] is more than a dozen or so; web server performance can degrade considerably. The correct example limits the number of spawns, and also uses a text variable to hold the value of the database field. |
Nothing within a SPAWN context will be delivered to the browser, nor will any HTML within the SPAWN be interpreted. SPAWN is intended to run time-consuming server-side tasks (like large database updates) without making the browser wait for it to complete.
[spawn]
[search db=xxx.db&neemaildatarq=[blank]]
[founditems]
[text]wffSuccess=no[/text]
[waitforfile thisFileWillNeverExist.txt][/waitforfile]
[showif [wffSuccess]=no]
[sendmail from=xxx@xxx.xxx&to=[email]&subject=not spam]
Blah blah blah ...
[/sendmail]
[text]wffSuccess=yes[/text]
[/showif]
[/founditems]
[/search]
[/spawn]
DOWNLOAD WEBDNA NOW!
A compilation of some user's questions...
Download WebDNA ApplicationsWebDNA applications...
[biotype]BioType is a behavioral biometrics WebDNA function based on ADGS research and development (from version 8...
WebDNA ModulesA list of the currently available modules...
AWS Raw WebDNA LAMP-Plus WebServerAmazon Web Services (AWS) README for Machine Image ID...
WebDNA referenceA list of all WebDNA instructions...
Lists all the text and/or math variables which have been set earlier on a page...
[closedatabase][CLOSEDATABASE db=FileName]...
[deletefolder]Deletes a folder from your website...
[tcpconnect]A powerful feature to connect to a TCP port of another computer on the Internet...
[createfolder]Create an empty folder on your webspace...
[url][url]...