POP_CONV
Published By | Date | Version | Knowledge Level | Keywords |
---|---|---|---|---|
Revelation Technologies | 23 APR 1992 | 2.1X | INTERMEDIATE | CONVERSIONS, POP_CONV, USER-DEFINED |
Many applications rely heavily on codes, for example, product codes, shipping codes, state codes, customer codes, status codes, etc. Usually the codes are static and relatively few. Some applications store codes in a series of code files. This bulletin describes a conversion that you use to eliminate code files and to make codes easier to use.
The user defined conversion (UDC) POP_CONV provides a convenient way for you to define and display codes while minimizing storage and maximizing flexibility.
Note: POP_CONV is available in Advanced Revelation 2.12.
POP_CONV uses codes that you define in popup records to display information and to determine what is stored. Because the codes are stored in a popup, you can use the popup in your windows to display choices and use POP_CONV to display the text.
POP_CONV is used like any other UDC except the optional argument, BRANCH, must contain a popup filename and a popup record separated by an asterisk:
[POP_CONV, FILENAME*RECORD]
The popup is expected to hold the codes in field 4 of the popup record (this is the Explicit popup information prompt in the Makepopup window). The layout of the codes is:
code|description|{absolute_value}
Code is the code entered by the user. It can be any character sequence significant to your application.
Description is the text to be displayed to the user. It should be a short, one line, phrase.
Absolute_value, which is optional, is the relative importance of the code. It should be either a numeric or a character value. You should not mix numerics with alphas.
Normally, absolute_value is the internal format stored. If it is not present, code is what is stored. In both cases, the external format is description.
For example:
A|Excellent|1 B|Good|2 C|Fair|3
In the example above, when you enter "A" or "Excellent" into a prompt using POP_CONV, the word "Excellent" appears. "1" is what is stored in the record.
Using absolute_value
The absolute_value column is used when you wish to specifiy the sort order. For example, assume your application tracks the results of Olympic events. You want to provide a code for the medals, so you build a popup with this code format:
G|Gold S|Silver B|Bronze
This is fine unless you want to sort on the field and have all the gold medal winners appear first, then the silver, then the bronze. Because the G, S, and B are used for sorting, you would see the results printed in bronze, gold, silver order.
To handle this situation, use absolute_value to indicate the ordering. For example:
G|Gold|1 S|Silver|2 B|Bronze|3
Now the 1, 2, and 3 are stored and used for sorting, and your results display correctly.
Tips
While POP_CONV is most useful in windows, Figure 1 shows how it can be used in a program.
It is not necessary to show either code or absolute_value in your popup. Indicate in the Column formats section that only the second position should display and the popup will show only the description.
Depending on the application, you may want to show code. By showing code, you see the shorthand way of entering the data every time the popup displays. In the example above, if you see the popup enough times, you may remember that, in a window, you only need to enter "G" for "Gold". You don't have to press [F2] to get the popup, and you don't have to type the entire word "Gold".
Examples
Figure 1
DECLARE SUBROUTINE CATALYST LOOP @ANS = "" CATALYST("P", "POPUPS*MEDALS") WHILE @ANS INTERNAL = ICONV(@ANS, "[POP_CONV,POPUPS*MEDALS]") EXTERNAL = OCONV(INTERNAL, "[POP_CONV,POPUPS*MEDALS]") MSGPARMS = INTERNAL : @FM : EXTERNAL MSGTEXT = "|Internal format is %1%|External format is %2%|" MSG(MSGTEXT, "", "", MSGPARMS) REPEAT