| Search Locate Previous Next | Contents |
This is the end-product of the first few sections of the tutorial. It is a small contact manager, with menu and toolbar, a list box of current contacts, and a pop-up incident log implemented as a Dyalog grid. It also has all the correct Windows file-management behaviour and keeps a list of the recently used files. It will take 45 hours to work through these examples, but by the end of the process you will have learned most of what there is to know about Causeway!
As before, lets start with some test data, but this time it is worth setting up a function to build it as we will need this soon enough to run from File, New on the main menu:
NEWFILE
[1] © Do what we need to clear data down
[2] names,'Noname'
[3] addrs,'House' 'Street' 'Town' 'PostCode'
[4] eyes,1
[5] log,0 2½0 ''
[6] wasnames addrs eyes log
This avoids the annoying empty case by setting up one row of dummy data to start with. It takes a snapshot of the data it made so that the application can prompt on exit if any data has changed.
Building the basic form definition is much as before, but there are one or two new tricks to look out for. The data for the Name field will now be indexed from the vector of names:
... where inx is set as the data of the list box to its left.
You can make inx a local variable on the form, and initialise it to 1 when the form is created. To localise it, simply add it to the locals list in the property watcher; and set it on creation in the event table for the main form (right mouse menu Behaviour on the form itself):
There is one other entry in this grid which needs to be explained:
#.CPro.Do utility. This takes the object name as left argument, and the function name (in quotes) and its arguments on the right. In this case you can use the shorthand ¸ for the name meaning self to run the SetIcon function with the name of the .ico file you want to use for the main form. This example also abbreviates #.CPro. to which has the advantage that if you ever relocate the CPro namespace your dialogue boxes will not need modification, as Causeway will always substitute this correctly.
For the moment, just localise inx by adding it to the locals property of the form, and add the second line to your table to initialise it we can sort out the icon later!