How do I test a user interface?

The m.page() function can take a second optional parameter that is a boolean. If this is ‘true’ then the page is drawn but its behaviour is modified as follows:

1.No callbacks are performed, instead a message is sent to the console describing what callback would have been called (so you can verify it will be called).

2.The ‘hide’ attribute is ignored, so all controls are visible (to allow size/position verification).

3.Any context where a callback would return a result (e.g. filling a calculated column), returns a NIL instead.

Using this ‘preview’ parameter allows you to edit the window definition, test it and edit again very quickly. To use this technique you must include the following line in your script before you call m.page():

require’console’

With the example window given in What is a User Interface? the console session would look like this after you pressed the Select button:

guile_console

A useful editor to use is Notepad++, this is free to download from http://notepad-plus.sourceforge.net/uk/site.htm and has the useful feature of being able to ‘fold’ a Lua program file as well as syntax highlight it.