attribute.defining.item.article Article/Article

attribute.defining.item.article

Command attribute.defining.item.article Article/Article
Applicable release versions: AP
Category Article (24)
Description Using processing codes in an attribute-defining item.

The Power of Advanced Pick Dictionaries, Part 2:
The Attribute-Defining Item

Contributed by Terri Hale
(original article ran in PickWorld Magazine)

Part 1 of this series described the features available to the Advanced Pick (AP) application programmer through extended processing codes invoked through the d-pointer or file-defining item.

This article will focus on the tools and features available to the application programmer and end user through the use of the AP data dictionary or Attribute-Defining Item.

A different approach to application development:

For the application programmer, writing applications in AP requires a different mind-set than in classic Pick or other Data Bases. Since most of the application functionality can be performed using the dictionaries, the first step in developing an application is to define the file structures. This includes defining inter and intra file relationships.

Once the file structures are defined, the Update processor can be used to build the dictionaries and enter Pick/BASIC subroutines.

After the dictionaries are defined and Pick/BASIC subroutines are written (most subroutines are no more than one screen long), the Update processor can be used to enter and retrieve data.

A different approach to data retrieval:

For the end-user, data retrieval is immediate when using B-tree indicies and the Update processor or Pick/BASIC. Once an index has been created and the index correlative has been defined, the user can access data for that attribute instantaneously.

Consider a name field with an index defined. To access a specific item, the user keys in a partial string and <ctrl>+f to 'cruise' forward in the data base for the person whose name begins with the given string. Another <ctrl>+f will bring up the next person whose name follows alphabetically.

This ability to immediately access data via indexed fields introduces a rather revolutionary concept. That is, item-ids are no longer necessary for data retrieval. You can find the item by 'cruising' through any indexed field - immediately. (There is no limit, other than disk capacity, to the number of indicies that can be created.)

Along those same lines, many printed reports can be replaced by giving users the capability to look-up the information needed. This can be accomplished easily using AP's menu structure and Update processor (with the "look only" option) on indexed dictionaries.

Listed below are some of the application related features AP's processing codes provide:

* on-line edit checking
* item modification using Pick/BASIC program calls
* output formatting using Pick/BASIC program calls
* local and remote indexing capabilities
* limit the number of values for input
* require operator input
* define "view" or display only attributes
* define default attributes to be viewed or updated when "zooming" or jumping from the current file to another predefined file

The following table shows what the processing codes are and from where they can be called.

OUTPUT INPUT
PROCESSING CODE CONVERSION CORRELATIVE CONVERSION
--------------------------------------------------------------
algebraic function x x x
ascending order x
attribute index correlative x
call BASIC subroutine x x x
character update x
concatenate x x
date conversion x x x
display only x
f-math correlative x x x
group extract x x x
length code x x x
mask character x x x
mask hexadecimal x x x
mask left & right justify x x x
mask time x x x
must input x
pattern match x x x
range x x x
remote index correlative x
substitution x x x
text extraction x x x
translate x x x
user exit x x
value code x
za x x
zip code x x x

In addition to the new processing codes, all of the existing R83 conversions and correlatives are available in Advanced Pick.

The rules for using processing codes:

A key to writing applications in AP, is knowing where to put the processing codes in the Attribute-Defining Item. In general, the following rules apply:

* Processing codes on output-conversion manipulate data immediately before output.
* Processing codes on correlative are used to preprocess data.
* Processing codes on input-conversion are applied immediately after entry of data.

The Attribute-Defining Item has four new dictionary attributes in AP. They are input-conversion, macro, output-macro, and description.

Note: In AP releases on or after April 25, 1991, there are an additional 11 dictionary attributes added to both the File and Attribute-Defining Items. These "hotkeys" are used to call Pick/BASIC subroutines from the Update processor. More on these later.

A new look to Attribute-Defining Items:

Let's create an Attribute-Defining Item for the orders file called customer. With this attribute, we will translate to the customer file for the name on output, utilize a remote index to look up valid customers (and optionally enter or update customer items), require input on this attribute, and limit the number of values allowed on this attribute to one. We will do all this without a single line of Pick/BASIC code. To view/edit the Attribute-Defining Item, the Pick/BASIC program "ud" is used:

