Pick For Professionals, Part 4: Defining Multiple Views of Data with the
Update Processor
Jonathan E. Sisk
In Part One of this series, we discussed the Update Processor, Advanced Pick’s new full-screen screen editor and data-entry vehicle. This article discusses the techniques for defining multiple views of your data, Using UP as the input mechanism. Even if you don’t use UP for entering data, it’s a remarkably useful tool for doing inquiries, especially when used with Pick’s new B-Tree’s. Here’s how it works.
First, you must understand that much of the processing power under UP is derived from the file’s D-Pointer, the item that describes not only where the file resides, but any additional processing codes to be applied to the data, including B-Tree’s, Item-ID assignments, calls to PICK/BASIC subroutines, and many more.
For our example, we’ll use the "ent" file. Let’s examine the D-Pointer using the ud macro:
:ud ent
DICT ent 'ent' size = 335
dictionary-code D
base 135325
modulo 71
structure
retrieval-lock
update-lock
output-conversion
correlative i135402a1 (A B-Tree Index on Attribute One)
id675 (An Auto-Assign Item-ID Processing Code)
xd13 (A Date Stamp Code to update attribute 13)
I135397a3 (A B-Tree Index on Attribute 3)
I135398a4 (A B-Tree Index on Attribute 4)
attribute-type L
column-width 10
input-conversion call ent.views.up (A Call Before input to a PICK/BASIC Subroutine)
macro name address zip phone contact birthday (View 1)
category amount ref location (I (View 2)
surname name phone comments (View 3)
Figure 1: The "ent" D-Pointer
A lot of stuff is happening in the D-Pointer, as you can see. The B-Tree’s illustrated in the correlative attribute were defined using the create-index ent a1 command. (There are also B-Trees on attributes 3 and 4.)
The id correlative assigns item-id’s during input with UP. The next item-id for this file will be 675.
The xd processing code automatically inserts the date last modified. In this case, it goes into attribute 13.
The two important issues related to our topic for this article concern the use of the input-conversion and the macro attribute. The input-conversion attribute contains a call to a cataloged PICK/BASIC subroutine called, in this example, ent.views.up. The program is shown in Figure 2. The macro attribute in this example contains three values, each of which consists of a different set of attributes to update, according to the rules defined in the ent.views.up program.
:u bp ent.views.up bp 'ent.views.up' size = 575 01 subroutine ent.views.up(item) 02 * 03 * selects the default attributes for UP to use, depending on the user 04 * system(29) returns a '1' if the 'who' command is in R83 format. 05 * AP format of the 'who' verb returns port#, user-id, md. 06 * 07 if system(29) then userp = 3 else userp = 2 08 execute "who" capturing output 09 user=field(output,' ',userp) 10 * 11 * select which value of the macro field to use based on the user id 12 * 13 begin case 14 case user = "th" 15 access(18) = 1 16 case user = "jes" 17 access(18) = 2 18 case 1 19 access(18) = 3 20 end case 21 return
Figure 2 The "ent.views.up" Program
This program illustrates several new features of Advanced Pick PICK/BASIC, including the extensions to the system function and an example of the access(18) function.
In line 7, we check the state of the who output using system(29). If we’re using the new AP format, the output of a who command appears as follows:
:who 10 jes production
Figure 3 Sample Output of AP-format "who" command
The AP style who returns the port number, the current user-id and the account name (master dictionary of the current account).
If we’re using the R83 format, the who output appears as:
:who 10 production jes
Figure 4 Sample Output of "R83"-format "who" command
Since we are going to tailor the View of the data according the user-id, it’s important to know which format we’re using. If system(29) returns a 1, then the R83 format is in effect, meaning that we’ll have to parse out the third part of the who output, otherwise we parse the second part.
Once we have determined who the user is, we can proceed with the rest of the processing. The case structure that begins on line 13 sets the value of access(18), which returns a numeric value to the Update Processor and determines which of the View Macros to use.
The logic in our example says that if the user is th, when she enters the command u ent, at the TCL prompt - without requesting any ‘explicit’ attributes - she will get the first view, which consists of the attributes: name address zip phone contact birthday.
If the user-id is jes, his view will consists of the category amount ref location attributes. The I option includes the item-id in his view. Any valid UP options can be included in the view, including the L option, which makes the process Look-Only, meaning that the data can not be changed - only examined.
The catch-all case statement on line 18 is used for all other user-ids. They will get a view which consists of the surname name phone comments attributes.
That’s essentially it, except for demonstrating how each user’s view changes according to their user-id.
The following Figures illustrate the actual output, starting with Terri’s view:
:who 10 th production :u ent ent NEW ITEM name address zip phone contact birthday ent NEW ITEM size = 14 exited.
Figure 5 Jerri's (jh) View of the "ent" file
Here’s what Jon’s view looks like:
:who 10 jes production :u ent ent NEW ITEM category amount ref location ent NEW ITEM size = 14 exited.
Figure 6 Jon's (jes) View of the "ent" file
Finally, anyone else other than th or jes get a view of the data which appears as:
:who 10 cb production :u ent ent NEW ITEM surname name phone comments ent NEW ITEM size = 14 exited.
Figure 7 Everyone Else's Default View of the "ent" file
This feature makes it easy to tailor the data access to the specific data requirements for a particular user, although any rules can be used for determining which view one gets.
