Sporkl Input/Output


The basic input/output process in a Sporkl program is as follows: the program prints some output to the screen, and that output may or may not include input fields and buttons. If it does not include inputs, then program execution ends there. If it does include inputs, then the program will have included a call to the load_user_input() function, which halts program execution and sends the output back to the user's browser. When the user presses an input button, the requested input is sent to the server and program execution resumes after the load_user_input() call. The above process is then repeated.

Sporkl programs can print output to the screen via the collection of functions that start with "print" - see the predefined function library for a list. The most basic output function is print(). This takes a string as an argument, and displays it on screen. Newlines must be explicitly added - to add a newline, include a "\n" at the desired location in the string. To apply some basic formatting to the output string, use the print_format() function.

There is also functionality to print form-style inputs - fields, textboxes, radio buttons, etc - to screen, which are then used to get input from the user.

Functions which print inputs return values of type input. These return values are used to indentify that input when obtaining its value after it is loaded via the load_user_input() function. You can see this procedure demonstrated in the examples on the SporkApp Builder page. Also, the input printing function documentation have examples to illustrate the process.

All Sporkl screen output is wrapped between preformat ("<pre>") html tags, so spaces and newlines should be preserved and displayed properly in the users browser, provided the browser uses a monospace font for preformatted text.

The screen is cleared of previous output after each input load via load_user_input().




( <-- Back to Sporkl documentation home )




sporkforge