Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EMPTY( ) OR NIL QUESTION

Status
Not open for further replies.

Tonydrph

Technical User
Sep 7, 2002
5
0
0
US
I have a program that transmits data to a national clearing house...anyway I have a field that is A/N and I am checking that the field is empty if there is data within the field I must send this field if not then I must ignore this field and bybass it...every thing is working fine EXCEPT for one small problem...IF my field is :
"abcd" it reads it as not empty...everything OK here
" " it reads it empty .......everyting ok here
" bcd" it reads it as empty.....??????

I have also checked for "nil" and that does not work..

Maybe I am missing something really small...
 
Hi, Tonydrph

Well, I don't ustand that, assuming by A/N you mean a character field. I'd like to see a snippet of yr code.

Anyway, how about:
if len(trim(fieldname))=0
<empty logic>
endif

Jock

 
I have a hunch that setting
Code:
Set Exact on
somewhere during the start of your app will clear up this old messy leftover of dBase compatibility.
For a full explanation of this setting have a look in the excellent Norton Guides, delivered with Clipper from 5 up.

HTH
TonHu
 
yes I meant Char ....and below cInfield is what is actually being sent out....
again the xFieldIn is Char and the one that will go out is
&quot;y 0000000000yyy&quot; this one will work and go out
&quot; y 0000000000yyy&quot; this one will not work..
you can see where I comm. out and have tried all three ways without any sucess..
you may be right with exact on ...I will have to look that up....
Thanks Tony
************************************************


cReturn = &quot;&quot;
cInField := &quot;&quot;
nInNum := 0
If cType = &quot;C&quot;
&& If xFieldIn = NIL
&& IF EMPTY(xFieldIn)
IF len (trim(xFieldIn)) = 0
cInField := &quot; &quot;
ENDIF
&& IF xFieldIn != NIL
&& IF .NOT. empty(xFieldIn)
IF LEN (TRIM(xFieldIn)) != 0
cInField := xFieldIn
Endif

******************************************************
 
Thank you guys for all your Help...

Yes I &quot;set exact on&quot; at the begining of the function and now it is working...Thanks for all your help...Tony
 
&quot;trim()&quot; function removes trailing spaces only from character strings
&quot;alltrim()&quot; removes both leading and trailing spaces

cReturn = &quot;&quot;
cInField := &quot;&quot;
nInNum := 0
If cType = &quot;C&quot;
&& If xFieldIn = NIL
&& IF EMPTY(xFieldIn)
IF len (alltrim(xFieldIn)) = 0
cInField := &quot; &quot;
ENDIF
&& IF xFieldIn != NIL
&& IF .NOT. empty(xFieldIn)
IF LEN (ALLTRIM(xFieldIn)) != 0
cInField := xFieldIn
Endif
 
But still the &quot;set exact on&quot; is required for normal, day to day string comparison, as we programmers *expect* it to work ;-), where &quot;ABC&quot; != &quot;AB&quot;. [surprise]

HTH
TonHu
 
I have this program working through its paces today with no problems..and I &quot;set exact on&quot;...and I am using the empty() function and all seems well..Thanks for all your help..
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top