the language report states that REF CHAR() objects may be used like CHAR(x) objects, with the restriction that the length is done at run-time
Example source fragment
DCL (rc1, rc2) REF CHAR();
DCL (c1,c2) CHAR(2) INIT('ab','cd');
...
! rc1 and rc2 contain some data
IF rc1 CAT c1 < c2 CAT rc2 THEN ... FIN;
In order to evaluate the comparison, we must create storage for all expression containing REF CHAR()
bool comparisonResult;
{ // create new block for local variables
// calculate the required length, I use int for simplicity
int l1;
l1 = rc1.getCurrent() + sizeof(c1);
l2 = sizeof(c2) + rc2.getCurrent();
// create local storage
char h1[l1],h2[l2];
// perform the CAT operations
RefChar r1,r2
r1.setWork(h1,l1);
r1.rewind();
r1.add(rc1);
r1.add(c1);
r2.setWork(h2,l2);
r2.rewind();
r2.add(c2);
r2.add(rc2);
comparisonResult = r1 < r2;
}
this may be a better solution than the current implementation, if more than 1 CAT operation is used in sequence like
compeleteName = title CAT preName CAT name;
~~~
Anonymous