Consultor Eletrônico



Kbase P124115: " " <space> string is seen as "" <zero-length> string when performing a conditional/logical test
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/02/2010
Status: Verified

SYMPTOM(s):

A variable named foo is defined as CHARACTER

The single <space> value is assign to foo

When performing a conditional test, foo bahaves as if it contains an empty string

foo=" " is equivalent to foo=""

FACT(s) (Environment):

Windows
UNIX

CAUSE:

This is an expected behaviour.

CAUSE:

The ABL/4GL code considers a string that exclusively contains <space> values as an empty string.

FIX:

To check whether a string exclusively contains 1 or more <space> values you can use the following:
DEFINE VARIABLE foo AS CHARACTER NO-UNDO.

foo= " " .

IF foo = " " AND length(foo) > 0 THEN
MESSAGE "There is" length(foo) "space(s)"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
ELSE
MESSAGE " No space in it"
VIEW-AS ALERT-BOX INFO BUTTONS OK.