Forms-Dynamic
WikiSh can be used to generate "dynamic forms". These forms are built on the fly based on the data found in pages or other sources.
For instance this link was a form designed for my book club. It allowed users to vote on their 7 favorite books, each book being described by PTVs in individual pages. The form is created dynamically based on the existence of any pages that matched a particular pattern. The users 7 votes were saved into another page which was unique for each user.
Reading the code for dynamic forms requires significant comfort with the concept that a variable can contain the name of another variable and so on.
Thus if I have a variable ${a1} which contains "Hello, World" and I have another variable ${q} which contains the number 1 then ${a${q}} evaluates to ${a1} and then to "Hello, World".
If that paragraph above didn't make sense to you then look at it again (and again) until it makes perfect sense, because this concept will be used extensively in this script and in ways which are a lot more complicated than that simple example...
(This page needs a LOT more explanation.)
Here is the script which corresponds to the "live" form mentioned above:
(:linebreaks:) {(wikish_form quickform process)} {(wikish source {$FullName}#Validate)} {(wikish source {$FullName}#MakeForm)} (:messages:) (:if false:) [[#MakeForm]] # Note that MakeForm actually creates 1 of 2 forms, depending on our current state. If we already have a ${name} (from the URL or POST) then we # create a form consisting of all books and the opportunity to vote. If we don't yet have a ${name} then we require the user to enter a name. if test -z ${name} then echo "Enter Your Name: (:input text name:) ''(Please be sure you enter your name exactly the same if you go back in to change your vote.)''" echo '(:input submit proceed "Proceed to Voting":)' else # Here's the main form. echo "VOTING INSTRUCTIONS:\n* You may vote for only 7 books total" echo "* You may vote HIGH for no more than 3 books, MEDIUM for no more than 3 books, and LOW for no more than 3 books." echo "** (obviously for at least one of HIGH, MEDIUM, LOW you will vote less than 3 times)" echo "** Weight: LOW=3, MEDIUM=4, HIGH=5" echo "* [[Results|View results HERE]]" echo "* Voting more than once simply changes (updates) your previous vote ... as long as you entered your name in the exact same way" echo "(:table border=1:)\n" set -s votepage = `makepagename "Votes-${name}"` # This is where this user's votes are stored # book-pages have a pagename that starts with a 0 in this current group for pn in 0* do set -s p = ${pn#*.} if test -n ${proceed} && test -n {${votepage}$:vote${p}} then echo "(:input default vote${p} {${votepage}$:vote${p}}:)" fi echo "(:cellnr rowspan=2 valign=center width=100px:)(:input radio vote${p} 0:)No Vote" echo "(:input radio vote${p} 1:)Low" echo "(:input radio vote${p} 2:)Medium" echo "(:input radio vote${p} 3:)High" echo "(:cell:)[[${pn}|[+'''''{${pn}$:booktitle}''''' by {${pn}$:bookauthor}+]]] " echo "(:cellnr:){${pn}$:description} " done echo "(:table end:)\n(:input submit savevote Vote:)" echo "(:input hidden name:)" echo "(:input end:)" fi [[#MakeFormEnd]] [[#Validate]] if test -z ${savevote} then exit fi for pn in 0* do set -s p = ${pn#*.} #echo "vote${p} = ${vote${p}}" if test ${vote${p}} > 0 then #echo "Processing..." set count ++ set total += ${vote${p}} set total${vote${p}} ++ fi done set err = 0 #echo "count=${count}, total=${total}, total1=${total1}, total2=${total2}, total3=${total3}" if test ${count} > 7 then echo "%red%ERROR: You can vote for only 7 books. You voted for ${count} books.%%" set err ++ fi if test ${total3} > 3 then echo "%red%ERROR: You can vote HIGH for a maximum of 3 books. You voted HIGH for ${total3} books." set err ++ fi if test ${total2} > 3 then echo "%red%ERROR: You can vote MEDIUM for a maximum of 3 books. You voted MEDIUM for ${total2} books." set err ++ fi if test ${total1} > 3 then echo "%red%ERROR: You can vote LOW for a maximum of 3 books. You voted LOW for ${total1} books.%%" set err ++ fi if test ${err} > 0 then echo "%red%YOUR VOTES WERE NOT SAVED! Please correct the errors and try again.%%" exit fi set -s votepage = `makepagename "Votes-${name}"` echo "" >${votepage} for i in ${!vote00*} do if test ${${i}} > 0 then echo "(:${i}:${${i}}:)" >>${votepage} #echo "Saved..${i}=${${i}}...to ${votepage}" fi done echo "%green%Saved... (${count} votes, ${total3} HIGH, ${total2} MEDIUM, and ${total1} LOW)%%" [[#ValidateEnd]] (:ifend:)