A B C D E F G H I J L M N O P R S T U V W
All Classes All Packages
All Classes All Packages
All Classes All Packages
S
- sent - Variable in class com.cyberfront.crdt.sample.simulation.SimCRDTManager
-
List of operations and the associated metadata this SimCRDTManager sent
- setAbbreviated(boolean) - Method in class com.cyberfront.crdt.unittest.AssessmentSupport
-
Set the flag to perform abbreviated testing
- setAbbreviatedFactor(long) - Method in class com.cyberfront.crdt.unittest.AssessmentSupport
-
Set the value of the abbreviation factor for abbreviated testing
- setAssessContentConsistency(boolean) - Method in class com.cyberfront.crdt.unittest.TestSimulation.Simulation
-
Set the flag which determines whether or not to perform content consistency assessments
- setAssessCountConsistency(boolean) - Method in class com.cyberfront.crdt.unittest.TestSimulation.Simulation
-
Set the flag which determines whether or not to perform count consistency assessments
- setAssessOperationCountConsistency(boolean) - Method in class com.cyberfront.crdt.unittest.TestSimulation.Simulation
- setAssessValidity(boolean) - Method in class com.cyberfront.crdt.unittest.TestSimulation.Simulation
-
Set the flag which determines whether or not to perform validity assessments
- setCreateCount(long) - Method in class com.cyberfront.crdt.sample.simulation.Executive
-
Sets the number of create operations the Executive is to perform during the course of the simulation execution
- setCreateCount(long) - Method in class com.cyberfront.crdt.unittest.TestSimulation.Simulation
-
Set the base number of create operations to perform in a given simulation run
- setDeleteCount(long) - Method in class com.cyberfront.crdt.sample.simulation.Executive
-
Sets the number of delete operations the Executive is to perform during the course of the simulation execution
- setDeleteCount(long) - Method in class com.cyberfront.crdt.unittest.TestSimulation.Simulation
-
Set the base number of delete operations to perform in a given simulation run
- setInstanceCount(long) - Method in class com.cyberfront.crdt.unittest.TestData.Clone
-
Set the instance count value to that specified
- setNodeCount(long) - Method in class com.cyberfront.crdt.sample.simulation.Executive
-
Sets the node count.
- setNodeCount(long) - Method in class com.cyberfront.crdt.unittest.TestSimulation.Simulation
-
Set the base number of nodes to manage during a simulation run
- setProbabilityChange(double) - Method in class com.cyberfront.crdt.unittest.TestData.Update
-
Set the probability of change for update operations
- setReadCount(long) - Method in class com.cyberfront.crdt.sample.simulation.Executive
-
Sets the number of read operations the Executive is to perform during the course of the simulation execution
- setReadCount(long) - Method in class com.cyberfront.crdt.unittest.TestSimulation.Simulation
-
Set the base number of read operations to perform in a given simulation run
- setRejectionProbability(double) - Method in class com.cyberfront.crdt.unittest.TestSimulation.Simulation
-
Set the probability of rejecting a PENDING operation
- setRejectProbability(double) - Method in class com.cyberfront.crdt.sample.simulation.Executive
-
Set the probability of rejecting an update or delete operation which occurred at a non-owning node
- setStressed(boolean) - Method in class com.cyberfront.crdt.unittest.AssessmentSupport
-
Set the flag to perform stress testing
- setStressedFactor(long) - Method in class com.cyberfront.crdt.unittest.AssessmentSupport
-
Set the value of the stress testing factor
- setTimestamp(long) - Method in class com.cyberfront.crdt.sample.simulation.MessageRouter
-
Set the current timestamp to the value given
- setTrialCount(long) - Method in class com.cyberfront.crdt.unittest.AssessmentSupport
-
Set the number of trials to perform
- setUpdateCount(long) - Method in class com.cyberfront.crdt.sample.simulation.Executive
-
Sets the number of update operations the Executive is to perform during the course of the simulation execution
- setUpdateCount(long) - Method in class com.cyberfront.crdt.unittest.TestSimulation.Simulation
-
Set the base number of update operations to perform in a given simulation run
- setUpdateProbability(double) - Method in class com.cyberfront.crdt.sample.simulation.Executive
-
Sets the probability of updating an update of a specific field in an object being managed
- setUpdateProbability(double) - Method in class com.cyberfront.crdt.unittest.TestSimulation.Simulation
-
Set the probability of updating a field during an update operation
- SHORT_SEQUENCE_LENGTH - Static variable in class com.cyberfront.crdt.support.Support
-
Length of a short sequence of random words from the word list.
- SHORT_SEQUNCE_LENGTH - Static variable in class com.cyberfront.crdt.support.Support
- SimCRDTManager<T extends AbstractDataType> - Class in com.cyberfront.crdt.sample.simulation
-
The Class SimCRDTManager is used to manage a Plain Old Java Object (POJO).
- SimCRDTManager(UUID, UUID, UUID, Class<T>) - Constructor for class com.cyberfront.crdt.sample.simulation.SimCRDTManager
-
Instantiates a new CRDT manager.
- SimOperationManager<T extends AbstractDataType> - Class in com.cyberfront.crdt.sample.simulation
-
The SimOperationManager class wraps JSON operations with some management code to ensure proper delivery and processing of the operations specifically tailored for the simulation test harness.
- SimOperationManager(OperationManager.StatusType, Operation, UUID, Class<T>) - Constructor for class com.cyberfront.crdt.sample.simulation.SimOperationManager
-
Instantiates a new operation manager.
- SimOperationManager(OperationManager.StatusType, Operation, UUID, UUID, Class<T>) - Constructor for class com.cyberfront.crdt.sample.simulation.SimOperationManager
-
Instantiates a new operation manager.
- SIMPLE_BOOLEAN - com.cyberfront.crdt.sample.data.Factory.DataType
-
Corresponds to com.cyberfront.cmrdt.data.SimpleBoolean
- SIMPLE_COLLECTION - com.cyberfront.crdt.sample.data.Factory.DataType
-
Corresponds to com.cyberfront.cmrdt.data.SimpleCollection
- SIMPLE_DOUBLE - com.cyberfront.crdt.sample.data.Factory.DataType
-
Corresponds to com.cyberfront.cmrdt.data.SimpleDouble
- SIMPLE_INTEGER - com.cyberfront.crdt.sample.data.Factory.DataType
-
Corresponds to com.cyberfront.cmrdt.data.SimpleInteger
- SIMPLE_REFERENCE - com.cyberfront.crdt.sample.data.Factory.DataType
-
Corresponds to com.cyberfront.cmrdt.data.SimpleReference
- SIMPLE_STRING - com.cyberfront.crdt.sample.data.Factory.DataType
-
Corresponds to com.cyberfront.cmrdt.data.SimpleString
- SimpleBoolean - Class in com.cyberfront.crdt.sample.data
-
This is a concrete class type derived from AbstractDataType used to test the CRDT.
- SimpleBoolean() - Constructor for class com.cyberfront.crdt.sample.data.SimpleBoolean
-
Instantiates a new SimpleBoolean instance with random values.
- SimpleBoolean(SimpleBoolean) - Constructor for class com.cyberfront.crdt.sample.data.SimpleBoolean
-
Copy constructor which uses `src` as the source content for the new instance
- SimpleBoolean(SimpleBoolean, double) - Constructor for class com.cyberfront.crdt.sample.data.SimpleBoolean
-
Copy constructor which uses `src` as the source content for the new instance
- SimpleBoolean(UUID, Long, String, Boolean) - Constructor for class com.cyberfront.crdt.sample.data.SimpleBoolean
-
Constructor used to fully specify the elements of the SimpleBoolean instance
- SimpleCollection - Class in com.cyberfront.crdt.sample.data
-
This is a concrete class type derived from AbstractDataType used to test the CRDT.
- SimpleCollection() - Constructor for class com.cyberfront.crdt.sample.data.SimpleCollection
-
Instantiates a new SimpleCollection instance with a collection of random objects derived from AbstractDataType.
- SimpleCollection(SimpleCollection) - Constructor for class com.cyberfront.crdt.sample.data.SimpleCollection
-
Copy constructor which uses `src` as the source content for the new instance
- SimpleCollection(SimpleCollection, double) - Constructor for class com.cyberfront.crdt.sample.data.SimpleCollection
-
Copy constructor which uses `src` as the source content for the new instance
- SimpleCollection(UUID, Long, String, Collection<AbstractDataType>) - Constructor for class com.cyberfront.crdt.sample.data.SimpleCollection
-
Constructor used to fully specify the elements of the SimpleCollection instance
- SimpleDouble - Class in com.cyberfront.crdt.sample.data
-
This is a concrete class type derived from AbstractDataType used to test the CRDT.
- SimpleDouble() - Constructor for class com.cyberfront.crdt.sample.data.SimpleDouble
-
Instantiates a new SimpleDouble instance with random values.
- SimpleDouble(SimpleDouble) - Constructor for class com.cyberfront.crdt.sample.data.SimpleDouble
-
Copy constructor which uses `src` as the source content for the new instance
- SimpleDouble(SimpleDouble, double) - Constructor for class com.cyberfront.crdt.sample.data.SimpleDouble
-
Copy constructor which uses `src` as the source content for the new instance
- SimpleDouble(UUID, Long, String, Double) - Constructor for class com.cyberfront.crdt.sample.data.SimpleDouble
-
Constructor used to fully specify the elements of the SimpleDouble instance
- SimpleInteger - Class in com.cyberfront.crdt.sample.data
-
This is a concrete class type derived from AbstractDataType used to test the CRDT.
- SimpleInteger() - Constructor for class com.cyberfront.crdt.sample.data.SimpleInteger
-
Instantiates a new SimpleInteger instance with random values.
- SimpleInteger(SimpleInteger) - Constructor for class com.cyberfront.crdt.sample.data.SimpleInteger
-
Copy constructor which uses `src` as the source content for the new instance
- SimpleInteger(SimpleInteger, double) - Constructor for class com.cyberfront.crdt.sample.data.SimpleInteger
-
Copy constructor which uses `src` as the source content for the new instance
- SimpleInteger(UUID, Long, String, Integer) - Constructor for class com.cyberfront.crdt.sample.data.SimpleInteger
-
Constructor used to fully specify the elements of the SimpleInteger instance
- SimpleReference - Class in com.cyberfront.crdt.sample.data
-
This is a concrete class type derived from AbstractDataType used to test the CRDT.
- SimpleReference() - Constructor for class com.cyberfront.crdt.sample.data.SimpleReference
-
Instantiates a new SimpleReference instance with a collection of random objects derived from AbstractDataType.
- SimpleReference(SimpleReference) - Constructor for class com.cyberfront.crdt.sample.data.SimpleReference
-
Copy constructor which uses `src` as the source content for the new instance
- SimpleReference(SimpleReference, double) - Constructor for class com.cyberfront.crdt.sample.data.SimpleReference
-
Copy constructor which uses `src` as the source content for the new instance
- SimpleReference(UUID, Long, String, AbstractDataType) - Constructor for class com.cyberfront.crdt.sample.data.SimpleReference
-
Constructor used to fully specify the elements of the SimpleReference instance
- SimpleString - Class in com.cyberfront.crdt.sample.data
-
This is a concrete class type derived from AbstractDataType used to test the CRDT.
- SimpleString() - Constructor for class com.cyberfront.crdt.sample.data.SimpleString
-
Instantiates a new SimpleString instance with random values.
- SimpleString(SimpleString) - Constructor for class com.cyberfront.crdt.sample.data.SimpleString
-
Copy constructor which uses `src` as the source content for the new instance
- SimpleString(SimpleString, double) - Constructor for class com.cyberfront.crdt.sample.data.SimpleString
-
Copy constructor which uses `src` as the source content for the new instance
- SimpleString(UUID, Long, String, String) - Constructor for class com.cyberfront.crdt.sample.data.SimpleString
-
Constructor used to fully specify the elements of the SimpleString instance
- Simulation() - Constructor for class com.cyberfront.crdt.unittest.TestSimulation.Simulation
-
Default constructor which sets all of the fields to the defaults values specified in the corresponding constant values.
- Simulation(long, long, long, long, long, double, double, long, long, long, boolean, boolean, boolean, boolean, boolean, boolean) - Constructor for class com.cyberfront.crdt.unittest.TestSimulation.Simulation
-
Constructor to explicitly set all of the fields to the values given in the constructor arguments below
- srcNodeId - Variable in class com.cyberfront.crdt.sample.simulation.Message
-
The source node identifier
- STATE_COUNT - Static variable in class com.cyberfront.crdt.unittest.TestCrdt.Generic
-
Constant defining the number of states to use in the testing
- STATE_COUNT - Static variable in class com.cyberfront.crdt.unittest.TestCrdt.Json
-
Constant defining the number of states to use in the testing
- stateCount - Variable in class com.cyberfront.crdt.unittest.TestCrdt.Generic
-
Number of states to prepare for the testing suite
- stateCount - Variable in class com.cyberfront.crdt.unittest.TestCrdt.Json
-
Number of states to prepare for the testing suite
- status - Variable in class com.cyberfront.crdt.operation.OperationManager
-
The status associated with the op.
- STATUS - Static variable in class com.cyberfront.crdt.operation.OperationManager
-
JSON property name for the status type property for a given manager
- StatusType() - Constructor for enum com.cyberfront.crdt.operation.OperationManager.StatusType
- stressed - Variable in class com.cyberfront.crdt.unittest.AssessmentSupport
-
Flag indicating whether the unit test derived from this class are to be stressed
- STRESSED - Static variable in class com.cyberfront.crdt.unittest.AssessmentSupport
-
Flag used to indicate whether or not to perform a stress test
- STRESSED_FACTOR - Static variable in class com.cyberfront.crdt.unittest.AssessmentSupport
-
Factor to apply during stress tests
- stressedFactor - Variable in class com.cyberfront.crdt.unittest.AssessmentSupport
-
Factor used to enhance the various counts when attempting to test under higher stress levels
- stringValue - Variable in class com.cyberfront.crdt.sample.data.SimpleString
-
The String stringValue associated with the SimpleString type
- Support - Class in com.cyberfront.crdt.support
-
This is a helper class for generating a number of random values useful for testing the CRDTs
- Support() - Constructor for class com.cyberfront.crdt.support.Support
All Classes All Packages


