Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The first time you execute a Change command with one of these values, a registry entry for the last value of the field in question is created.
Note: These values are not available with a web interface as, for security purposes, they will not have access to registry settings.
Example
Our sample application is used to retrieve the name of an employee based on the employee number:Image Removed
 

Image Added

When the application is started, it shows the employee that was being displayed when the application was last closed down. The values are retrieved using this code:
EVTROUTINE handling(#com_owner.Initialize)
   CHANGE FIELD(#EMPNO #GIVENAME #SURNAME) TO(*remembered_value_for_function)
ENDROUTINE 
Remembering the Form's Size and Position
You use this same method to remember a form's position and size, but first you need to create fields for storing the information:
Define #top *dec 7 0
Define #left *dec 7 0
Define #width *dec 7 0
Define #height *dec 7 0
Then you need to retrieve the last values of these fields and assign them to the appropriate properties of the form in the Initialize event:
EVTROUTINE handling(#com_owner.Initialize)
   CHANGE FIELD(#top #left #width #height) TO(*remembered_value_for_function)
   Set #com_owner top(#top) left(#left) width(#width) height(#height)
ENDROUTINE 
To store the current values of these four properties to the fields when the application is closed, you need to specify:
EVTROUTINE handling(#com_owner.closing)
   Change #top    #com_owner.top
   Change #left   #com_owner.left
   Change #width  #com_owner.width
   Change #height #com_owner.height
Endroutine
Simplifying the Code
You can simplify your code by grouping together all the fields you want the application to remember. You could call the group for example #Remember:
group_by name(#remember) fields(#top #left #width #height #empno #givename #surname)
and then simply add this line to the Initialize event of the form:
Change #remember *remembered_value_for_user
Making All Forms Remember
You may want to consider adding the code required for remembering settings to the STD_FORM component so that it will be in every new form you create. For more information refer to Modify Default Component Behavior.