A
FIELD object is an area on the form where the user can key text. A value
can also be set by the program. If you want to force a line feed in the text,
use the &h0A character (chr(10)).
The code for a Field is executed when the user exits the field by tapping on some other object or menu item. The code may then perform editing for validity or other computations dependent on the new field value. This code will be triggered even if the user does not change the field value (e.g. taps on the field but then makes no changes) and positions on a different field. NS Basic/Palm does not keep track of the before and after field values; it only knows that the field was selected for editing and then the user moved off the field to another object.
A common program need is to read a database record and display the contents of fields to the user, let the user make changes, and then restore the new values to the database record. This would normally mean that in the form startup code, you would read the database record and place database values into each field.
Properties Supported (Set at design time)
Label, Font ID, Text, Max Characters, Left Justified, Underline, Single Line, AutoShift, HasScrollbar, Dynamic Size, Editable, Numeric, Visible
Methods Supported (See "Methods")
Left, Top, Width, Height, Hide, Show, Redraw, Text, SetFocus, ID, Index, Type
Example
Read in database record and display it. Let the user make changes and write it out.
Dim Name as string
Dim Age as integer
Dim Married as integer '0=not or 1=married
Dim err as integer
Err=DbRead(MyDb, Name, Age, Married) 'using Name as key
FldName.text=Name
FldAge.text=str(Age)
ChkMarried.status=Married
Then, on the "Done" button that the user presses after changing the values on the form, you might have the code:
Dim Name as string
Dim Age as integer
Dim Married as integer
Dim err as Integer
If not testNum(fldAge.Age, " ",3,0)=0 then
Beep
Msgbox "Age field is not valid."
Exit sub
end if
Name=fldname.text
Age=val(fldAge.text)
Married=chkMarried.status
Err=DbUpdate(MyDb, Name, Age,Married)