IF

mod_harbour is an Apache module that allows to run PRGs directly on the web !!!
Post Reply
luiscambuston
Posts: 21
Joined: Mon Mar 02, 2020 12:00 am

IF

Post by luiscambuston »

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
stefano
Posts: 80
Joined: Tue Mar 25, 2008 9:03 pm
Location: ITALIA

Re: IF

Post by stefano »

Try

if len(alltrim(cUserName )) > 0
FWH 14.11 + xHarbour + bcc582
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: IF

Post by Antonio Linares »

Luis,

Code: Select all

If ! cUserName == ""
   ? "Not Empty"
Else
   ? "Empty"
EndIf
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Re: IF

Post by MarcoBoschi »

Code: Select all

[#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
luiscambuston
Posts: 21
Joined: Mon Mar 02, 2020 12:00 am

Re: IF

Post by luiscambuston »

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