Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Engineering

Storing Data Between Sessions

  • Last UpdatedOct 30, 2024
  • 2 minute read

APPFORMCNTRL also provides a means for forms to store data so that they can restore their state next time the module is loaded. For each form that is registered, APPFORMCNTRL calls the .saveData method of the form when leaving AVEVA E3D Design: the form can return an array of strings of data to be stored. When the form is next shown, it can retrieve this data using the following method:

!data = !!appFormCntrl.getFormData(!form is FORM).

The contents of the array !data will be the strings in the array returned by the .saveData method when AVEVA E3D Design exited. If no data has been stored for that form, it will be an empty array.

You can also use the command:

data = !!appFormCntrl.getFormData(!formName is STRING)

if only the name of the form that stored the data is known.

Note:
The form must be able to cope if no data is returned. This will happen the first time AVEVA E3D Design is run or if the form was not open the previous time you exited AVEVA E3D Design.

The following example shows a form that stores the state of some of its gadgets between sessions.

layout form !!testForm

 title 'Test of form data storage'

 text .name 'Name' width 10 is STRING

 toggle .toggle 'Toggle'

exit

define method .testForm()

 -- register form with form controlling object

 !!appFormCntrl.registerForm(!this, ARRAY(), ARRAY(), true, true)

 -- retrieve data if available

 !data = !!appFormCntrl.getFormData(!this)

 -- restore name and state of toggle if data present

 if (!data.empty().not()) then

  !this.name.val = !data[1]

  !this.toggle.val = !data[2].boolean()

 endif

endmethod

define method .saveData() is ARRAY

 !return[1] = !this.name.val

 !return[2] = !this.toggle.val.string()

endmethod

Related Links
TitleResults for “How to create a CRG?”Also Available in