FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index mod_harbour IF
Posts: 22
Joined: Mon Mar 02, 2020 12:00 AM
IF
Posted: Thu Mar 12, 2020 07:22 PM

I am running this simple code

cUserName := "Luis"

If cUserName <> ""   
    ? "Not Empty"
Else
    ? "Empty"
EndIf

The response is "Empty".
I tried everything that I can think.
Driving me crazy...

Thanks

Posts: 80
Joined: Tue Mar 25, 2008 09:03 PM
Re: IF
Posted: Thu Mar 12, 2020 11:03 PM

Try

if len(alltrim(cUserName )) > 0

FWH 14.11 + xHarbour + bcc582
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: IF
Posted: Fri Mar 13, 2020 03:44 AM
Luis,

Code (fw): Select all Collapse
If ! cUserName == ""
   ? "Not Empty"
Else
   ? "Empty"
EndIf
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: IF
Posted: Sat Mar 14, 2020 04:01 PM
Code (fw): Select all Collapse
[#include "Set.ch"
FUNCTION MAIN()

? set(_SET_EXACT )
cUserName := "Luis"

If cUserName <> ""
? "Not Empty"
Else
? "Empty"
EndIf

SET EXACT ON
? set(_SET_EXACT )

cUserName := "Luis"

If cUserName <> ""
? "Not Empty"
Else
? "Empty"
EndIf


RETURN NIL




SET EXACT
Determines the mode for character string comparison.
Syntax
SET EXACT on | OFF | ( <lOnOff> )

Arguments
on | OFF | ( <lOnOff> )
on | OFF | ( <lOnOff> )
This option toggles if an exact comparison is performed with character strings. or not.
The default is OFF or .F. (false), i.e. characters are compared up the length of the shorter string.
To change the setting use ON or .T. (true) as parameter.
The parameter can also be specified as a logical expression enclosed in parentheses.
Marco Boschi
info@marcoboschi.it
Posts: 22
Joined: Mon Mar 02, 2020 12:00 AM
Re: IF
Posted: Sat Mar 14, 2020 10:39 PM

Basically this ! variable == "" works
This variable <> "" does not
this variable != "" does not....

Continue the discussion