
Basic Correlative Interpreter
Quote:
> For some years now I have used file extract correlatives in basic programs
> and this works very well. E.g. WK1 = OCONV(000100,'TST.CST;X1;;10) will
> return the first value in attribute 10 in file ST.CST on item 000100. In
> some way this statement interprets a correlative within basic. I have been
> trying unsuccesfully to extend this concept for other types of correlatives
> as well. This has its problems, as a statement of that sort will have to
> refer to a file, item and the correlative itself. A typical logical syntax
> to me would seem WK1 = OCONV(OCONV(000100,'ST.MST'),'F;5;10;*'). I have
> tried many variations of this and have no luck so far and would like to
> request and users out there if they have succeeded with a correlative
> 'interpretation' statement.
> Regards - Hans Appelo
Hans,
The reason your original "correlative" works is because it's not really a
correlative, it's a conversion (a subtle, sometime nit-picky difference).
Within Pick Basic, an xCONV is a call to the CONV processor within the Pick O/S
(or dbms, whatever). The only difference between Iconv and Oconv is a single
bit set to true for Iconv and false for Oconv (I-true; O-false; cute, huh?)
All conversions eventually pass through CONV, the difference is what's
available to the CONV processor when it gets there.
What I mean is, is the first example, you are asking CONV to read a record from
a specific file and bring back a specific attribute. But the second one has
some serious problems. First, what would the CONV proc do with
OCONV(000100,'ST.MST')? ST.MST is not a valid conversion code, so it would
choke. Second, the correlative processor ASSUMES it has the full record, item
id and all, with a special register pointing at the item body so it can figure
out where 5 and 10 are. And lastly, the math involved in 5;10;* is a little
more subtle than just multiply attr 5 by attr 10. And that work depends on
other registers and pointers being setup properly when it gets there.
If you are on a standard Pick platform later than release 6.1.0, there is a
user exit (u85) which is used by the verify-index process to create key data
from the basic record. The syntax is:
x = oconv(func:am:lvl:am:id:am:rec:am,'u85')
where func = the correlative you want to execute
lvl = the value mark level you are processing at (normally 1)
id = the item id of the record
rec = the entire record (at least up to the attr you need)
am = an attribute mark. they are important
In the case of the verify-index process, there is an additional user exit
necessary just to setup the index control block that the index correlative is
going to use.
=============================
As Roger pointed out, there is always another way to skin the cat. You can use
the FILE command in standard Pick Basic. It's a compiler directive shortcut
that creates a default file descriptor (fv.filename), dimensioned array and
does correlative processing. For example:
file CUSTOMERS
read CUSTOMERS from cust.no then
print CUSTOMERS(name)
print CUSTOMERS(address)
print CUSTOMERS(csz)
end
In this example, name, address and csz are dictionary items within the
customers file. At compile time, we figure out what CUSTOMERS(NAME) means and
plug in the code. If CSZ is a translate with some math, no problemo. But it
does it because it's expecting to do so.
Everything within the Pick product is inter-related somehow. As with life,
when you circumvent those relationships, sometimes you get lucky, sometime you
get caught.
--
Sincerely,
--
Mark Brown
Manager, Continuing Engineering
Pick Systems, Inc. USA
Just when I was winning the rat race, they sent in faster rats.