It appears as though when a hash definition contains DefineKey('key') but
contains no DefineData() at all, DefineData('key') is added implicitly. That
explains why OUTPUT() method seems to write keys out, in fact writing the
data, not the keys - the inviolable rule is that keys are neither written to
PDV host variables, hence nor are they written out with OUTPUT() method.
That also explains why your error causes the following info in the log:
ERROR: Incorrect number of data entries specified at line ... column 1.
which seemed to indicate that ADD() method expects both key and data to be
given via the tags, but you have given the key only. Obliquely, it is
confirmed by the fact that when I change S.add(key:'c') to
S.add(key:'c',data:'c'), it works hunky-dory, and the error vanishes.
As to S.add(), it works trouble-free because the value of ELEMENT in the PDV
provides the values for both the key and the data portion of the hash.
On Tue, 4 Sep 2007 11:14:58 -0400, Richard A. DeVenezia
>Oft times a hash is simply used to test if a value is in some set.
>What I find peculiar is that when a hash has only keys, the .ADD method
>cannot be used if the key: tag is utilized!
> declare hash S();
> element = 'a';
> element = 'b';
> if S.find(key:'c') ne 0 then
> put "'c' is not in S";
> * key: tag causes an error !;
> if S.find(key:'c') eq 0 then
> put "'c' is in S";
>Does such an error seem reasonable ? Not to me :(
>Another interesting quirk, when a hash has only keys, the OUTPUT method
>writes out the key values. When a hash hash keys and data, only the data is
>Richard A. DeVenezia