1)
Harry made a snowman in his backyard.
2)
My grandparents visited us on Saturday.
3)
The seven ducklings followed their mother.
4)
Becky painted a beautiful picture.
5)
Aunt Jane cut her finger yesterday.
6)
I kissed my baby brother.
7)
The rat nibbled on the block of cheese.
8)
Ron accidentally stamped on the cat’s tail.


(c) Software Lab. Alexander Burger, Mattias Sundblad
This document presents an introduction to writing browser-based applications in PicoLisp.
It concentrates on the XHTML/CSS GUI-Framework (as opposed to the previous Java-AWT, Java-Swing and Plain-HTML frameworks), which is easier to use, more flexible in layout design, and does not depend on plug-ins, JavaScript, cookies or CSS.
A plain HTTP/HTML GUI has various advantages: It runs on any browser, and can be fully driven by scripts ("@lib/scrape.l").
To be precise: CSS can be used to enhance the layout. And browsers with JavaScript will respond faster and smoother. But this framework works just fine in browsers which do not know anything about CSS or JavaScript. All examples were also tested using the w3m text browser.
For basic informations about the PicoLisp system please look at the PicoLisp Reference and the PicoLisp Tutorial. Knowledge of HTML, and a bit of CSS and HTTP is assumed.
The examples assume that PicoLisp was started from a global installation (see Installation).
You can use PicoLisp to generate static HTML pages. This does not make much sense in itself, because you could directly write HTML code as well, but it forms the base for interactive applications, and allows us to introduce the application server and other fundamental concepts.
To begin with a minimal application, please enter the following two lines into a generic source file named "project.l" in the PicoLisp installation directory.
########################################################################
(html 0 "Hello"<EMAIL_ADDRESS>NIL
"Hello World!" )
########################################################################
(We will modify and use this file in all following examples and experiments. Whenever you find such a program snippet between hash ('#') lines, just copy and paste it into your "project.l" file, and press the "reload" button of your browser to view the effects)
Open a second terminal window, and start a PicoLisp application server
$ pil @lib/http.l @lib/xhtml.l @lib/form.l --server 8080 project.l +
No prompt appears. The server just sits, and waits for connections. You can
stop it later by hitting Ctrl-C
in that terminal, or by executing
'killall pil
' in some other window.
(In the following, we assume that this HTTP server is up and running)
Now open the URL 'http://localhost:8080
' with your
browser. You should see an empty page with a single line of text.
The above line loads the debugger (via the '+' switch), the HTTP server code ("@lib/http.l"), the XHTML functions<EMAIL_ADDRESS>and the input form framework<EMAIL_ADDRESS>it will be needed later for interactive forms).
Then the -server
function is called (a front-end to
server
) with a port number and a default URL. It will listen on
that port for incoming HTTP requests in an endless loop. Whenever a GET request
arrives on port 8080, the file "project.l" will be (load)
ed, causing the evaluation (= execution)
of all its Lisp expressions.
During that execution, all data written to the current output channel is sent directly to the browser. The code in "project.l" is responsible to produce HTML (or anything else the browser can understand).
The PicoLisp application server uses a slightly specialized syntax when communicating URLs to and from a client. The "path" part of an URL - which remains when
(load)
ed. This
is the most common case, and we use it in our example "project.l".
*Mimes
, the file is sent to the client with mime-type and
max-age values taken from that table.
An application is free to extend or modify the *Mimes
table with
the mime
function. For example
(mime "doc" "application/msword" 60)
defines a new mime type with a max-age of one minute.
Argument values in URLs, following the path and the question mark, are encoded in such a way that Lisp data types are preserved:
In that way, high-level data types can be directly passed to functions encoded in the URL, or assigned to global variables before a file is loaded.
It is, of course, a huge security hole that - directly from the URL - any
Lisp source file can be loaded, and any Lisp function can be called. For that
reason, applications must take care to declare exactly which files and functions
are to be allowed in URLs. The server checks a global variable *Allow
, and - when its value is
non-NIL
- denies access to anything that does not match its
contents.
Normally, *Allow
is not manipulated directly, but set with the
allowed
and allow
functions
(allowed ("app/")
"!start" "!stop"<EMAIL_ADDRESS>"!psh" )
This is usually called at the beginning of an application, and allows access to the directory "app/", to the functions 'start', 'stop' and 'psh', and to the file<EMAIL_ADDRESS>Later in the program, *Allow
may be dynamically extended with
allow
(allow "!foo")
(allow "newdir/" T)
This adds the function 'foo', and the directory "newdir/", to the set of allowed items.
For a variety of security checks (most notably for using the psh
function, as in some later examples) it is necessary to create a file named
".pw" in the PicoLisp installation directory. This file should contain a single
line of arbitrary data, to be used as a password for identifying local
resources.
The recommeded way to create this file is to call the pw
function, defined in<EMAIL_ADDRESS>$ pil @lib/http.l -'pw 12' -bye
Please execute this command.
html
FunctionNow back to our "Hello World" example. In principle, you could write "project.l" as a sequence of print statements
########################################################################
(prinl "HTTP/1.0 200 OK^M")
(prinl "Content-Type: text/html; charset=utf-8")
(prinl "^M")
(prinl "")
(prinl "Hello World!")
(prinl "")
########################################################################
but using the html
function is much more convenient.
Moreover, html
is nothing more than a printing function.
You can see this easily if you connect a PicoLisp Shell (psh
) to
the server process (you must have generated a ".pw" file for
this), and enter the html
statement
$ /usr/lib/picolisp/bin/psh 8080
: (html 0 "Hello"<EMAIL_ADDRESS>NIL "Hello World!")
HTTP/1.0 200 OK
Server: PicoLisp
Date: Fri, 29 Dec 2006 07:28:58 GMT
Cache-Control: max-age=0
Cache-Control: no-cache
Content-Type: text/html; charset=utf-8
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<title>Hello</title>
<base href="http://localhost:8080/"/>
<link rel="stylesheet" type="text/css"<EMAIL_ADDRESS>
Hello World!

->
: # (type Ctrl-D here to terminate PicoLisp)
These are the arguments to html
:
0
: A max-age value for cache-control (in seconds, zero means
"no-cache"). You might pass a higher value for pages that change seldom, or
NIL
for no cache-control at all.
"Hello"
: The page title.
<EMAIL_ADDRESS>: A CSS-File name. Pass NIL
if you do
not want to use any CSS-File, or a list of file names if you want to give more
than one CSS-File.
NIL
: A CSS style attribute specification (see the description
of CSS Attributes below). It will be passed to the
body
tag.
After these four arguments, an arbitrary number of expressions may follow. They form the body of the resulting page, and are evaluated according to a special rule. This rule is slightly different from the evaluation of normal Lisp expressions:
Therefore, our source file might as well be written as:
########################################################################
(html 0 "Hello"<EMAIL_ADDRESS>NIL
(prinl "Hello World!") )
########################################################################
The most typical print statements will be some HTML-tags:
########################################################################
(html 0 "Hello"<EMAIL_ADDRESS>NIL
(
 NIL "Hello World!")
(
 "This is some text.")
(ht:Prin "And this is a number: " (+ 1 2 3)) )
########################################################################

and

