Forms-Logging

Sometimes when someone fills in a form and presses "submit" you simply want to add a "line" to a "logfile" somewhere. Now the "line" may be in any form you can express in a wiki page (or a text file) and it may actually be many lines (if someone was adding a comment, for instance). The point is that one of the things you like to be able to do with data entered on a form is to output it in some form to a given page (or textfile), either pre-pending it to the beginning of the page or appending it to the end of the page.

Let's say you have a form that looks like this:

Your Name:
Your favorite color:

And in your WikiSh script you have a section that looks like this:

(...uninteresting stuff, including possible validation)
echo "'''${name}''' voted for the color '''${favorite}''' on `ftime`\\" >>Mygroup.Logpage
(uninteresting stuff...)

The only line we are interested in there is the line that begins with echo. This line of code simply outputs a string that looks something like this:

Sam voted for the color chartreuse on December 04, 2024, at 08:26 AM\\

and appends it to the very end of the page Mygroup.Logpage. Thus after several people have voted you might have a page that looks like this:

...
Gertrude voted for the color turquoise on December 03, 2024, at 12:00 AM
Sally voted for the color blue on December 04, 2024, at 07:26 AM
Jack voted for the color red on December 04, 2024, at 08:21 AM
Sam voted for the color chartreuse on December 04, 2024, at 08:26 AM

Sometimes you prefer to put the latest information at the top of the page. This can be done with just a few changes at the end of that echo line:

(...uninteresting stuff, including possible validation)
echo "'''${name}''' voted for the color '''${favorite}''' on `ftime`" >Mygroup.Logpage<_TOP
(uninteresting stuff...)

This says to put that line of data "above the top" of the page Mygroup.Logpage.

There's a great deal of flexibility in placement of text using this ">" operator (called redirection). You can place it before or after or in place of a certain pattern of text, at the beginning or end of a page, etc. For more information you can see this section of the WikiSh documentation.