If I use a null value supressed descriptor on a logical field, I would expect to get records with logical-field = TRUE only … A really bad trap for the unwary.
How do you have “logical-field” defined to Adabas? Since there is no real data type “logical” (unless it is in the new version of PC Adabas, have not played with data types there yet), do you have it defined as alpha? If so, I understand your concern. If not, I can understand Adabas “keeping” the value x’20’ (which is a blank for mainframers who are confused that it is not x’40’).
Now I understand Adabas, too. But I never thought about that “problem” - until yesterday. Yesterday, I discovererd some bad logical values. And I know that we got many codings like this:
read SOMEFILE by LOGICAL-FLAG = TRUE
/* do some processing
...
LOGICAL-FLAG := FALSE
update
end transaction
end-read
… In case of H’20’ values I would do the loop, too.
I have long claimed that REDEFINE is one of the most “dangerous” statements in Natural. Your problem is just another example of this.
For some fun, try the following program
DEFINE DATA LOCAL
1 #A (A5)
1 REDEFINE #A
2 #N (N5)
END-DEFINE
*
INPUT #A
WRITE #A#A (EM=H(5))
ADD 1 TO #N
WRITE #A#A (EM=H(5))
END
Run the program and enter a “typo” value of 12E45 (instead of 12345). Take a look at what happens. Natural “strips” the high order bits from the E.
Now run the program again and enter a value of 123. Watch the two trailing blanks become trailing zeroes (before the ADD). Hardly correct arithmetic. 123 + 1 = 12301
I have long hoped for such ADDs to be illegal and produce run time errors. HOWEVER, I also realize this would degrade arithmetic performance considerably. Natural would have to test all operands before performing arithmetic; this would be VERY expensive.
Hence, the responsibility is placed on the programmer to ensure that numeric operands have numeric values. REDEFINE is the easiest way to create values that “violate” such a responsibility.