are tag functions.

takes a CSS attribute as its first argument.
Note the use of ht:Prin
instead of prin
.
ht:Prin
should be used for all direct printing in HTML pages,
because it takes care to escape special characters.
The html
function above, and many of the
HTML tag functions, accept a CSS attribute specification.
This may be either an atom, a cons pair, or a list of cons pairs. We demonstrate
the effects with the

tag function.
An atom (usually a symbol or a string) is taken as a CSS class name
: (
 'foo "Title")

Title

For a cons pair, the CAR is taken as an attribute name, and the CDR as the attribute's value
: (
 '(id . bar) "Title")

Title

Consequently, a list of cons pairs gives a set of attribute-value pairs
: (
 '((id . "abc") (lang . "de")) "Title")

Title

All pre-defined XHTML tag functions can be found in<EMAIL_ADDRESS>We recommend to look at their sources, and to experiment a bit, by executing them at a PicoLisp prompt, or by pressing the browser's "Reload" button after editing the "project.l" file.
For a suitable PicoLisp prompt, either execute (in a separate terminal
window) the PicoLisp Shell (psh
) command (works only if the
application server is running, and you did generate a ".pw"
file)
$ /usr/lib/picolisp/bin/psh 8080
:
or start the interpreter stand-alone, with<EMAIL_ADDRESS>loaded
$ pil @lib/http.l @lib/xhtml.l +
:
Note that for all these tag functions the above tag body evaluation rule applies.
Most tag functions are simple and straightforward. Some of them just print their arguments
: (
 "Hello world")
Hello world

: ( "Hello world")
Hello world
while most of them take a CSS attribute specification
as their first argument (like the

tag above)
: (
 'main "Hello world")

Hello world

: (
 NIL "Hello world")

Hello world

: (
 'info "Hello world")

Hello world

All of these functions take an arbitrary number of arguments, and may nest to an arbitrary depth (as long as the resulting HTML is legal)
: (
 'main
(
 NIL "Head")
(
 NIL
(
 "Line 1")
"Line"
(<nbsp>)
(+ 1 1) ) )

Head

Line 1

Line 2

HTML-lists, implemented by the

and

tags, let you define hierarchical structures. You might
want to paste the following code into your copy of "project.l":
########################################################################
(html 0 "Unordered List"<EMAIL_ADDRESS>NIL
(
 NIL
(
 NIL "Item 1")
(
 NIL
"Sublist 1"
(
 NIL
(
 NIL "Item 1-1")
(
 NIL "Item 1-2") ) )
(
 NIL "Item 2")
(
 NIL
"Sublist 2"
(
 NIL
(
 NIL "Item 2-1")
(
 NIL "Item 2-2") ) )
(
 NIL "Item 3") ) )
########################################################################
Here, too, you can put arbitrary code into each node of that tree, including other tag functions.
Like the hierarchical structures with the list functions, you can generate
two-dimensional tables with the

and
<row>
functions.
The following example prints a table of numbers and their squares:
########################################################################
(html 0 "Table"<EMAIL_ADDRESS>NIL
(
 NIL NIL NIL
(for N 10 # A table with 10 rows
(<row> NIL N (prin (* N N))) ) ) ) # and 2 columns
########################################################################
The first argument to

is the usual CSS attribute,
the second an optional title ("caption"), and the third an optional list
specifying the column headers. In that list, you may supply a list for a each
column, with a CSS attribute in its CAR, and a tag body in its CDR for the
contents of the column header.
The body of

contains calls to the
<row>
function. This function is special in that each
expression in its body will go to a separate column of the table. If both for
the column header and the row function an CSS attribute is given, they will be
combined by a space and passed to the HTML
tag. This
permits distinct CSS specifications for each column and row.
As an extension of the above table example, let's pass some attributes for
the table itself (not recommended - better define such styles in a CSS file and
then just pass the class name to

), right-align both
columns, and print each row in an alternating red and blue color
########################################################################
(html 0 "Table"<EMAIL_ADDRESS>NIL
(

'((width . "200px") (style . "border: dotted 1px;")) # table style
"Square Numbers" # caption
'((align "Number") (align "Square")) # 2 headers
(for N 10 # 10 rows
(<row> (xchg '(red) '(blue)) # red or blue
N # 2 columns
(prin (* N N) ) ) ) ) )
########################################################################
If you wish to concatenate two or more cells in a table, so that a single
cell spans several columns, you can pass the symbol '-
' for the
additional cell data to <row>
. This will cause the data given
to the left of the '-
' symbols to expand to the right.
You can also directly specify table structures with the simple

,

and
tag
functions.
If you just need a two-dimensional arrangement of components, the even
simpler <grid>
function might be convenient:
########################################################################
(html 0 "Grid"<EMAIL_ADDRESS>NIL
(<grid> 3
"A" "B" "C"
123 456 789 ) )
########################################################################
It just takes a specification for the number of columns (here: 3) as its first argument, and then a single expression for each cell. Instead of a number, you can also pass a list of CSS attributes. Then the length of that list will determine the number of columns. You can change the second line in the above example to
(<grid> '(NIL NIL right)
Then the third column will be right aligned.
The two most powerful tag functions are <menu>
and
<tab>
. Used separately or in combination, they form a
navigation framework with
The following example is not very useful, because the URLs of all items link to the same "project.l" page, but it should suffice to demonstrate the functionality:
########################################################################
(html 0 "Menu+Tab"<EMAIL_ADDRESS>NIL
(
 '(id . menu)
(<menu>
("Item" "project.l") # Top level item
(NIL (
)) # Plain HTML
(T "Submenu 1" # Submenu
("Subitem 1.1" "project.l")
(T "Submenu 1.2"
("Subitem 1.2.1" "project.l")
("Subitem 1.2.2" "project.l")
("Subitem 1.2.3" "project.l") )
("Subitem 1.3" "project.l") )
(T "Submenu 2"
("Subitem 2.1" "project.l")
("Subitem 2.2" "project.l") ) ) )
(
 '(id . main)
(
 NIL "Menu+Tab")
(<tab>
("Tab1"
(
 NIL "This is Tab 1") )
("Tab2"
(
 NIL "This is Tab 2") )
("Tab3"
(
 NIL "This is Tab 3") ) ) ) )
########################################################################
<menu>
takes a sequence of menu items. Each menu item is a
list, with its CAR either
NIL
: The entry is not an active menu item, and the rest of the
list may consist of arbitrary code (usually HTML tags).
T
: The second element is taken as a submenu name, and a click
on that name will open or close the corresponding submenu. The rest of the list
recursively specifies the submenu items (may nest to arbitrary depth).
<tab>
takes a list of subpages. Each page is simply a tab
name, followed by arbitrary code (typically HTML tags).
Note that only a single menu and a single tab may be active at the same time.
In HTML, the only possibility for user input is via <form>
and <input>
elements, using the HTTP POST method to
communicate with the server.
<EMAIL_ADDRESS>defines a function called <post>
, and a
collection of input tag functions, which allow direct programming of HTML forms.
We will supply only one simple example:
########################################################################
(html 0 "Simple Form"<EMAIL_ADDRESS>NIL
(<post> NIL "project.l"
(<field> 10 '*Text)
(<submit> "Save") ) )
########################################################################
This associates a text input field with a global variable *Text
.
The field displays the current value of *Text
, and pressing the
submit button causes a reload of "project.l" with *Text
set to any
string entered by the user.
An application program could then use that variable to do something useful, for example store its value in a database.
The problem with such a straightforward use of forms is that
<hidden>
tags.
Though we wrote a few applications in that style, we recommend the GUI framework provided by<EMAIL_ADDRESS>It does not need any variables for the client/server communication, but implements a class hierarchy of GUI components for the abstraction of application logic, button actions and data linkage.
First of all, we need to establish a persistent environment on the server, to handle each individual session (for each connected client).
Technically, this is just a child process of the server we started above, which does not terminate immediately after it sent its
page to the browser. It is achieved by calling the app
function
somewhere in the application's startup code.
########################################################################
(app) # Start a session
(html 0 "Simple Session"<EMAIL_ADDRESS>NIL
(<post> NIL "project.l"
(<field> 10 '*Text)
(<submit> "Save") ) )
########################################################################
Nothing else changed from the previous example. However, when you connect your browser and then look at the terminal window where you started the application server, you'll notice a colon, the PicoLisp prompt
$ pil @lib/http.l @lib/xhtml.l @lib/form.l --server 8080 project.l +
:
Tools like the Unix ps
utility will tell you that now two
picolisp
processes are running, the first being the parent of the
second.
If you enter some text, say "abcdef", into the text field in the browser
window, press the submit button, and inspect the Lisp *Text
variable,
: *Text
-> "abcdef"
you see that we now have a dedicated PicoLisp process, "connected" to the client.
You can terminate this process (like any interactive PicoLisp) by hitting
Ctrl-D
on an empty line. Otherwise, it will terminate by itself if
no other browser requests arrive within a default timeout period of 5 minutes.
To start a (non-debug) production version, the server is commonly started
without the '+' flag, and with -wait
$ pil @lib/http.l @lib/xhtml.l @lib/form.l --server 8080 project.l -wait
In that way, no command line prompt appears when a client connects.
Now that we have a persistent session for each client, we can set up an active GUI framework.
This is done by wrapping the call to the html
function with
action
. Inside the body of html
can be - in addition
to all other kinds of tag functions - one or more calls to form
########################################################################
(app) # Start session
(action # Action handler
(html 0 "Form"<EMAIL_ADDRESS>NIL # HTTP/HTML protocol
(form NIL # Form
(gui 'a '(+TextField) 10) # Text Field
(gui '(+Button) "Print" # Button
'(msg (val> (: home a))) ) ) ) )
########################################################################
Note that there is no longer a global variable like *Text
to
hold the contents of the input field. Instead, we gave a local, symbolic name
'a
' to a +TextField
component
(gui 'a '(+TextField) 10) # Text Field
Other components can refer to it
'(msg (val> (: home a)))
(: home)
is always the form which contains this GUI component.
So (: home a)
evaluates to the component 'a
' in the
current form. As msg
prints its
argument to standard error, and the val>
method retrieves the
current contents of a component, we will see on the console the text typed into
the text field when we press the button.
An action
without embedded form
s - or a
form
without a surrounding action
- does not make much
sense by itself. Inside html
and form
, however, calls
to HTML functions (and any other Lisp functions, for that matter) can be freely
mixed.
In general, a typical page may have the form
(action # Action handler
(html .. # HTTP/HTML protocol
(
 ..) # HTML tags
(form NIL # Form
(
 ..)
(gui ..) # GUI component(s)
(gui ..)
.. )
(
 ..)
(form NIL # Another form
(
 ..)
(gui ..) # GUI component(s)
.. )
(
 ..)
.. ) )
gui
FunctionThe most prominent function in a form
body is gui
.
It is the workhorse of GUI construction.
Outside of a form
body, gui
is undefined.
Otherwise, it takes an optional alias name, a list of classes, and additional
arguments as needed by the constructors of these classes. We saw this example
before
(gui 'a '(+TextField) 10) # Text Field
Here, 'a
' is an alias name for a component of type
(+TextField)
. The numeric argument 10
is passed to the
text field, specifying its width. See the chapter on GUI
Classes for more examples.
During a GET request, gui
is basically a front-end to
new
. It builds a component, stores it in the internal structures of
the current form, and initializes it by sending the init>
message to the component. Finally, it sends it the show>
message, to produce HTML code and transmit it to the browser.
During a POST request, gui
does not build any new components.
Instead, the existing components are re-used. So gui
does not have
much more to do than sending the show>
message to a component.
HTTP has only two methods to change a browser window: GET and POST. We employ these two methods in a certain defined, specialized way:
A button's action code can do almost anything: Read and modify the contents of input fields, communicate with the database, display alerts and dialogs, or even fake the POST request to a GET, with the effect of showing a completely different document (See Switching URLs).
GET builds up all GUI components on the server. These components are objects
which encapsulate state and behavior of the HTML page in the browser. Whenever a
button is pressed, the page is reloaded via a POST request. Then - before any
output is sent to the browser - the action
function takes control.
It performs error checks on all components, processes possible user input on the
HTML page, and stores the values in correct format (text, number, date, object
etc.) in each component.
The state of a form is preserved over time. When the user returns to a previous page with the browser's BACK button, that state is reactivated, and may be POSTed again.
The following silly example displays two text fields. If you enter some text into the "Source" field, you can copy it in upper or lower case to the "Destination" field by pressing one of the buttons
########################################################################
(app)
(action
(html 0 "Case Conversion"<EMAIL_ADDRESS>NIL
(form NIL
(<grid> 2
"Source" (gui 'src '(+TextField) 30)
"Destination" (gui 'dst '(+Lock +TextField) 30) )
(gui '(+JS +Button) "Upper Case"
'(set> (: home dst)
(uppc (val> (: home src))) ) )
(gui '(+JS +Button) "Lower Case"
'(set> (: home dst)
(lowc (val> (: home src))) ) ) ) ) )
########################################################################
The +Lock
prefix class in the
"Destination" field makes that field read-only. The only way to get some text
into that field is by using one of the buttons.
Because an action code runs before html
has a chance to output
an HTTP header, it can abort the current page and present something different to
the user. This might, of course, be another HTML page, but would not be very
interesting as a normal link would suffice. Instead, it can cause the download
of dynamically generated data.
The next example shows a text area and two buttons. Any text entered into the text area is exported either as a text file via the first button, or a PDF document via the second button
########################################################################
(load<EMAIL_ADDRESS>(app)
(action
(html 0 "Export"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+TextField) 30 8)
(gui '(+Button) "Text"
'(let Txt (tmp "export.txt")
(out Txt (prinl (val> (: home gui 1))))
(url Txt) ) )
(gui '(+Button) "PDF"
'(psOut NIL "foo"
(a4)
(indent 40 40)
(down 60)
(hline 3)
(font (14 . "Times-Roman")
(ps (val> (: home gui 1))) )
(hline 3)
(page) ) ) ) ) )
########################################################################
(a text area is built when you supply two numeric arguments (columns and
rows) to a +TextField
class)
The action code of the first button
creates a temporary file (i.e. a file named "export.txt" in the current
process's temporary space), prints the value of the text area (this time we did
not bother to give it a name, we simply refer to it as the form's first gui list
element) into that file, and then calls the url
function with the file name.
The second button uses the PostScript library<EMAIL_ADDRESS>to create a
temporary file "foo.pdf". Here, the temporary file creation and the call to the
url
function is hidden in the internal mechanisms of
psOut
. The effect is that the browser receives a PDF document and
displays it.
Alerts and dialogs are not really what they used to be ;-)
They do not "pop up". In this framework, they are just a kind of simple-to-use, pre-fabricated form. They can be invoked by a button's action code, and appear always on the current page, immediately preceding the form which created them.
Let's look at an example which uses two alerts and a dialog. In the beginning, it displays a simple form, with a locked text field, and two buttons
########################################################################
(app)
(action
(html 0 "Alerts and Dialogs"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+Init +Lock +TextField) "Initial Text" 20 "My Text")
(gui '(+Button) "Alert"
'(alert NIL "This is an alert " (okButton)) )
(gui '(+Button) "Dialog"
'(dialog NIL
(
 "This is a dialog.")
(

"You can change the text here "
(gui '(+Init +TextField) (val> (: top 1 gui 1)) 20) )
(
 "and then re-submit it to the form.")
(gui '(+Button) "Re-Submit"
'(alert NIL "Are you sure? "
(yesButton
'(set> (: home top 2 gui 1)
(val> (: home top 1 gui 1)) ) )
(noButton) ) )
(cancelButton) ) ) ) ) )
########################################################################
The +Init
prefix class
initializes the "My Text" field with the string "Initial Text". As the field is
locked, you cannot modify this value directly.
The first button brings up an alert saying "This is an alert.". You can dispose it by pressing "OK".
The second button brings up a dialog with an editable text field, containing a copy of the value from the form's locked text field. You can modify this value, and send it back to the form, if you press "Re-Submit" and answer "Yes" to the "Are you sure?" alert.
Now let's forget our "project.l" test file for a moment, and move on to a more substantial and practical, stand-alone, example. Using what we have learned so far, we want to build a simple bignum calculator. ("bignum" because PicoLisp can do only bignums)
It uses a single form, a single numeric input field, and lots of buttons. It can be found in the PicoLisp distribution (e.g. under "/usr/share/picolisp/") in "misc/calc.l", together with a directly executable wrapper script "misc/calc".
To use it, change to the PicoLisp installation directory, and start it as
$ misc/calc
or call it with an absolute path, e.g.
$ /usr/share/picolisp/misc/calc
If you like to get a PicoLisp prompt for inspection, start it instead as
$ pil misc/calc.l -main -go +
Then - as before - point your browser to 'http://localhost:8080
'.
The code for the calculator logic and the GUI is rather straightforward. The
entry point is the single function calculator
. It is called
directly (as described in URL Syntax) as the server's
default URL, and implicitly in all POST requests. No further file access is
needed once the calculator is running.
Note that for a production application, we inserted an allow-statement (as recommended by the Security chapter)
(allowed NIL "!calculator"<EMAIL_ADDRESS>at the beginning of "misc/calc.l". This will restrict external access to that single function.
The calculator uses three global variables, *Init
,
*Accu
and *Stack
. *Init
is a boolean flag
set by the operator buttons to indicate that the next digit should initialize
the accumulator to zero. *Accu
is the accumulator. It is always
displayed in the numeric input field, accepts user input, and it holds the
results of calculations. *Stack
is a push-down stack, holding
postponed calculations (operators, priorities and intermediate results) with
lower-priority operators, while calculations with higher-priority operators are
performed.
The function digit
is called by the digit buttons, and adds
another digit to the accumulator.
The function calc
does an actual calculation step. It pops the
stack, checks for division by zero, and displays an error alert if necessary.
operand
processes an operand button, accepting a function and a
priority as arguments. It compares the priority with that in the top-of-stack
element, and delays the calculation if it is less.
finish
is used to calculate the final result.
The calculator
function has one numeric input field, with a
width of 60 characters
(gui '(+Var +NumField) '*Accu 60)
The +Var
prefix class
associates this field with the global variable *Accu
. All changes
to the field will show up in that variable, and modification of that variable's
value will appear in the field.
The square root operator button has an
+Able
prefix class
(gui '(+Able +JS +Button) '(ge0 *Accu) (char 8730)
'(setq *Accu (sqrt *Accu)) )
with an argument expression which checks that the current value in the accumulator is positive, and disables the button if otherwise.
The rest of the form is just an array (grid) of buttons, encapsulating all
functionality of the calculator. The user can enter numbers into the input
field, either by using the digit buttons, or by directly typing them in, and
perform calculations with the operator buttons. Supported operations are
addition, subtraction, multiplication, division, sign inversion, square root and
power (all in bignum integer arithmetic). The 'C
' button just
clears the accumulator, while the 'A
' button also clears all
pending calculations.
All that in 53 lines of code!
Charts are virtual components, maintaining the internal representation of two-dimensional data.
Typically, these data are nested lists, database selections, or some kind of dynamically generated tabular information. Charts make it possible to view them in rows and columns (usually in HTML tables), scroll up and down, and associate them with their corresponding visible GUI components.
In fact, the logic to handle charts makes up a substantial part of the whole framework, with large impact on all internal mechanisms. Each GUI component must know whether it is part of a chart or not, to be able to handle its contents properly during updates and user interactions.
Let's assume we want to collect textual and numerical data. We might create a table
########################################################################
(app)
(action
(html 0 "Table"<EMAIL_ADDRESS>NIL
(form NIL
(
 NIL NIL '((NIL "Text") (NIL "Number"))
(do 4
(<row> NIL
(gui '(+TextField) 20)
(gui '(+NumField) 10) ) ) )
(<submit> "Save") ) ) )
########################################################################
with two columns "Text" and "Number", and four rows, each containing a
+TextField
and a +NumField
.
You can enter text into the first column, and numbers into the second. Pressing the "Save" button stores these values in the components on the server (or produces an error message if a string in the second column is not a legal number).
There are two problems with this solution:
: (val> (get *Top 'gui 2)) # Value in the first row, second column
-> 123
there is no direct way to get the whole data structure as a single list.
Instead, you have to traverse all GUI components and collect the data.
A chart can handle these things:
########################################################################
(app)
(action
(html 0 "Chart"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+Chart) 2) # Inserted a +Chart
(
 NIL NIL '((NIL "Text") (NIL "Number"))
(do 4
(<row> NIL
(gui 1 '(+TextField) 20) # Inserted '1'
(gui 2 '(+NumField) 10) ) ) ) # Inserted '2'
(<submit> "Save") ) ) )
########################################################################
Note that we inserted a +Chart
component before the GUI
components which should be managed by the chart. The argument '2' tells the
chart that it has to expect two columns.
Each component got an index number (here '1' and '2') as the first argument
to gui
, indicating the column into which this component should go
within the chart.
Now - if you entered "a", "b" and "c" into the first, and 1, 2, and 3 into
the second column - we can retrieve the chart's complete contents by sending it
the val>
message
: (val> (get *Top 'chart 1)) # Retrieve the value of the first chart
-> (("a" 1) ("b" 2) ("c" 3))
BTW, a more convenient function is chart
: (val> (chart)) # Retrieve the value of the current chart
-> (("a" 1) ("b" 2) ("c" 3))
chart
can be used instead of
the above construct when we want to access the "current" chart, i.e. the chart
most recently processed in the current form.
To enable scrolling, let's also insert two buttons. We use the pre-defined
classes +UpButton
and
+DnButton
########################################################################
(app)
(action
(html 0 "Scrollable Chart"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+Chart) 2)
(
 NIL NIL '((NIL "Text") (NIL "Number"))
(do 4
(<row> NIL
(gui 1 '(+TextField) 20)
(gui 2 '(+NumField) 10) ) ) )
(gui '(+UpButton) 1) # Inserted two buttons
(gui '(+DnButton) 1)
(----)
(<submit> "Save") ) ) )
########################################################################
to scroll down and up a single (argument '1') line at a time.
Now it is possible to enter a few rows of data, scroll down, and continue. It is not necessary (except in the beginning, when the scroll buttons are still disabled) to press the "Save" button, because any button in the form will send changes to the server's internal structures before any action is performed.
As we said, a chart is a virtual component to edit two-dimensional data. Therefore, a chart's native data format is a list of lists: Each sublist represents a single row of data, and each element of a row corresponds to a single GUI component.
In the example above, we saw a row like
("a" 1)
being mapped to
(gui 1 '(+TextField) 20)
(gui 2 '(+NumField) 10)
Quite often, however, such a one-to-one relationship is not desired. The internal data structures may have to be presented in a different form to the user, and user input may need conversion to an internal representation.
For that, a chart accepts - in addition to the "number of columns" argument - two optional function arguments. The first function is invoked to 'put' the internal representation into the GUI components, and the second to 'get' data from the GUI into the internal representation.
A typical example is a chart displaying customers in a database. While the internal representation is a (one-dimensional) list of customer objects, 'put' expands each object to a list with, say, the customer's first and second name, telephone number, address and so on. When the user enters a customer's name, 'get' locates the matching object in the database and stores it in the internal representation. In the following, 'put' will in turn expand it to the GUI.
For now, let's stick with a simpler example: A chart that holds just a list of numbers, but expands in the GUI to show also a textual form of each number (in German).
########################################################################
(app)
(load<EMAIL_ADDRESS>(action
(html 0 "Numerals"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+Init +Chart) (1 5 7) 2
'((N) (list N (zahlwort N)))
car )
(
 NIL NIL '((NIL "Numeral") (NIL "German"))
(do 4
(<row> NIL
(gui 1 '(+NumField) 9)
(gui 2 '(+Lock +TextField) 90) ) ) )
(gui '(+UpButton) 1)
(gui '(+DnButton) 1)
(----)
(<submit> "Save") ) ) )
########################################################################
<EMAIL_ADDRESS>defines the utility function zahlwort
, which
is required later by the 'put' function. zahlwort
accepts a number
and returns its wording in German.
Now look at the code
(gui '(+Init +Chart) (1 5 7) 2
'((N) (list N (zahlwort N)))
car )
We prefix the +Chart
class
with +Init
, and pass it a list
of numbers (1 5 7)
for the initial value of the chart. Then,
following the '2' (the chart has two columns), we pass a 'put' function
'((N) (list N (zahlwort N)))
which takes a number and returns a list of that number and its wording, and a 'get' function
car )
which in turn accepts such a list and returns a number, which happens to be the list's first element.
You can see from this example that 'get' is the inverse function of 'put'. 'get' can be omitted, however, if the chart is read-only (contains no (or only locked) input fields).
The field in the second column
(gui 2 '(+Lock +TextField) 90) ) ) )
is locked, because it displays the text generated by 'put', and is not supposed to accept any user input.
When you start up this form in your browser, you'll see three pre-filled
lines with "1/eins", "5/fünf" and "7/sieben", according to the +Init
argument (1 5 7)
.
Typing a number somewhere into the first column, and pressing ENTER or one of
the buttons, will show a suitable text in the second column.
In previous chapters we saw examples of GUI classes like +TextField
, +NumField
or +Button
, often in combination with
prefix classes like +Lock
,
+Init
or +Able
. Now we take a broader look at the
whole hierarchy, and try more examples.
The abstract class +gui
is the base of all GUI classes. A live
view of the class hierarchy can be obtained with the dep
("dependencies") function:
: (dep '+gui)
+gui
+Img
+field
+Radio
+TextField
+UpField
+PwField
+BlobField
+FileField
+TimeField
+DateField
+MailField
+AtomField
+HttpField
+LinesField
+ClassField
+TelField
+numField
+NumField
+FixField
+SymField
+SexField
+ListTextField
+Checkbox
+Button
+BubbleButton
+DelRowButton
+DnButton
+GoButton
+UpButton
+ChoButton
+Choice
+ClrButton
+PickButton
+DstButton
+todoButton
+RedoButton
+UndoButton
+ShowButton
+JsField
-> +gui
We see, for example, that +DnButton
is a subclass of +Button
, which in turn is a subclass of
+gui
. Inspecting +DnButton
directly
: (dep '+DnButton)
+Tiny
+Rid
+JS
+Able
+gui
+Button
+DnButton
-> +DnButton
shows that +DnButton
inherits from +Tiny
, +Rid
, +Able
and +Button
. The actual definition of
+DnButton
can be found in
<EMAIL_ADDRESS>(class +DnButton +Tiny +Rid +JS +Able +Button)
...
In general<EMAIL_ADDRESS>is the ultimate reference to the framework, and should be freely consulted. See also the form library reference.
Input fields implement the visual display of application data, and allow - when enabled - input and modification of these data.
On the HTML level, they can take the form of
Except for checkboxes, which are implemented by the Checkbox class, all these HTML representations are
generated by +TextField
and
its content-specific subclasses like +NumField
, +DateField
etc. Their actual
appearance (as one of the above forms) depends on their arguments:
We saw already "normal" text fields. They are created with a single numeric argument. This example creates an editable field with a width of 10 characters:
(gui '(+TextField) 10)
If you supply a second numeric for the line count ('4' in this case), you'll get a text area:
(gui '(+TextField) 10 4)
Supplying a list of values instead of a count yields a drop-down selection (combo box):
(gui '(+TextField) '("Value 1" "Value 2" "Value 3"))
In addition to these arguments, you can pass a string. Then the field is created with a label:
(gui '(+TextField) 10 "Plain")
(gui '(+TextField) 10 4 "Text Area")
(gui '(+TextField) '("Value 1" "Value 2" "Value 3") "Selection")
Finally, without any arguments, the field will appear as a plain HTML text:
(gui '(+TextField))
This makes mainly sense in combination with prefix classes like +Var
and +Obj
, to manage the contents of these
fields, and achieve special behavior as HTML links or scrollable chart values.
A +NumField
returns a
number from its val>
method, and accepts a number for its
set>
method. It issues an error message when user input cannot
be converted to a number.
Large numbers are shown with a thousands-separator, as determined by the current locale.
########################################################################
(app)
(action
(html 0 "+NumField"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+NumField) 10)
(gui '(+JS +Button) "Print value"
'(msg (val> (: home gui 1))) )
(gui '(+JS +Button) "Set to 123"
'(set> (: home gui 1) 123) ) ) ) )
########################################################################
A +FixField
needs an
additional scale factor argument, and accepts/returns scaled fixpoint numbers.
The decimal separator is determined by the current locale.
########################################################################
(app)
(action
(html 0 "+FixField"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+FixField) 3 10)
(gui '(+JS +Button) "Print value"
'(msg (format (val> (: home gui 1)) 3)) )
(gui '(+JS +Button) "Set to 123.456"
'(set> (: home gui 1) 123456) ) ) ) )
########################################################################
A +DateField
accepts and
returns a date
value.
########################################################################
(app)
(action
(html 0 "+DateField"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+DateField) 10)
(gui '(+JS +Button) "Print value"
'(msg (datStr (val> (: home gui 1)))) )
(gui '(+JS +Button) "Set to \"today\""
'(set> (: home gui 1) (date)) ) ) ) )
########################################################################
The format displayed to - and entered by - the user depends on the current
locale (see datStr
and expDat
). You can change it, for example to
: (locale "DE" "de")
-> NIL
If no locale is set, the format is YYYY-MM-DD. Some pre-defined locales use patterns like DD.MM.YYYY (DE), YYYY/MM/DD (JP), DD/MM/YYYY (UK), or MM/DD/YYYY (US).
An error is issued when user input does not match the current locale's date format.
Independent from the locale setting, a +DateField
tries to expand
abbreviated input from the user. A small number is taken as that day of the
current month, larger numbers expand to day and month, or to day, month and
year:
Similar is the +TimeField
. It accepts and returns a time
value.
########################################################################
(app)
(action
(html 0 "+TimeField"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+TimeField) 8)
(gui '(+JS +Button) "Print value"
'(msg (tim$ (val> (: home gui 1)))) )
(gui '(+JS +Button) "Set to \"now\""
'(set> (: home gui 1) (time)) ) ) ) )
########################################################################
When the field width is '8', like in this example, time is displayed in the
format HH:MM:SS
. Another possible value would be '5', causing
+TimeField
to display its value as HH:MM
.
An error is issued when user input cannot be converted to a time value.
The user may omit the colons. If he inputs just a small number, it should be between '0' and '23', and will be taken as a full hour. '125' expands to "12:05", '124517' to "12:45:17", and so on.
Telephone numbers are represented internally by the country code (without a
leading plus sign or zero) followed by the local phone number (ideally separated
by spaces) and the phone extension (ideally separated by a hyphen). The exact
format of the phone number string is not enforced by the GUI, but further
processing (e.g. database searches) normally uses fold
for better reproducibility.
To display a phone number, +TelField
replaces the country code
with a single zero if it is the country code of the current locale, or prepends
it with a plus sign if it is a foreign country (see telStr
).
For user input, a plus sign or a double zero is simply dropped, while a
single leading zero is replaced with the current locale's country code (see
expTel
).
########################################################################
(app)
(locale "DE" "de")
(action
(html 0 "+TelField"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+TelField) 20)
(gui '(+JS +Button) "Print value"
'(msg (val> (: home gui 1))) )
(gui '(+JS +Button) "Set to \"49 1234 5678-0\""
'(set> (: home gui 1) "49 1234 5678-0") ) ) ) )
########################################################################
A +Checkbox
is
straightforward. User interaction is restricted to clicking it on and off. It
accepts boolean (NIL
or non-NIL
) values, and returns
T
or NIL
.
########################################################################
(app)
(action
(html 0 "+Checkbox"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+Checkbox))
(gui '(+JS +Button) "Print value"
'(msg (val> (: home gui 1))) )
(gui '(+JS +Button) "On"
'(set> (: home gui 1) T) )
(gui '(+JS +Button) "Off"
'(set> (: home gui 1) NIL) ) ) ) )
########################################################################
A big part of this framework's power is owed to the combinatorial flexibility of prefix classes for GUI- and DB-objects. They allow to surgically override individual methods in the inheritance tree, and can be combined in various ways to achieve any desired behavior.
Technically, there is nothing special about prefix classes. They are just normal classes. They are called "prefix" because they are intended to be written before other classes in a class's or object's list of superclasses.
Usually they take their own arguments for their T
method from
the list of arguments to the gui
function.
+Init
overrides the
init>
method for that component. The init>
message is sent to a +gui
component when the page is loaded for the
first time (during a GET request). +Init
takes an expression for the initial
value of that field.
(gui '(+Init +TextField) "This is the initial text" 30)
Other classes which automatically give a value to a field are +Var
(linking the field to a variable) and
+E/R
(linking the field to a
database entity/relation).
+Cue
can be used, for example
in "mandatory" fields, to give a hint to the user about what he is supposed to
enter. It will display the argument value, in angular brackets, if and only if
the field's value is NIL
, and the val>
method will
return NIL
despite the fact that this value is displayed.
Cause an empty field to display "<Please enter some text here>":
(gui '(+Cue +TextField) "Please enter some text here" 30)
An important feature of an interactive GUI is the context-sensitive disabling and enabling of individual components, or of a whole form.
The +Able
prefix class takes
an argument expression, and disables the component if this expression returns
NIL
. We saw an example for its usage already in the square root button of the calculator example. Or, for
illustration purposes, imagine a button which is supposed to be enabled only
after Christmas
(gui '(+Able +Button)
'(>= (cdr (date (date))) (12 24))
"Close this year"
'(endOfYearProcessing) )
or a password field that is disabled as long as somebody is logged in
(gui '(+Able +PwField) '(not *Login) 10 "Password")
A special case is the +Lock
prefix, which permanently and unconditionally disables a component. It takes no
arguments
(gui '(+Lock +NumField) 10 "Count")
('10' and "Count" are for the +NumField
), and creates a read-only
field.
The whole form can be disabled by calling disable
with a non-NIL
argument. This affects all components in this form. Staying with the above
example, we can make the form read-only until Christmas
(form NIL
(disable (> (12 24) (cdr (date (date))))) # Disable whole form
(gui ..)
.. )
Even in a completely disabled form, however, it is often necessary to
re-enable certain components, as they are needed for navigation, scrolling, or
other activities which don't affect the contents of the form. This is done by
prefixing these fields with +Rid
(i.e. getting "rid" of the lock).
(form NIL
(disable (> (12 24) (cdr (date (date)))))
(gui ..)
..
(gui '(+Rid +Button) ..) # Button is enabled despite the disabled form
.. )
GUI prefix classes allow a fine-grained control of how values are stored in -
and retrieved from - components. As in predefined classes like +NumField
or +DateField
, they override the
set>
and/or val>
methods.
+Set
takes an argument
function which is called whenever that field is set to some value. To convert
all user input to upper case
(gui '(+Set +TextField) uppc 30)
+Val
is the complement to
+Set
. It takes a function which
is called whenever the field's value is retrieved. To return the square of a
field's value
(gui '(+Val +NumField) '((N) (* N N)) 10)
+Fmt
is just a combination of
+Set
and +Val
, and takes two functional arguments.
This example will display upper case characters, while returning lower case
characters internally
(gui '(+Fmt +TextField) uppc lowc 30)
+Map
does (like +Fmt
) a two-way translation. It uses a
list of cons pairs for a linear lookup, where the CARs represent the displayed
values which are internally mapped to the values in the CDRs. If a value is not
found in this list during set>
or val>
, it is
passed through unchanged.
Normally, +Map
is used in
combination with the combo box incarnation of text fields (see Input Fields). This example displays "One", "Two" and
"Three" to the user, but returns a number 1, 2 or 3 internally
########################################################################
(app)
(action
(html 0 "+Map"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+Map +TextField)
'(("One" . 1) ("Two" . 2) ("Three" . 3))
'("One" "Two" "Three") )
(gui '(+Button) "Print"
'(msg (val> (field -1))) ) ) ) )
########################################################################
Whenever a button is pressed in the GUI, any changes caused by action
in the current environment (e.g.
the database or application state) need to be reflected in the corresponding GUI
fields. For that, the upd>
message is sent to all components.
Each component then takes appropriate measures (e.g. refresh from database
objects, load values from variables, or calculate a new value) to update its
value.
While the upd>
method is mainly used internally, it can be
overridden in existing classes via the +Upd
prefix class. Let's print updated
values to standard error
########################################################################
(app)
(default *Number 0)
(action
(html 0 "+Upd"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+Upd +Var +NumField)
'(prog (extra) (msg *Number))
'*Number 8 )
(gui '(+JS +Button) "Increment"
'(inc '*Number) ) ) ) )
########################################################################
To allow automatic validation of user input, the chk>
message
is sent to all components at appropriate times. The corresponding method should
return NIL
if the value is all right, or a string describing the
error otherwise.
Many of the built-in classes have a chk>
method. The +NumField
class checks for legal
numeric input, or the +DateField
for a valid calendar
date.
An on-the-fly check can be implemented with the +Chk
prefix class. The following code only
accepts numbers not bigger than 9: The or
expression first
delegates the check to the main +NumField
class, and - if it does not
give an error - returns an error string when the current value is greater than
9.
########################################################################
(app)
(action
(html 0 "+Chk"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+Chk +NumField)
'(or
(extra)
(and (> (val> This) 9) "Number too big") )
12 )
(gui '(+JS +Button) "Print"
'(msg (val> (field -1))) ) ) ) )
########################################################################
A more direct kind of validation is built-in via the +Limit
class. It controls the
maxlength
attribute of the generated HTML input field component.
Thus, it is impossible to type more characters than allowed into the field.
########################################################################
(app)
(action
(html 0 "+Limit"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+Limit +TextField) 4 8)
(gui '(+JS +Button) "Print"
'(msg (val> (field -1))) ) ) ) )
########################################################################
Although set>
and val>
are the official
methods to get a value in and out of a GUI component, they are not very often
used explicitly. Instead, components are directly linked to internal Lisp data
structures, which are usually either variables or database objects.
The +Var
prefix class takes a
variable (described as the var
data type - either a symbol or a
cons pair - in the Function Reference). In the
following example, we initialize a global variable with the value "abc", and let
a +TextField
operate on it.
The "Print" button can be used to display its current value.
########################################################################
(app)
(setq *TextVariable "abc")
(action
(html 0 "+Var"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+Var +TextField) '*TextVariable 8)
(gui '(+JS +Button) "Print"
'(msg *TextVariable) ) ) ) )
########################################################################
+E/R
takes an entity/relation
specification. This is a cons pair, with a relation in its CAR (e.g.
nm
, for an object's name), and an expression in its CDR (typically
(: home obj)
, the object stored in the obj
property of
the current form).
For an isolated, simple example, we create a temporary database, and access
the nr
and nm
properties of an object stored in a
global variable *Obj
.
########################################################################
(when (app) # On start of session
(class +Tst +Entity) # Define data model
(rel nr (+Number)) # with a number
(rel nm (+String)) # and a string
(pool (tmp "db")) # Create temporary DB
(setq *Obj # and a single object
(new! '(+Tst) 'nr 1 'nm "New Object") ) )
(action
(html 0 "+E/R"<EMAIL_ADDRESS>NIL
(form NIL
(gui '(+E/R +NumField) '(nr . *Obj) 8) # Linkage to 'nr'
(gui '(+E/R +TextField) '(nm . *Obj) 20) # Linkage to 'nm'
(gui '(+JS +Button) "Show" # Show the object
'(out 2 (show *Obj)) ) ) ) ) # on standard error
########################################################################
Buttons are, as explained in Control Flow, the only way (via POST requests) for an application to communicate with the server.
Basically, a +Button
takes
Here is a minimal button, with just a label and an expression:
(gui '(+Button) "Label" '(doSomething))
And this is a button displaying different labels, depending on the state:
(gui '(+Button) "Enabled" "Disabled" '(doSomething))
To show an image instead of plain text, the label(s) must be preceeded by the
T
symbol:
(gui '(+Button) T "img/enabled.png" "img/disabled.png" '(doSomething))
The expression will be executed during action
handling (see Action Forms), when this button was pressed.
Like other components, buttons can be extended and combined with prefix classes, and a variety of predefined classes and class combinations are available.
Buttons are essential for the handling of alerts and dialogs. Besides buttons for normal functions, like scrolling in charts or other side effects, special buttons exist which can close an alert or dialog in addition to doing their principal job.
Such buttons are usually subclasses of +Close
, and most of them can be called
easily with ready-made functions like closeButton
, cancelButton
, yesButton
or noButton
. We saw a few examples in Alerts and Dialogs.
When a button inherits from the +JS
class (and JavaScript is enabled in the
browser), that button will possibly show a much faster response in its action.
The reason is that the activation of a +JS
button will - instead of doing a normal
POST - first try to send only the contents of all GUI components via an
XMLHttpRequest to the server, and receive the updated values in response. This
avoids the flicker caused by reloading and rendering of the whole page, is much
faster, and also does not jump to the beginning of the page if it is larger than
the browser window. The effect is especially noticeable while scrolling in
charts.
Only if this fails, for example because an error message was issued, or a dialog popped up, it will fall back, and the form will be POSTed in the normal way.
Thus it makes no sense to use the +JS
prefix for buttons that cause a change
of the HTML code, open a dialog, or jump to another page. In such cases, overall
performance will even be worse, because the XMLHttpRequest is tried first (but
in vain).
When JavaScript is disabled int the browser, the XMLHttpRequest will not be tried at all. The form will be fully usable, though, with identical functionality and behavior, just a bit slower and not so smooth.
The PicoLisp release includes in the "app/" directory a minimal, yet complete reference application. This application is typical, in the sense that it implements many of the techniques described in this document, and it can be easily modified and extended. In fact, we use it as templates for our own production application development.
It is a kind of simplified ERP system, containing customers/suppliers, products (items), orders, and other data. The order input form performs live updates of customer and product selections, price, inventory and totals calculations, and generates on-the-fly PDF documents. Fine-grained access permissions are controlled via users, roles and permissions. It comes localized in seven languages (English, Spanish, German, Norwegian, Swedish, Russian and Japanese), with some initial data and two sample reports.
Since this reference application employs so many of the typical techniques used in writing PicoLisp applications, taking the time to study it is time very well invested. Another good way to get acquainted with the language and framework is to start experimenting by writing small applications of your own. Copying and making changes to the reference application is a very good way to get started with this, and I highly recommend doing so.
For a global installation (see Installation), please create a symbolic link to the place where the program files are installed. This is necessary because the application needs read/write access to the current working directory (for the database and other runtime data).
$ ln -s /usr/share/picolisp/app
As ever, you may start up the application in debugging mode
$ pil app/main.l -main -go +
or in (non-debug) production mode
$ pil app/main.l -main -go -wait
and go to 'http://localhost:8080
' with your
browser. You can login as user "admin", with password "admin". The demo data
contain several other users, but those are more restricted in their role
permissions.
Another possibility is to try the online version of this application at app.7fach.de.
Before or after you logged in, you can select another language, and click on the "Change" button. This will effect all GUI components (though not text from the database), and also the numeric, date and telephone number formats.
The navigation menu on the left side shows two items "Home" and "logout", and three submenus "Data", "Report" and "System".
Both "Home" and "logout" bring you back to the initial login form. Use "logout" if you want to switch to another user (say, for another set of permissions), and - more important - before you close your browser, to release possible locks and process resources on the server.
The "Data" submenu gives access to application specific data entry and maintenance: Orders, product items, customers and suppliers. The "Report" submenu contains two simple inventory and sales reports. And the "System" submenu leads to role and user administration.
You can open and close each submenu individually. Keeping more than one submenu open at a time lets you switch rapidly between different parts of the application.
The currently active menu item is indicated by a highlighted list style (no matter whether you arrived at this page directly via the menu or by clicking on a link somewhere else).
Each item in the "Data" or "System" submenu opens a search dialog for that class of entities. You can specify a search pattern, press the top right "Search" button (or just ENTER), and scroll through the list of results.
While the "Role" and "User" entities present simple dialogs (searching just by name), other entities can be searched by a variety of criteria. In those cases, a "Reset" button clears the contents of the whole dialog. A new object can be created with bottom right "New" button.
In any case, the first column will contain either a "@"-link (to jump to that object) or a "@"-button (to insert a reference to that object into the current form).
By default, the search will list all database objects with an attribute value greater than or equal to the search criterion. The comparison is done arithmetically for numbers, and alphabetically (case sensitive!) for text. This means, if you type "Free" in the "City" field of the "Customer/Supplier" dialog, the value of "Freetown" will be matched. On the other hand, an entry of "free" or "town" will yield no hits.
Some search fields, however, show a different behavior depending on the application:
Using the bottom left scroll buttons, you can scroll through the result list without limit.  Be careful here to select the right column: Some dialogs (those for "Item" and "Order") also provide links for related entities (e.g. "Supplier").
A database object is usually displayed in its own individual form, which is determined by its entity class.
The basic layout should be consistent for all classes: Below the heading (which is usually the same as the invoking menu item) is the object's identifier (name, number, etc.), and then a row with an "Edit" button on the left, and "Delete" button, a "Select" button and two navigation links on the right side.
The form is brought up initially in read-only mode. This is necessary to prevent more than one user from modifying an object at the same time (and contrary to the previous PicoLisp Java frameworks, where this was not a problem because all changes were immediately reflected in the GUIs of other users).
So if you want to modify an object, you have to gain exclusive access by clicking on the "Edit" button. The form will be enabled, and the "Edit" button changes to "Done". Should any other user already have reserved this object, you will see a message telling his name and process ID.
An exception to this are objects that were just created with "New". They will automatically be reserved for you, and the "Edit" button will show up as "Done".
The "Delete" button pops up an alert, asking for confirmation. If the object is indeed deleted, this button changes to "Restore" and allows to undelete the object. Note that objects are never completely deleted from the database as long as there are any references from other objects. When a "deleted" object is shown, its identifier appears in square brackets.
The "Select" button (re-)displays the search dialog for this class of entities. The search criteria are preserved between invocations of each dialog, so that you can conveniently browse objects in this context.
The navigation links, pointing left and right, serve a similar purpose. They let you step sequentially through all objects of this class, in the order of the identifier's index.
Other buttons, depending on the entity, are usually arranged at the bottom of the form. The bottom rightmost one should always be another "Edit" / "Done" button.
As we said in the chapter on Scrolling, any button in the form will save changes to the underlying data model. As a special case, however, the "Done" button releases the object and reverts to "Edit". Besides this, the edit mode will also cease as soon as another object is displayed, be it by clicking on an object link (the pencil icon), the top right navigation links, or a link in a search dialog.
The only way to interact with a HTTP-based application server is to click either on a HTML link, or on a submit button (see also Control Flow). It is essential to understand the different effects of such a click on data entered or modified in the current form.
For that reason the layout design should clearly differentiate between links and buttons. Image buttons are not a good idea when in other places images are used for links. The standard button components should be preferred; they are usually rendered by the browser in a non-ambiguous three-dimensional look and feel.
Note that if JavaScript is enabled in the browser, changes will be automatically committed to the server.
The enabled or disabled state of a button is an integral part of the application logic. It must be indicated to the user with appropriate styles.
The data model for this mini application consists of only six entity classes (see the E/R diagram at the beginning of "app/er.l"):
+CuSu
(Customer/Supplier),
+Item
(Product Item) and +Ord
(Order).
+Pos
object is a single position in an order.
+Role
and +User
objects are needed for
authentication and authorization.
The classes +Role
and +User
are defined in
<EMAIL_ADDRESS>A +Role
has a name, a list of permissions, and a list
of users assigned to this role. A +User
has a name, a password and
a role.
In "app/er.l", the +Role
class is extended to define an
url>
method for it. Any object whose class has such a method is
able to display itself in the GUI. In this case, the file "app/role.l" will be
loaded - with the global variable *ID
pointing to it - whenever an
HTML link to this role object is activated.
The +User
class is also extended. In addition to the login name,
a full name, telephone number and email address is declared. And, of course, the
ubiquitous url>
method.
The application logic is centered around orders. An order has a number, a
date, a customer (an instance of +CuSu
) and a list of positions
(+Pos
objects). The sum>
method calculates the
total amount of this order.
Each position has an +Item
object, a price and a quantity. The
price in the position overrides the default price from the item.
Each item has a number, a description, a supplier (also an instance of
+CuSu
), an inventory count (the number of these items that were
counted at the last inventory taking), and a price. The cnt>
method calculates the current stock of this item as the difference of the
inventory and the sold item counts.
The call to dbs
at the end of "app/er.l" configures the physical
database storage. Each of the supplied lists has a number in its CAR which
determines the block size as (64 << N) of the corresponding database file.
The CDR says that the instances of this class (if the element is a class symbol)
or the tree nodes (if the element is a list of a class symbol and a property
name) are to be placed into that file. This allows for some optimizations in the
database layout.
When you are connected to the application (see Getting Started) you might try to do some "real" work with it. Via the "Data" menu (see Navigation) you can create or modify customers, suppliers, items and orders, and produce simple overviews via the "Report" menu.
Source in "app/cusu.l"
The Customer/Supplier search dialog (choCuSu
in "app/gui.l")
supports a lot of search criteria. These become necessary when the database
contains a large number of customers, and can filter by zip, by phone number
prefixes, and so on.
In addition to the basic layout (see Editing), the form is divided into four separate tabs. Splitting a form into several tabs helps to reduce traffic, with possibly better GUI response. In this case, four tabs are perhaps overkill, but ok for demonstration purposes, and they leave room for extensions.
Be aware that when data were modified in one of the tabs, the "Done" button has to be pressed before another tab is clicked, because tabs are implemented as HTML links (see Buttons vs. Links).
New customers or suppliers will automatically be assigned the next free number. You can enter another number, but an error will result if you try to use an existing number. The "Name" field is mandatory, you need to overwrite the "<Name>" clue.
Phone and fax numbers in the "Contact" tab must be entered in the correct format, depending on the locale (see Telephone Numbers).
The "Memo" tab contains a single text area. It is no problem to use it for large pieces of text, as it gets stored in a database blob internally.
The general layout of cusu.l
is quite similar to the other
source files making up the demo application. Since this is such a typical way of
structuring PicoLisp applications, let's have a more detailed look. The
beginning of cusu.l
looks like this:
########################################################################
(must "Customer/Supplier" Customer)
(menu ,"Customer/Supplier"
(idForm ,"Customer/Supplier" '(choCuSu) 'nr '+CuSu T '(may Delete)
'((: nr) " -- " (: nm))
....
########################################################################
The first line checks whether the user has the right permissions to access
this page. After that a call to a function called (menu)
follows.
This function is defined in app/gui.l
and creates the menu and
basic page layout used in this application. Nested within the call to
(menu)
is our first, direct, encounter with a form function. In
this case it is a call to (idForm)
. Let us look a little closer at
this call.
The first parameter, "Customer/Supplier", is used in the form heading.
Parameter number two is interesting. '(choCuSu)
creates a dialog
that makes is possible to search for an existing object to display/ edit, or
create a new one. (choCuSu)
is defined in app/gui.l
and uses another form function, called (diaform)
. An abbreviated version is
shown below.
########################################################################
(de choCuSu (Dst)
(diaform '(Dst)
(<grid> "--.-.-."
# Form components
... )
(gui 'query '(+QueryChart) (cho)
# Pilog query
9
'((This) (list This (: nr) This (: nm2) (: em) (: plz) (: ort) (: tel) (: mob))) )
(
 'chart (choTtl ,"Customers/Suppliers" 'nr '+CuSu)
# Table headers
(do (cho)
(<row> (alternating)
(gui 1 '(+DstButton) Dst)
...
(gui 9 '(+TelField)) ) ) )
(<spread>
(scroll (cho))
(newButton T Dst '(+CuSu) ...)
(cancelButton) ) ) )
########################################################################
(choCuSu)
starts off by calling (diaform)
. This function is used when
we want a form to behave in a similar way to a dialog (See Alerts and Dialogs for a description of how dialogs
work in this framework). The first part of our diaform is a
(<grid>)
containing some form components.
The grid is followed by another gui component, this time a +QueryChart
. The chart is an
interesting, and very useful, concept. The basic idea is to separate how data is
presented in the gui from the internal representation. See charts for more information.
The +QueryChart
uses a
Pilog query to fetch the data we wish to show from
the database. This part is followed by a number, in this case 9, which tells the
Chart how many columns of data to expect. The final part is a function that
takes care of putting data into the gui from the
dataset retrieved by the Pilog query. A table is used to present the result. The
number of columns in this table must match the number mentioned above, the one
that tells the chart how many columns to expect.
What is here is a common way of structuring applications in PicoLisp. Objects
are displayed and edited using (idForm)
, which in turn use (diaform)
to select or create new
objects to view or edit.
Source in "app/item.l"
Items also have a unique number, and a mandatory "Description" field.
To assign a supplier, click on the "+" button. The Customer/Supplier search dialog will appear, and you can pick the desired supplier with the "@" button in the first column. Alternatively, if you are sure to know the exact spelling of the supplier's name, you can also enter it directly into the text field.
In the search dialog you may also click on a link, for example to inspect a possible supplier, and then return to the search dialog with the browser's back button. The "Edit" mode will then be lost, however, as another object has been visited (this is described in the last part of Editing).
You can enter an inventory count, the number of items currently in stock. The following field will automatically reflect the remaining pieces after some of these items were sold (i.e. referenced in order positions). It cannot be changed manually.
The price should be entered with the decimal separator according to the current locale. It will be formatted with two places after the decimal separator.
The "Memo" is for an arbitrary info text, like in Customer/Supplier above, stored in a database blob.
Finally, a JPEG picture can be stored in a blob for this item. Choose a file with the browser's file select control, and click on the "Install" button. The picture will appear at the bottom of the page, and the "Install" button changes to "Uninstall", allowing the picture's removal.
Source in "app/ord.l"
Oders are identified by number and date.
The number must be unique. It is assigned when the order is created, and cannot be changed for compliance reasons.
The date is initialized to "today" for a newly created order, but may be changed manually. The date format depends on the locale. It is YYYY-MM-DD (ISO) by default, DD.MM.YYYY in the German and YYYY/MM/DD in the Japanese locale. As described in Time & Date, this field allows input shortcuts, e.g. just enter the day to get the full date in the current month.
To assign a customer to this order, click on the "+" button. The Customer/Supplier search dialog will appear, and you can pick the desired customer with the "@" button in the first column (or enter the name directly into the text field), just as described above for Items.
Now enter order the positions: Choose an item with the "+" button. The "Price" field will be preset with the item's default price, you may change it manually. Then enter a quantity, and click a button (typically the "+" button to select the next item, or a scroll button go down in the chart). The form will be automatically recalculated to show the total prices for this position and the whole order.
Instead of the "+" or scroll buttons, as recommended above, you could of course also press the "Done" button to commit changes. This is all right, but has the disadvantage that the button must be pressed a second time (now "Edit") if you want to continue with the entry of more positions.
The "x" button at the right of each position deletes that position without further confirmation. It has to be used with care!
The "^" button is a "bubble" button. It exchanges a row with the row above it. Therefore, it can be used to rearrange all items in a chart, by "bubbling" them to their desired positions.
The "PDF-Print" button generates and displays a PDF document for this order. The browser should be configured to display downloaded PDF documents in an appropriate viewer. The source for the postscript generating method is in "app/lib.l". It produces one or several A4 sized pages, depending on the number of positions.
Sources in "app/inventory.l and "app/sales.l"
The two reports ("Inventory" and "Sales") come up with a few search fields and a "Show" button.
If no search criteria are entered, the "Show" button will produce a listing of the relevant part of the whole database. This may take a long time and cause a heavy load on the browser if the database is large.
So in the normal case, you will limit the domain by stating a range of item numbers, a description pattern, and/or a supplier for the inventory report, or a range of order dates and/or a customer for the sales report. If a value in a range specification is omitted, the range is considered open in that direction.
At the end of each report appears a "CSV" link. It downloads a file with the TAB-separated values generated by this report.


I'm a senior computer engineering student studying at Simon Fraser University and I am passionate about solving problems with technology and programming. I picked computer engineering because of the impact software has in our life and the unique problems you can solve with it. I enjoy being challenged, solving new problems, and learning new tools and technologies. In my spare time you can find me training at the gym, honing my photography skills, or improving my programming skills through projects and academia. I'm also into blockchain technology, cryptocurrencies, and its applications, if any of that interests you, feel free to connect with me on LinkedIn!
Specialization option in Computer Engineering, with a focus on software and computer science related topics.
An IOS utility application dedicated towards connecting people suffering from Parkinson's Disease with their caregivers or family members.As one of our main goals we have enabled an easy to use interface for Caregivers and Patients to interact. We provide families an opportunity to check up on their patient’s status, such as a way to provide reminders and track their medication usage, monitor changes in mood, and observe remote location, for both medical and assurance purposes. See Github for more info..
View ProjectA Python script written to learn the fundamentals of web scraping, browser automation, and storing data to files. This program scrapes data from the Nike website and compiles data about a certain product with its associated price, and link to buy the item and outputs it to a spreadsheet.
View ProjectDeveloped using c++ objected oriented programming, utilizing the Huffman tree algorithm to compress and decompress files. See Github repo for more details about the project.
View ProjectProgrammed a real-time bank simulation in c++, that simulates a bank line. It outputs the average wait time and clients processed, given a fixed amount of tellers in a bank with the processing of clients that walk in over time. Utilized queues and priority queues to simulate flow of clients in a bank. Used object oriented programming and data structures to create an event driven simulation
View Project


Preparation time
1-2 hours
Cooking time
30 mins to 1 hour
Serves
Serves 6-8
Dietary
Place the sugar, oil and warm water into a bowl. Add the yeast and gently stir to dissolve the yeast.
Pour the flour into a bowl and make a well in the centre. Gradually add the yeast mixture to the flour, mixing it in with your hands until all the liquid is absorbed. It will be quite lumpy at this stage.
Knead the dough until smooth, then roll into a ball. Put some oil onto your hands and roll the ball around to cover it with oil.
Place the oiled ball of dough into a large floured dish. Cover with a cloth or some cling film and leave in a warm (but not hot) place to rise for one hour. The dough should have risen to three times its original size in this time.
While the dough is rising, make the topping. Preheat the oven to 180C/365F/Gas 4.
Place the whole garlic bulb into a sheet of kitchen foil and drizzle with olive oil. Wrap up the foil around the garlic to create a sealed package and place into the oven to roast for one hour, or until the garlic is cooked and tender.
Remove the garlic from the foil and allow to cool. Transfer to a bowl and add the butter and rosemary. Mash the garlic well and season with salt and freshly ground black pepper.
Rub a pizza pan or baking tray with olive oil.
Roll the dough into one large 2cm/1in thick rectangle. You may bake the loaf like this, or cut the dough into smaller pieces to make individual loaves.
Place the bread onto the oiled pan or tray and prick it all over with a fork.
Spread the roasted garlic and butter mixture over the dough, then leave to prove for 30 minutes.
Preheat the oven to 230C/445F/Gas 8.
Transfer the dough to the oven and bake for 15-20 minutes, or until golden-brown and risen.


After 7 months of hard work and more than 50 liters of coffee, the brand new StravistiX App is here!
But... Why everything has been rebuild from scratch?
Because...
- The old application was made with 2010's web technologies which tends to be deprecated in the next
months: AngularJS (v1)
- It makes more sense to produce the newest features with up to date technologies. And thus avoid an
even bigger technical migration work in the upcoming years.
This new app improves existing features on some points. She's also a way
more reliable than the previous one and the global performance has been increased.
So what's the roadmap from now?
Basically, every big features which have been postponed by this required technical switch:
- Custom year progression targets: Define your targets for various set of sports and
a data
type (distance, time, ...)
- Dashboard: Interrogate your activities on a period. By sports, by bike, by shoes...
Customisable.
- Grid: All your activities and stats in a table. Exportable to a spreadsheet. Mostly
done in old app. Rebuild required.
- Fitness trend planner: Simulate futures efforts (stress scores) and prepare
yourself for
the D-Day.
- Fitness trend for all: A simple smartphone will be sufficient to access fitness
trend feature. Extension will estimate your running and cycling stress scores without heart rate
monitor and/or power meters.
(This welcome note will be removed in future releases).


Module dist.fetch
This module is responsible for downloading contents using URIs. It should handle at least HTTP and FILE URIs as well as system paths transparently. 2DO: support for more protocols if demanded. Two functions are provided. Notice that http requests are cached. download - To download dists. get - To directly obtain manifests.
Functions
| download (src, dest) | Fetch file from URI into destination. |
| get (src) | Directly get file contents from URI using luasocket. |
Functions
- download (src, dest)
-
Fetch file from URI into destination.
Parameters
- src: string: URI to fetch file from. Accepts paths too.
- dest: string: Destination dir, if not provided temporary dir will be used.
Return value:
path, log: Path the file was downloaded and the resulting log message. - get (src)
-
Directly get file contents from URI using luasocket.
Parameters
- src: string: URI to fetch file from. Accepts paths too.
Return value:
text, log: Contents of the URL file or nil and log message.


AWS::ApiGateway::Model
The AWS::ApiGateway::Model
resource defines the structure of a request or response payload for an Amazon API
Gateway (API Gateway) method.
Topics
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::ApiGateway::Model", "Properties" : { "ContentType" :
String
, "Description" :String
, "Name" :String
, "RestApiId" :String
, "Schema" :JSON object
} }
YAML
Type: AWS::ApiGateway::Model Properties: ContentType:
String
Description:String
Name:String
RestApiId:String
Schema:JSON object
Properties
ContentType
-
The content type for the model.
Required: Yes
Type: String
Update requires: Replacement
Description
-
A description that identifies this model.
Required: No
Type: String
Update requires: No interruption
Name
-
A name for the model. If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the model name. For more information, see Name Type.
Important
If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.
Required: No
Type: String
Update requires: Replacement
RestApiId
-
The ID of a REST API with which to associate this model.
Required: Yes
Type: String
Update requires: Replacement
Schema
-
The schema to use to transform data to one or more output formats. Specify null (
{}
) if you don't want to specify a schema.Required: Yes
Type: JSON object
Update requires: No interruption
Return Value
Ref
When the logical ID of this resource is provided to the Ref
intrinsic function, Ref
returns the model name, such as myModel
.
For more information about using the Ref
function, see Ref.
Example
The following example creates a model that transforms input data into the described schema.
JSON
"PetsModelNoFlatten": { "Type": "AWS::ApiGateway::Model", "Properties": { "RestApiId": { "Ref": "RestApi" }, "ContentType": "application/json", "Description": "Schema for Pets example", "Name": "PetsModelNoFlatten", "Schema": { "$schema": "http://json-schema.org/draft-04/schema#", "title": "PetsModelNoFlatten", "type": "array", "items": { "type": "object", "properties": { "number": { "type": "integer" }, "class": { "type": "string" }, "salesPrice": { "type": "number" } } } } } }
YAML
PetsModelNoFlatten: Type: AWS::ApiGateway::Model Properties: RestApiId: Ref: RestApi ContentType: "application/json" Description: "Schema for Pets example" Name: PetsModelNoFlatten Schema: "$schema": "http://json-schema.org/draft-04/schema#" title: PetsModelNoFlatten type: array items: type: object properties: number: type: integer class: type: string salesPrice: type: number


TODO (demo)
Tasks
{{remaining()}} task/s remaining of {{cont}}
{{msgAlert}}
DELETE
{{countDelete}}
{{task.text}}
Add