VDF-GUIdance logo



  Visual DataFlex Logo
  

Shared knowledge leads to accumulated knowledge

        Printer Friendly Page


No Files Available
Date Created: 10/27/2000
Date Updated: 10/27/2000
Author: Peter Bosch
Company: info trans Logistik Systems GmbH
Summary:
Do you remember the item_option "retain" from console mode DataFlex? This is no longer a supported technique in VDF, until now! This white paper describes how you can still make use of the retain field_option in VDF (DD_RETAIN) by adding a few lines of code to your subclass structure.

Retain in VDF

by Peter Bosch
In VDF Retain fields can no longer be cleared, neither with pressing F5 twice nor with Ctrl+F5. These subclasses now allow you to have Retain-fields with the ability to clear them with Ctrl+F5 (pressing F5 twice still has no effect)

Usage:

Just use the RETAIN Checkbox in the Database Builder as usual. All other things are handled by the subclasses.

RETAIN_ALL reacts like before: no Clearing at all.
What I do is query if the DD_RETAIN is set for every field. If so, then I clear the original RETAIN setting and replace it with my own settings at runtime.
This means that once you put the code below in your subclasses it will work. You don't need to change your individual .dd files to use it.

Note: make sure that the Database builder and the IDE are using your subclasses instead of the global subclasses from Data Access.

Definitions in your own DataDictionary Class

Class ITDataDictionary is a DataDictionary

Procedure Construct_Object
Object Tab_Retain_Fields Is An Array
End_Object

Object Tab_Retain_Value Is An Array
End_Object
Forward Send Construct_Object
Property Integer pNoDefaults Public False
Send Define_Retain_Fields
End_Procedure

Set Retain State for a Field
Procedure Set Field_Retain_State Integer iField Integer iState
Set Array_Value of (Tab_Retain_Fields(Self)) Item iField to iState
End_Procedure
Query Retain-State
Function Field_Retain_State Integer iField Returns Integer
Integer iState
Get Integer_Value of (Tab_Retain_Fields(Self)) Item iField to iState
Function_Return iState
End_Function

Procedure Define_Retain_Fields
Integer iCount I iRetain
Get Field_Count to iCount
For I From 1 to iCount
Get Field_Option I DD_RETAIN to iRetain
If iRetain Begin
Set Field_Options I to DD_CLEAR_FIELD_OPTIONS DD_RETAIN
Set Field_Retain_State I to True
End
Loop
End_Procedure
If the field is RETAIN: Default Values, if Ctrl+F5 pressed: no Default Values
Procedure Field_Defaults
Integer I Anz iState
String Val
Forward Send Field_Defaults
If (Not(pNoDefaults(Self))) Begin Defaults only, if not Ctrl+F5
Get Field_Count to Anz
For I From 1 to Anz
Get Array_Value of (Tab_Retain_Fields(Self)) Item I to iState
If iState Begin Retain-Field
Get Array_Value of (Tab_Retain_Value(Self)) Item I to Val
Set Field_Default_Value I to Val
End
Loop
End
Set pNoDefaults to False
End_Procedure
Save Database Values for RETAIN
Procedure ITSave_DDO
Integer I Anz iState
String Val
Get Field_Count to Anz
For I From 1 to Anz
Get Integer_Value of (Tab_Retain_Fields(Self)) Item I to iState
If iState Begin Retain-Feld
Get Field_Current_Value I to Val
Set Array_Value of (Tab_Retain_Value(Self)) Item I to Val
End
Loop
End_Procedure
End_Class

Definitions in your own dbForm Class and your dbView Class

Procedure Request_Save
Integer Svr#
Get Server to Svr#
If (Svr# > 0) Send ITSave_DDO to Svr#
Forward Send Request_Save
End_Procedure

Procedure Request_Clear
Integer Feld# Svr#
Get Server to Svr#
If (Svr# > 0) Send ITSave_DDO to Svr#
Forward Send Request_Clear
End_Procedure

Procedure Request_Clear_All
Integer Svr#
Forward Send Request_Clear_All
Get Server to Svr#
If (Svr# > 0) Begin
Set pNoDefaults of Svr# to True
Send Clear to Svr#
End
End_Procedure