summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-03-10 13:57:09 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-03-10 13:57:09 -0400
commite9c88084b769bb1af4ec2ffb876c861e01487ba1 (patch)
tree3e522006804b15893b7382c24a5f0806e36f3579
parent8d6dd2b06eb70e446048b50d5995d38fd9de63f9 (diff)
Increment demo
-rw-r--r--demo/increment.ur10
-rw-r--r--demo/increment.urp4
-rw-r--r--demo/increment.urs1
-rw-r--r--demo/prose4
-rw-r--r--include/urweb.h6
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
diff --git a/demo/prose b/demo/prose
index a06b1ce5..7555b490 100644
--- a/demo/prose
+++ b/demo/prose
@@ -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);