diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-03-10 13:57:09 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-03-10 13:57:09 -0400 |
commit | 4f9024019d78bebec6926d19da0361587c88bd03 (patch) | |
tree | 3e522006804b15893b7382c24a5f0806e36f3579 | |
parent | b3bfa064636a8507e0fe83779791dbbee6f15c38 (diff) |
Increment demo
-rw-r--r-- | demo/increment.ur | 10 | ||||
-rw-r--r-- | demo/increment.urp | 4 | ||||
-rw-r--r-- | demo/increment.urs | 1 | ||||
-rw-r--r-- | demo/prose | 4 | ||||
-rw-r--r-- | include/urweb.h | 6 |
5 files changed, 22 insertions, 3 deletions
diff --git a/demo/increment.ur b/demo/increment.ur new file mode 100644 index 00000000..a74e80df --- /dev/null +++ b/demo/increment.ur @@ -0,0 +1,10 @@ +sequence seq + +fun increment () = nextval seq + +fun main () = + src <- source 0; + return <xml><body> + <dyn signal={n <- signal src; return <xml>{[n]}</xml>}/> + <button value="Update" onclick={n <- increment (); set src n}/> + </body></xml> diff --git a/demo/increment.urp b/demo/increment.urp new file mode 100644 index 00000000..777a6edd --- /dev/null +++ b/demo/increment.urp @@ -0,0 +1,4 @@ +database dbname=test +sql increment.sql + +increment diff --git a/demo/increment.urs b/demo/increment.urs new file mode 100644 index 00000000..6ac44e0b --- /dev/null +++ b/demo/increment.urs @@ -0,0 +1 @@ +val main : unit -> transaction page @@ -205,3 +205,7 @@ listEdit.urp <p>The central data structure is the <tt>rlist</tt>, a list whose individual elements are sources, enabling fine-grained mutation. Every rlist is either nil or is a cons cell made up of a source for a string data element, another source to serve as a scratchpad for GUI-based edits to the data element, and a final source that stores the remainder of the list.</p> <p>The main program provides operations to append to a list and to edit the data stored at any cell of the list. Append is implemented by maintaining a source <tt>head</tt>, which points to the first list element; and a source <tt>tailP</tt>, which points to a <tt>source rlist</tt> where we should place the next appended node.</p> + +increment.urp + +<p>Here's an example where client-side code needs to run more code on the server. We maintain a (server-side) SQL sequence. When the user clicks a button, an AJAX request increments the remote sequence and gets the new value.</p> diff --git a/include/urweb.h b/include/urweb.h index 63066e20..676cc84b 100644 --- a/include/urweb.h +++ b/include/urweb.h @@ -79,9 +79,9 @@ uw_Basis_string uw_Basis_unurlifyString(uw_context, char **); uw_Basis_bool uw_Basis_unurlifyBool(uw_context, char **); uw_Basis_time uw_Basis_unurlifyTime(uw_context, char **); -uw_Basis_string uw_Basis_strcat(uw_context, uw_Basis_string, uw_Basis_string); -uw_Basis_string uw_Basis_strdup(uw_context, uw_Basis_string); -uw_Basis_string uw_Basis_maybe_strdup(uw_context, uw_Basis_string); +uw_Basis_string uw_Basis_strcat(uw_context, const char *, const char *); +uw_Basis_string uw_Basis_strdup(uw_context, const char *); +uw_Basis_string uw_Basis_maybe_strdup(uw_context, const char *); uw_Basis_string uw_Basis_sqlifyInt(uw_context, uw_Basis_int); uw_Basis_string uw_Basis_sqlifyFloat(uw_context, uw_Basis_float); |