ALLTRIM harbour compiler

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

ALLTRIM harbour compiler

Post by l3whmg »

Hi guys,
in my application I have this code:

Code: Select all

IF ALLTRIM( formname.usrpasswd.Value ) <> ALLTRIM( formname.retypepwd.Value )
 MSGSTOP("Different password")
 formname.retypepwd.SetFocus
 lOkCheck := .F.
ENDIF
It work fine...but NOT when "formname.usrpasswd.Value" is filled and "formname.retypepwd.Value" is empty :!:

It's my mistake or misunderstanding :?:

Best regards
Luigi from Italy
www.L3W.it
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: ALLTRIM harbour compiler

Post by Rathinagiri »

Can you give a small working sample?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
gfilatov
Posts: 1116
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: ALLTRIM harbour compiler

Post by gfilatov »

Hello Luigi,

It is a good known behaviour of '<>' operator and it is related to the current EXACT SETting.

Please take a look for the following explanation from Clipper documentation:
<> != # Not equal--binary

Syntax

<exp1> <> <exp2>
<exp1> != <exp2>
<exp1> # <exp2>

Type

Character, date, logical, memo, NIL, numeric

Operands

<exp1> and <exp2> are expressions of the same data type or NIL
to compare for inequality.

Description

The <> (not equal) is a binary operator that compares two values of the
same data type and returns true (.T.) if <exp1> is not equal to <exp2>
according to the following rules:

- Character: The comparison is based on the underlying ASCII
code and is the inverse of the equal operator (=). This means that
the comparison is sensitive to the current EXACT SETting. See the
examples below.

- Date: Dates are compared according to the underlying date
value.

- Logical: False (.F.) is not equal to true (.T.).

- Memo: Treated the same as character.

- NIL: All values compared to NIL other than NIL return true (.T.).

- Numeric: Compared based on magnitude.

Examples

- These examples illustrate how the not equal operator (<>)
behaves with different data types:

// Character
SET EXACT ON

? "123" <> "12345" // Result: .T.
? "12345" <> "123" // Result: .T.
? "123" <> "" // Result: .T.
? "" <> "123" // Result: .T.
SET EXACT OFF
? "123" <> "12345" // Result: .T.
? "12345" <> "123" // Result: .F.
? "123" <> "" // Result: .F.
? "" <> "123" // Result: .T.

// Date
? CTOD("12/12/88") <> ;
CTOD("12/12/88") // Result: .F.

// Logical
? .T. <> .T. // Result: .F.
? .T. <> .F. // Result: .T.

// NIL
? NIL <> NIL // Result: .F.
? NIL <> 12 // Result: .T.
? NIL <> "hello" // Result: .T.

// Numeric
? 2 <> 1 // Result: .T.
? 1 <> 1 // Result: .F.
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: ALLTRIM harbour compiler

Post by l3whmg »

Hi guys,

many thanks Grigory.

I've remembered about SET EXACT while you answer to me :mrgreen:

In fact, with "==" operator every things work fine!
Any way I've included a little example for testing.

Many, many thanks
Attachments
pgm000.zip
source file
(1.36 KiB) Downloaded 138 times
Luigi from Italy
www.L3W.it
Post Reply