|Powered by QM on a Rpi server|
KnowledgeBase 00013: The CORRELATIVE.REUSE Option
The CORRELATIVE.REUSE setting of the OPTION command was added at release 2.9-7 as a way to improve compatibility of correlatives with Pick systems. Part of the reason for needing this option is that QM executes correlatives in a different way from Pick systems.
The precise behaviour of correlatives is not very well documented in any of the multivalue systems. QM's behaviour was based on information extracted from documentation for PI/open, UniVerse, D3, mvBase and several training packages from Malcolm Bull.
There is frequent reference in these documents to the use of the R qualifier after a data item to imply an operation equivalent to use of the REUSE() function in QMBasic. Using an F-correlative as our example, we might have something like
F;'~';1;:to prefix the content of field 1 with a tilde. This is equivalent to use of a QMBasic expression
But, what if field 1 is multivalued? According to many of the multivalue correlative documents, we must amend our correlative to be
F;'~'R;1;:which is equivalent to
So far, all is ok. Now let's say that we want our correlative to return the record id (which is always single valued) followed by a tilde and then the content of multivalued field 1. It looks as though we need to write
F;0;'~';1but we somehow need to insert an R option that will be applied to the result of the first concatenation. The language doesn't have a way to do this.
The underlying problem may be that QM converts correlatives to the equivalent multivalued functions of QMBasic rather than executing the correlative multiple times, once for each value in the multivalued data, which is what Pick appears to do. In most cases, there is no difference between these two approaches.
This leads to a question... What does the R option actually do in Pick? If the expression is evaluated many times, it doesn't appear to be needed
Enabling the CORRELATIVE.REUSE mode of the OPTION command causes all correlative operators to behave as though the R option was present, even those like our double concatenation where there is nowhere in the expression syntax to insert the R.
QM has never guaranteed 100% compatibility with Pick or any other system but we aim to make migration easy. This is the first time that this incompatibility has been observed in several years of users migrating to QM from Pick style systems.
Rather than making this behaviour standard we chose to make it an option just in case there is some situation where it would have undesireable effects.