How to write a file using WebDNA
numero = 157[math date]{[date]}-{00/07/0000}[/math]will show today's date less 7 days
[math]5/3[/math]will show 1.66666666666667
[math]a=3540/(36+24)[/math]will show "59" and will store it as "a"You can now use [a] in any mathematical operation; it will be replaced by "59"There is a lot to discover with [math].Now let's look at the [writefile] context. This context allows you to create a new file, or page, on your server.
<!--HAS_WEBDNA_TAGS-->[writefile page.txt]Text[/writefile]will create a new file on your server, with name "page.txt" and content "Text". This means you can recover the content of a form and create a hard copy of it on your server. The problem here would be that any new entry would overwrite "page.txt". As already said, there are a number of solutions for every case. In this one, how about adding a time stamp? Something that would show year-month-day-hour-minute-second? here it is:
<!--HAS_WEBDNA_TAGS-->[writefile [date %Y%m%d][time %H%M%S]page.txt]Text[/writefile]Your file will be named 20090412132433page.txtNow, let's imagine your page has to show the day's date.[writefile page.txt]This is today's date: [date][/writefile]Easy enough! But your page.txt is now a static file. It will show the date the page was created. Let's imagine you want to keep it dynamic...First, do not forget the <!--HAS_WEBDNA_TAGS-->:
[writefile page.dna]<!--HAS_WEBDNA_TAGS-->This is today's date: [raw][date][/raw][/writefile]Done! The page will be dynamic: what we did was to add [raw][/raw] on each side of the context we don't want WebDNA to interpret when it writes the file. Instead, it wrote the literal text with brackets, "[date]". Now page.dna includes a dynamic tag that will be interpreted each time WebDNA reads the page, instead of just the creation day's date.
[math date]{[date]}-{00/07/0000}[/math]will show today's date less 7 days
[math]5/3[/math]will show 1.66666666666667
[math]a=3540/(36+24)[/math]will show "59" and will store it as "a"
<!--HAS_WEBDNA_TAGS-->
[writefile page.txt]Text[/writefile]
<!--HAS_WEBDNA_TAGS-->
[writefile [date %Y%m%d][time %H%M%S]page.txt]Text[/writefile]
[writefile page.dna]
<!--HAS_WEBDNA_TAGS-->
This is today's date: [raw][date][/raw]
[/writefile]
DOWNLOAD WEBDNA NOW!
...
7. Searching DatabasesSearching databases with WebDNA and conclusion...
IntroductionA short introduction to WebDNA programming for absolute beginner...
1. Learn WebDNA ProgrammingLearning WebDNA programming: the very basics...
2. Conditional ProgrammingConditional programming with WebDNA...
6. Working with DatabasesWorking with WebDNA database...