Bug in Progress?

sdjensen

Member
Could you please try the following code and let me know the result.

message (if ' ' = '' then 'not OK' else 'OK').
message (if ' ' > '' then 'OK' else 'not OK').


Tried it on windows xp OpenEdge 10.2A02 and 10.1A, 9.0A and 9.1A.
The code results to 'not OK' in all cases. :eek:
 

StuartT

Member
Could you please try the following code and let me know the result.

message (if ' ' = '' then 'not OK' else 'OK').
message (if ' ' > '' then 'OK' else 'not OK').


Tried it on windows xp OpenEdge 10.2A02 and 10.1A, 9.0A and 9.1A.
The code results to 'not OK' in all cases. :eek:

It is in my opinion a bug. It has existed for as long as I can remember, for some strange reason progress treats a null character value as being equal to a character string when comparing.
You can get around it by comparing the lengths of the strings.
 
saw one entry in the Progress KB with regard to this. Dont know if this helps.

----------------------------------------------------------------------
KB-P45036: Why do ' ' and '' when compared, evaluate to being equal?
----------------------------------------------------------------------
Status: Verified
GOAL:
Why do ' ' and '' when compared, evaluate to being equal?
FACT(s) (Environment):
All Supported Operating Systems
Progress 8.x
Progress 9.x
OpenEdge 10.x
OpenEdge Category: Language (4GL/ABL)
FIX:
When comparing two strings Progress always appends space characters to
the shorter of the two strings before doing the comparison. In this
scenario, the empty string is expanded to the same length as the
string containing a single space character. Since the character used
during the extending of the empty string is the space character the
resulting strings are equal.
 

StuartT

Member
Try the workaround method:

message (if length(' ') = length('') then 'not OK' else 'OK').
message (if length(' ') > length('') then 'OK' else 'not OK').

I have been using progress since 6.3 was released and this bug has always existed.
 

TomBascom

Curmudgeon
It's not a bug, it's a feature ;)

No, really. I know it's annoying but think about a character field that a user enters. Trailing spaces are invisible to the user. So Progress doesn't want them to throw off a comparison. And putting TRIM() everywhere is a real PITA.

Much like dictionary validation it makes a good demo. At least it did in 1985.
 

D.Cook

Member
Wow I've been using Progress for a while now and had no idea about that.. I'm glad I know now.
It's one of those 'shortcut' features of the ABL you have to be careful with, like string comparisons being case-insensitive (by default).
 
Top