Exchanging Values With Controls

<< Click to Display Table of Contents >>

Navigation:  Interactive Documents >

Exchanging Values With Controls

Previous pageReturn to chapter overviewNext page

When using dycodoc to create interactive templates, you should always associate fields with the Controls you placed in a document. This is the easiest way to exchange values between the Controls and your application. (VPE offers in addition an API to access the values of Controls directly, but using Fields is - from the programmer's view and source code logic - more efficient.)

Fields which are associated with Controls work as a two-way data exchange point:
if your application sets Field values, the associated Controls will visualize these values.
Vice versa, if a user does edit a Control, the underlying Field will change its value accordingly.

App Fields Controls

 

Example for setting a Field's value:

tpl.SetFieldAsString "iForm", "Name", "Smith"

Sets the Field "Name" which is a member of the table "iForm" to the value "Smith", i.e. one could read this as "iForm.Name = Smith".

 

Example for retrieving a Field's value:

Dim data As String

data = tpl.GetFieldAsString "iForm", "Name"

Retrieves the value of the Field "Name" and assigns it to the variable "data".

 

The Basic Rule is:
Fields are used to exchange data between your application and any associated Controls.

 

Note, the TVPETemplate Object itself offers a set of simple methods to access Field values directly, i.e. without using a TVPEField object. In the sample code above, we used a method of the Template Object  to set and retrieve the value of the Field (see also Example).

For a further description of Fields and the Field Object TVPEField, please see “Field Object - TVPEField”.

 

In the following section we will explain, how VPE fires events which will notify your application about changes of Controls due to a user editing the control with the keyboard and mouse.