Skip to content

Class: CodePickList

Properties | Events | Methods | Index of Classes

Allows selection of one or more values from a list of static choices for insertion into database records by a code for each choice in programs handling the database through DataSets

Hierarchy

cObject > cUIObject > DfBaseObject > DfBaseWindow > DfBaseUIWindow > DfBaseControl > DfBaseList > DfBaseForm > DfBaseEntry > DfBaseEntryList > EntryList > WideList_ > WideList > PickList_ > PickList > CodePickList_ > CodePickList

Show full hierarchy and direct subclasses

Library: Windows Application Class Library

Package: Dfcdpk.pkg

Description

CodePickList is used to allow selection of one or more values from a list of static choices for insertion into database records by a code (usually one character) for each choice in programs handling the database through DataSets.

In programs using DataDictionarys, the CodeValidationTable class should be used.

Usage

Use CodePick.pkg

Object ObjectName is a CodePickList
    [set Server to DDOName] 
    [set Modal_State to True]
    [Entry_Item File.Field]
    :
    Item_List
        On_Item [value]
        :
    End_Item_List
    :
End_Object

Argument Explanation

Constant Meaning
ObjectName The name of the object.
File.Field The name of the table and field which is to receive the selected value (only for single-select or auto-select lists).
DDOName The name of the DataDictionary or DataSet object through which this object accesses the database. Also the initial value of this object's server property.
value The value to display for the item.

Of Special Note

This class extends its superclass Pick_list, to enable it to display a selection code, usually a single character, on the same line as the selection value itself is displayed.

The auto_locate_state of a CodePickList is set true.

Updating a Code Field and a Description in a DEO

Often in data-entry screens it is desirable to have a data field represented in two items. The first item will contain the actual database field value, and the second item will contain a display-only description of its meaning.

If the pick-list values were Open, Closed, and New, the pick list should return the first letter to the first item (this is the item that will get written to the database), and the entire text in the second item (this is a displayonly field). The following example shows how to do this:

Object Stat_List is a CodePickList POPUP
    Set export_description_state to TRUE
    item_list
        on_item  "Open"
        on_item  "Closed"
        on_item  "New"
    end_item_list
end_object

Object File_Entry is a dbForm
    :
    item_list
        :
        entry_name_item Stat## File.Status { Capslock, ;
            iPrompt   =(Stat_List(self)), ;
            iValidate =GET_validate_prompt, ;
            iExit     =MSG_prompt_description }
        entry_item (prompt_description(self, Stat##))

Alternatively, if the list values were 1 Open, 2 Closed, and 3 New, we would want the number to be returned to the invoking item, and the word returned to the next item.

Export_description_state tells the list that it must move two values out (the description will be exported to the following DEO item). The prompt_description (this is a procedure imported from the code_deo_mixin class) in the iExit procedure makes sure that the description is updated as users leave the item (in case they entered the status value manually). If the iValidate =GET_Validate_Prompt option is used, the iExit message will not be needed (as a programming convenience, the iValidate will provide this service). Therefore, in this example, the iExit message was actually not needed.

The prompt_description expression in the display-only description item makes sure that the description is updated when the DEO is refreshed by its server DSO. Note that this function must be passed the number of the item that contains the iPrompt message. This will usually be the previous item (using entry_name_item makes this much easier).

A property named description_offset allows you separate your code and your description in the pick list. By default, this value is zero. This works well when the first letter of a description is the code and the first letter of the description (the prior example works this way). If the code and the description are separate, you can tell the CodePickList where the descriptions start by setting this property (2 is often a suigrid value).

Object Stat_List is an CodePickList POPUP
    Set export_description_state to TRUE
    Set description_offset to 2
    item_list
        on_item  "1 Open"
        on_item  "2 Closed"
        on_item  "3 New"
    end_item_list
end_object

When export_description_state is set true, the description is returned by default to the item following the iPrompt item. This can be changed. The property description_item_offset determines the position of the DEO's description item relative to prompt item. The default value is 1. In the following example, this property is used in an unconventional fashion:

Object Card_List is an CodePickList Choose_Card POPUP
    Set export_description_state to TRUE
    Set description_item_offset to 0
    item_list
        on_item  "AMEX"
        on_item  "DINERS"
        on_item  "MASTERCD"
        on_item  "VISA"
    end_item_list
end_object
:

in the DEO's item list:

entry_name_item Card_1## Person.Card_1 { Capslock, ;
        iPrompt   =(Card_List(self)), ;
        iValidate =GET_Validate_Prompt }

The description will get displayed right on top of the actual code item. Why do this? Users may now press a single letter (A, D, M, or V) and press Enter. During the iValidate, the description (AMEX, DINERS, MASTERCD, VISA) will replace the single letter. This provides us with an autofind-like behavior.

Accelerator Keys

This class's accelerator keys are unchanged from those of its superclass.