This article was brought to you by the guys from VDF-GUIdance.
For more DataFlex targeted articles see http://www.vdf-guidance.com


Autoprompting

by Wil van Antwerpen

Summary

This package contains some classes to add autoprompt selectionlists to your application for when you exit a dbForm or dbGrid object. Supported are findrequired prompts, required selectionlists and validation-prompts. Updated to support VDF8 SP1.
Size: 0 KB Download
Date Created: 04/03/2000
Date Updated: 12/03/2002
Author: Wil van Antwerpen
Company: Antwise Solutions


Updated 12 March 2002 to take care of changed behaviour in the way item_options are set in VDF8 or higher. The new code is compatible with VDF6 SP2 , VDF7 SP3 and VDF8 SP1.

Popping up a selectionlist if the user doesn't enter a valid value in a field is maybe not a windows standard. It is however a very fast and intuitive interface to the user in the case of a data-entry application.
This interface in DataFlex is called "auto prompting" and is supported in the console mode of DataFlex. Visual DataFlex doesn't have this enabled and Data Access once told me that it isn't supported, because it's not standard in Windows. The irony of this all is that you can find notes about this in the helpfiles (See: required_auto_prompt and findreq_auto_prompt entry options). But these functions do not work, because the datadictionary classes report an error before the auto_prompt handler is executed.
So what I did is to write my own auto-prompt handler that also supports the new datadictionaries and the old console mode options.
This auto-prompt handler supports the field/item options: findreq, required and the validation table. The auto-prompt handler is written for use in a subclass of the dbform and dbGrid classes.
By including this package you will automatically get a findreq and a validationtable auto_prompt.The required auto_prompt is disabled by default, but you can easily change this by setting the property vpbRequired_Auto_Prompt to True.

Originally this code was in my allentry packages, but for your convenience some IDE components were created so they can easily be used. More details are discussed in the following paragraphs or can be seen in the examples.

Registering the new classes

Following are the steps needed to include this package into the order entry example workspace. These steps will create the subclass locally into the order entry workspace, but you can always change this to your global settings.

- Copy the .dfc, .dfo and .bmp files to the Order\IdeSrc folder.
- Copy the .pkg files in the Order\AppSrc folder
- Open the IDE in the order entry sample workspace
- Select 'Maintain Classlists' from the Tools menu (Make sure no program or component is open at this time, otherwise you cannot select this from the menu)
- Click on the workspace tabpage and press the Add button, enter the necessary information
- Select Add and the new class is registered into the IDE. Follow the same steps for the vAppdbGrid class. That's it, now you can use these new classes from within the IDE.

Included in the zip-file are also some example views that are to be used in the order entry workspace.

By the means of this document I would like to thank Dave Porter for testing my code and discussing possible features, before we published the package in here.

Using The Auto_Prompt features

Here is some documentation about the public interface of this code. You do not really have to do anything to get auto_prompting during keyboard navigation, because that is the default behaviour for these classes. But you can also use this feature to display some nicer messages to the user during a save if it fails on the findreq or required options.

vFindReq_Auto_Prompt - vdbForm/vdbGrid

Function vFindReq_Auto_Prompt Returns Integer
This function is created to support auto_prompting during data-entry. There is a standard function of DAC that should work, but it will not work because the required item_option gets in it's way and will display an "record not found" error message to the user just before it can pop up a selectionlist.

The auto_prompting behaviour is cancelled during a save, clear or delete
The reason for this is that there's a pretty good chance that the current_object is not equal to this object resulting in annoying side effects like seeding a different object with the selected code, or presenting a selectionlist during a clear.
Initiating a save during data-entry whith no data in the item that validates on this function returns an info_box to the user with the text that can be defined in the vpsAuto_Prompt_Help property

Note that the field_option DD_Findreq has to be turned off for this to work.

Example:
Object Cs_main_Zip is a vAppdbForm
  Entry_Item Cs_main.Zip
  Set Label to "Zipcode:"
  Set Label_Col_Offset to 38
  Set Size to 13 70
  Set Location to 94 168

  //AB-StoreStart
  Set vpsAuto_Prompt_Help To "Please select a valid zipcode before you try to save" 
  Set Item_validate_msg Item 0 To GET_vFindReq_auto_prompt
  //AB-StoreEnd

End_Object // Cs_main_Zip

vRequired_Auto_Prompt - vdbForm/vdbGrid

Function vRequired_Auto_Prompt Returns Integer
This function is created to support auto_prompting during data-entry. There is a standard function of DAC that should work, but it will not work because the required item_option gets in it's way and will display an "invalid value" error message to the user just before it can pop up a selectionlist.

The auto_prompting behaviour is cancelled during a save or a delete
The reason for this is that there's a pretty good chance that the current_object is not equal to this object resulting in annoying side effects like seeding a different object with the selected code, or presenting a selectionlist during a clear.
Initiating a save during data-entry whith no data in the item that validates on this function returns an info_box to the user with the text that can be defined in the vpsAuto_Prompt_Help property

Note that the field_option DD_Required has to be turned off for this to work.

Example:
Object Cs_main_Zip is a vAppdbForm
  Entry_Item Cs_main.Zip
  Set Label to "Zipcode:"
  Set Label_Col_Offset to 38
  Set Size to 13 70
  Set Location to 94 168

  //AB-StoreStart
  Set vpsAuto_Prompt_Help To "Please select a valid zipcode before you try to save" 
  Set Item_validate_msg Item 0 To GET_vRequired_auto_prompt
  //AB-StoreEnd

End_Object // Cs_main_Zip

vpsAuto_Prompt_Help - vdbForm/vdbGrid

Property String vpsAuto_Prompt_Help Public "Please enter a correct value for field <label>"
This property is meant to be used when the function vRequired_Auto_Prompt or vFindReq_Auto_Prompt is used in your programs. The <label> written here is purely illustrative and will be replaced during runtime with the label of the field. You cannot yet use this as a tag in your definitions, although this might be a good idea for future enhancements.
The message is displayed as an "save aborted" info_box to the user if a save action is aborted because of the required/findreq option on this field.

vpbAuto_Prompt_State - vdbForm/vdbGrid

Property Integer vpbAuto_Prompt_State Public True
With this property you can switch the entire Auto_Prompt feature On and Off. The default value is to have Auto_Prompting switched On.

vpbFindreq_Auto_Prompt - vdbForm/vdbGrid

Property Integer vpbFindreq_Auto_Prompt Public True
With this property you can switch the findreq auto_prompt feature On or Off. As a default the findreq auto_prompt is true.

vpbRequired_Auto_Prompt - vdbForm/vdbGrid

Property Integer vpbRequired_Auto_Prompt Public False
With this property you can switch the required auto_prompt feature On or Off. As a default the required auto_prompt is false.