Page 1 of 2

TGet bug?

PostPosted: Tue Feb 21, 2006 5:56 pm
by Enrico Maria Giordano
In TGet:LButtonUp() method there is

elseif Empty( cText ) .or. cText == " / /" .or. ;
AllTrim( cText ) == "0" .or. ;
AllTrim( cText ) == " - -"

but I think that cText can never be exactly equal to " / /" and surely AllTrim( cText ) can never be exactly equal to " - -".

EMG

PostPosted: Tue Feb 21, 2006 5:59 pm
by manuramos
I think it's OK because ALLTRIM(" / / ") is exactly "/ /", in the same way ALLTRIM(" - - ") is exactly "- -", and is necesary.

PostPosted: Tue Feb 21, 2006 7:03 pm
by Enrico Maria Giordano
manuramos wrote:I think it's OK because ALLTRIM(" / / ") is exactly "/ /",


Yes, but the exact comparison is with " / / " (note that it starts with a space).

manuramos wrote:in the same way ALLTRIM(" - - ") is exactly "- -", and is necesary.


And here the exact comparison is with " - - " (note the leading and trailing spaces).

EMG

PostPosted: Tue Feb 21, 2006 7:06 pm
by manuramos
Yes it's true. I don't know why. It seems a bug.

PostPosted: Tue Feb 21, 2006 7:13 pm
by manuramos
Enrico, I'm remembering, tree years ago,more or less, I modified some methods of TGET class, and I released leading spaces. It's running OK.

PostPosted: Tue Feb 21, 2006 8:06 pm
by Enrico Maria Giordano
manuramos wrote:Enrico, I'm remembering, tree years ago,more or less, I modified some methods of TGET class, and I released leading spaces. It's running OK.


Sorry, I don't understand. Are you saying that you leaved or removed the leading spaces?

EMG

PostPosted: Wed Feb 22, 2006 4:14 pm
by manuramos
Excuse my english. I removed it.

PostPosted: Wed Feb 22, 2006 4:43 pm
by Enrico Maria Giordano
Ah, ok.

EMG

PostPosted: Sun Feb 26, 2006 7:08 am
by Antonio Linares
Enrico,

I guess the right code is ... .or. cText == " - -" without using AllTrim().

The other expressions seem fine.

PostPosted: Sun Feb 26, 2006 10:46 am
by Enrico Maria Giordano
Antonio Linares wrote:Enrico,

I guess the right code is ... .or. cText == " - -" without using AllTrim().

The other expressions seem fine.


I think not. If cText is an empty date it will be " - - " or " / / " (note the trailing space) and the exact comparison (==) will fail. Or am I wrong?

EMG

PostPosted: Sun Feb 26, 2006 11:01 am
by Antonio Linares
Enrico,

Please notice that there are three spaces in front: " - -"

It looks as a picture for US phone numbers.

PostPosted: Sun Feb 26, 2006 11:09 am
by Enrico Maria Giordano
Antonio Linares wrote:Enrico,

Please notice that there are three spaces in front: " - -"

It looks as a picture for US phone numbers.


Ok, right. But what about ... .or. cText == " / /"?

EMG

PostPosted: Sun Feb 26, 2006 11:22 am
by Antonio Linares
Enrico,

> cText == " / /"

It looks as an empty date (please notice that AllTrim() was not needed). There are two spaces before the first "/" and none after the last "/".

That seems to be the return from GetWindowText() when the date is empty. (edit: not sure about this, as a space may be typed after)

PostPosted: Sun Feb 26, 2006 11:28 am
by Enrico Maria Giordano
Antonio Linares wrote:Enrico,

> cText == " / /"

It looks as an empty date (please notice that AllTrim() was not needed). There are two spaces before the first "/" and none after the last "/".

That seems to be the return from GetWindowText() when the date is empty.


Are you sure that GetWindowText() returns " / /" without the two trailing spaces? If yes then ok.

EMG

PostPosted: Sun Feb 26, 2006 11:34 am
by Antonio Linares
Enrico,

The problem is that if a PICTURE is used that has a "/" or a "-" in the front, then the code will be wrong, as ::nPos should not be set to 1.

This may be the right code:
Code: Select all  Expand view
      elseif Empty( cText ) .or. RTrim( cText ) == "  /  /" .or. ;
         AllTrim( cText ) == "0" .or. ;
         RTrim( cText ) == "   -  -"


What do you think ?