ud orders customer
DICT orders 'customer'
NAME DATA DESCRIPTION
dictionary-code a Valid codes are a or s.
attribute-count 1 Position of data.
substitute-header customer.name User/programmer defined.
structure dependent structure.
output-conversion tcustomer.file;x;;1 Translate name on output
correlative
attribute-type l Valid types are:
l,r,t,u,w,ww,lx,rx,tx
column-width 10 Width for output.
input-conversion i Local index on
orders(customer)
icustomer;a1 Remote index on
customer(name)
mi Defines must input field.
v1 Only one value allowed.
macro name address zip Default attributes
output-macro Not used.
description Enter customer name On-line UP help messages.

That was easy!

Now, we'll create another attribute in the orders file called part#. This attribute will control another attribute in a controlling/dependent structure. It will also translate the description of the part from the parts file, call a Pick/BASIC program to display the quantity on hand, require input and translate to the parts file for valid entry. If this is a new part#, the ability to "zoom" to the parts file and enter a new part number is provided.

ud orders part#
DICT orders 'part#'
NAME DATA DESCRIPTION
dictionary-code a Valid codes are a or s.
attribute-count 2 Position of data.
substitute-header part.number User/programmer defined.
structure c;3 Controls attribute 3.
output-conversion tparts;x;;1 Translate
correlative call display.qoh Program to filter info
attribute-type l Valid types are l,r,t,u,w,ww,x.
column-width 25 Width for output.
input-conversion iparts;a0 Remote index
mi Must input field.
macro part# qoh price Default attributes
output-macro Not used.
description Enter part number. On-line UP help messages.

A faster application prototype:

After the orders file and the two dictionary items (customer and part#) have been created, the Update processor can be used to enter data into the file. The UP command to generate an operable data entry screen would be u orders customer part# . This screen would look like:

orders NEW ITEM
orders _________
customer _________
part# _________

When entering data into the orders file, the customer and part# attributes have all the abilities and restrictions that were designed into them.

The next example will show the 'hotkey' feature. That is the ability to call a Pick/BASIC subroutine from any attribute from the Update processor. Remember that a subroutine called from output conversion, correlative or input-conversion will be automatically executed at the default time by a carriage return.

To call a Pick/BASIC subroutine while in the Update processor on a particular attribute, type control x<0-9>. Typing control x<1>, for example will execute the subroutine called by hotkey1. Typing control x<2> will execute the subroutine called by hotkey2, etc... If no subroutine is called from that particular attribute, then the system looks at the file pointer for any defined calls. If any are present, they will be executed. Any subroutine calls on hotkey.all will also be executed by control x<0-9>.

ud orders state
DICT orders 'state'
NAME DATA DESCRIPTION
dictionary-code a
attribute-count 5
substitute-header
structure
output-conversion tstates;x;;0
correlative
attribute-type l
column-width 20
input-conversion istates;0
macro city state
output-macro
description
hotkey.all sub called by control x<0-9>
hotkey1 call list.states sub called by control x<1>
hotkey2 sub called by control x<2>
hotkey3 sub called by control x<3>
hotkey4 sub called by control x<4>
hotkey5 sub called by control x<5>
hotkey6 sub called by control x<6>
hotkey7 sub called by control x<7>
hotkey8 sub called by control x<8>
hotkey9 sub called by control x<9>
hotkey0 sub called by control x<0>

By modifying our UP command to add the state attribute, we have the following screen

u orders customer part# state
orders NEW ITEM
orders __________
customer _________
part# __________
state __________

In the example above, when the user types control x<1> at the state attribute, the subroutine list.states will execute. Control will then return to the Update processor.

Pick/BASIC program 'list.states'

subroutine list.states(value)
execute 'sort states city state'
return

To summarize, AP provides many features for both the application programmer and the end user through the use of dictionaries. When these features are used in conjunction with the Update processor, the possibilities are only limited to your imagination.
Syntax
Options
Example
Purpose
Related