Hi Ernad,
The cause of problem is that nSocket is pointer, not numberic
variable.
For example:
-return iif(::nSocket > 0, sqlGetErr(::nSocket), "No connection to
server")
+return iif(::nSocket <> nil, sqlGetErr(::nSocket), "No connection
to server")
With this knowledge, i think this would be better:
return iif(hb_IsPointer(::nSocket), sqlGetErr(::nSocket), "No
connection to server")
This may or may not work depending on how the C module was
implemented. There is quite some variations even inside the
Harbour contribs.
Some C functions return hb_ret() (or nothing), so NIL comparison
will work, but some use hb_retptr( NULL ), which won't, since
it will be a pointer type, and it will not be equal to NIL either.
Old, or non-updated code may simply return hb_retnl( 0 ).
Currently the only way to check whether a pointer is NULL, is
to have a C function always returning hb_retptr( NULL ) (let's call
it hb_nullptr()), and compare against that. (This another solution
to this problem)
Here's a patched hvm.c to support comparing pointers to zero
numeric values. I dropped the idea of pointers as NILs and
pointers as logical, to not break any existing concept and
have a cleaner solution:
http://www.syenar.hu/harbour/null_as_zeronum.zip
if p == NULL:
p == 0, p = 0, p >= 0, p <= 0 -> returns .T.
p != 0, p > 0, p < 0 -> returns .F.
if p != NULL:
p == 0, p = 0, p >= 0, p <= 0 -> returns .F.
p != 0, p > 0, p < 0 -> returns .T.
Comparison to any other values than zero will always return .F.
Brgds,
Viktor
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour