Bernie,
Try:
SET EQNULL ON
IF (CVAL('DATABASE')) <> 'DataBaseName' THEN
CONNECT DatabaseName
ELSE
-- Do what you have to do ...
ENDIF
That long time bug HAS BEEN FIXED in The Glorious R:BASE
2000 (ver 6.5++) for Windows and The R:edoubtable R:BASE
2000 (ver 6.5++) for DOS, officially released on June 15,
2001 and is FULLY EXPLAINED and DOCUMENTED in RBW65PP.TXT
and RBD65PP.TXT accordingly.
You'll also find such explanation on the latest, greatest
and up-to-date Online HTML Documentation, i.e:
http://www.RSyntax.com
Following is the technical snapshot of such very old bug
fix in 6.5++.
R:BASE uses special processing on simple IF commands for
maximum speed. However, the way these were processed was
not consistent with the way complex IF commands or WHILE
commands were processed with regard to comparisons using
NULL values. The EQNULL setting at TRUE means that a
comparison between two NULL values is a match and that a
comparison between a NULL value and a non-NULL value is
not. When EQNULL is set to FALSE then a comparison between
two NULL values is not a match nor is a comparison between
a NULL value and a non-NULL value a mismatch. The NULL
value essentially make the whole thing "unknown'. This
behavior was followed in WHILE and complex IF commands
but was not followed in simple IF commands. A simple IF
command has only one comparison and the left side is a
simple variable and the right side is either a variable
or a constant. A simple IF does not have any expressions.
Compare these code samples:
SET VAR v1 TEXT = NULL
SET VAR v2 TEXT = NULL
SET EQNULL OFF
IF v1 = .v2 THEN
-- will not be a hit
ENDIF
IF v1 <> .v2 THEN
-- will not be a hit
ENDIF
IF v1 <> 'This' THEN
-- will not be a hit (it used to be before the fix in 6.5++)
ENDIF
SET EQNULL ON
IF v1 = .v2 THEN
-- will be a hit
ENDIF
IF v1 <> .v2 THEN
-- will not be a hit
ENDIF
IF v1 <> 'This' THEN
-- will be a hit
ENDIF
Before this fix in 6.5++, the comparison "IF v1 <> 'This'
THEN" would be a hit with EQNULL set ON or FALSE when it
should only be a hit when EQNULL is ON. This means that
now "IF (.v1) <> 'This' THEN" and "IF v1 <> 'This' THEN"
will both process the same way. In the past they would
be different because of this problem.
In your code if you want the comparison of a NULL variable
and a non-NULL constant to be a hit then you should run
with EQNULL set ON.
For a complete list of New Commands, Features, Enhancements,
and Bug-Fixes in 6.5++, please visit:
http://www.rbase2000.com/rbw65pp
Enjoy and make sure to have fun!
Very Best Regards,
Razzak.
At 05:42 PM 6/17/2001 -0400, >Bernie Lis wrote:
>I want to make sure I am connected to the right database
>so I do if (cval('database')) <> 'DataBaseName' then if
>no database is connected, cval('database') returns a null
>and will not do the compare to my data base name.
>It worked in dos 5.5 and I am trying to upgrade my client
>to 6.5 Is this a bug or can't you compare a null in an if
>statement?
===================================-============================
R:BASE Developers's Conference: http://www.rbase.com/conference
Official R:BASE List Server: mailto:[EMAIL PROTECTED]
RBTI Events/Training: http://www.rbase2000.com/events
R:DCC Members: http://www.rbase2000.com/rdcc
================================================================
R:BASE, Oterro & R:Tango are registered trademarks of RBTI.
==================================-=============================