DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Frame definition files

Saving user input to a form

You can use the frame descriptor done to take information entered in a form by a user and save it in a file. The address entered by the user in the following form is to be written in a file named Addr.file. ``Form.addr: defaults not used'' shows how the form definition file would look if you coded the field descriptors explicitly with values; ``Form.addr: screen output'' shows the form itself; ``Form.addr: defaults used'' shows how the definition file would look if you took advantage of the defaults.

   form=Address Entry Form
   done=`echo Name=$F1 >> Addr.file;\
   echo Address=$F2 >> Addr.file;\
   echo City=$F3 >> Addr.file;\
   echo State=$F4 >> Addr.file;\
   echo Zip=$F5 >> Addr.file`update
   

name=Name nrow=0 ncol=0 frow=0 fcol=5 rows=1 columns=34

name=Address nrow=1 ncol=0 frow=1 fcol=7 rows=1 columns=31

name=City nrow=2 ncol=0 frow=2 fcol=5 rows=1 columns=15

name=State nrow=2 ncol=21 frow=2 fcol=27 rows=1 columns=2

name=Zip nrow=2 ncol=30 frow=2 fcol=34 rows=1 columns=5

Form.addr: defaults not used

This frame definition file creates the following form:

Form.addr: screen output

So does the next form definition file, which takes advantage of the default values for field descriptors:

   form=Address Entry Form
   autolayout=true
   done=`echo Name=$F1 >> Addr.file;\
   echo Address=$F2 >> Addr.file;\
   echo City=$F3 >> Addr.file;\
   echo State=$F4 >> Addr.file;\
   echo Zip=$F5 >> Addr.file`update
   

name=Name columns=34

name=Address columns=31

name=City fcol=5 columns=15

name=State nrow=2 ncol=21 columns=2

name=Zip nrow=2 ncol=30 columns=5

Form.addr: defaults used

As the example suggests, you can save yourself considerable effort by using the default values for field descriptors, if you have coded the autolayout descriptor as TRUE. Note that fcol must be coded for City because, by default, FMLI takes the greater of fcol for the previous field (7) or 1+current_ncol+lengthOf Label (5). That is, you want the input area for City to be separated from its label by one space, not three. nrow must be coded for State because, by default, FMLI increments its value in the previous field (2) by the number of rows in the previous field (1). That is, you want State to appear in the same row as City, not the fourth row. The same thing holds for the nrow descriptor in the Zip field. Finally, ncol must be coded for the State and Zip fields because, by default, FMLI uses its value in the previous field. That is, you do not want different fields in the same row to start in the same column.

This form can be used in an application where addresses have to be entered into the system. If a user fills in this form as follows:

Form.addr: screen output after being filled out by a user

when the user presses <SAVE> (or <CTRL-f> <3>), the done descriptor is evaluated and the following information is written into the Addr.file file:

   Name=Smith, Albert
   Address=1234 High Street
   City=Best
   State=AA
   Zip=12345

Addr.file: contents after user saves the form

If Addr.file does not exist it is created. If it already exists, the information above is appended to it.

Note that the done descriptor in forms is of type command, and thus must evaluate to an FMLI command. In this example, done evaluates to the FMLI command update. After the user input is saved in the file Addr.file, the update command causes the form to be updated to its default values (a blank form), the cursor is positioned on the first field, and the user can begin to enter a new address record in the Address Entry Form.


Next topic: Validating a form field
Previous topic: Example form definition files

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004