The LiveCode server-side scripting technology allows you to mix LiveCode code with HTML content on the same web page, in much the same way as PHP, the most widely-used server-side scripting language. The advantage for LiveCode developers is that they can use the very same language they use to develop desktop applications to create dynamic web pages. While the language is the same there are a few differences and additions to LiveCode as used in server-side scripting, compared to the way it is used in developing stacks. Here is a summary of the main differences:
put
command without a destination container, such as put "Hello World"
, is directed to the message box. There is no message box in the server-side environment; instead a put
without a destination is returned to the client or web browser that called the URL. In a web browser it is displayed as part of the html output.the defaultFolder
and the itemDelimiter
;
put
data into are variables and files on the server.include
command – You can access library stacks in the LiveCode Server environment just as you can in LiveCode itself. You can also use the include
command you can reference other .lc files containing frequently used handlers and use their scripts as if they were part of the current file. For example, say we have a file containing frequently used handlers called "mylibrary.lc" in the same folder as your current .lc file. It could contain our old friend the q()
function, which returns a string with double quotes around it. We could do this in our .lc file:
include "mylibrary.lc" put "<p>" & q("Hello World") & "</p>"
$_GET
and $_POST
array variables – When a form on a web page is submitted to the .lc script, or a URL with a query string is requested, the LiveCode Server engine will attempt to parse this data into structured arrays. For a query string, or a form 'GET' method, this information will placed in the $_GET array. For a form 'POST' method, this information will be placed in the $_POST array. In both cases the conversion to an array is the same. The incoming data is a set of key=value pairs. The key determines which element of the array the value gets put in.$_SERVER
array variable - contains lots of information about the client and server environments. See an example here.the errormode
property set the errormode to "inline"
- displays LiveCode scripting errors in the web page; good for debugging (remember to comment out before you go final on your page.)