Su ayuda con este código

Post Reply
User avatar
Armando
Posts: 3279
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Been thanked: 4 times
Contact:

Su ayuda con este código

Post by Armando »

Hola Amigos del foro:

Por favor ayúdenme a entender este simple y sencillo código

Code: Select all | Expand


   ? "Texto" <> ""
   ? "Texto" == ""
 


Ambos me devuelven FALSE, y mi lógica me dice que la primera comparación
debería ser TRUE, será que la noche ha sido larga? :cry:

Saludos
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
cnavarro
Posts: 6572
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Has thanked: 4 times
Been thanked: 6 times

Re: Su ayuda con este código

Post by cnavarro »

Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
Armando
Posts: 3279
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Been thanked: 4 times
Contact:

Re: Su ayuda con este código

Post by Armando »

Cristóbal:

Perfecto, me estaba volviendo loco :oops: .

Saludos
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
nageswaragunupudi
Posts: 10733
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 11 times
Contact:

Re: Su ayuda con este código

Post by nageswaragunupudi »

Use
? !( "TextTo" == "" )
This does not require changing SET EXACT.
Please note that setting SET EXACT ON will have global effect and somewhere some comparisons may give different results.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Armando
Posts: 3279
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Been thanked: 4 times
Contact:

Re: Su ayuda con este código

Post by Armando »

Mr. Rao:

Thanks a lot.

Best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Enrico Maria Giordano
Posts: 8770
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: Su ayuda con este código

Post by Enrico Maria Giordano »

The opposite of

Code: Select all | Expand

? "Texto" <> ""


is

Code: Select all | Expand

? "Texto" = ""


EMG
User avatar
cnavarro
Posts: 6572
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Has thanked: 4 times
Been thanked: 6 times

Re: Su ayuda con este código

Post by cnavarro »

nageswaragunupudi wrote:Use
? !( "TextTo" == "" )
This does not require changing SET EXACT.
Please note that setting SET EXACT ON will have global effect and somewhere some comparisons may give different results.


Dear Rao
Do you mean that what we have to do is induce our code to obtain the result that we expect and that it is not harbour, using the commands and functions that it provides us, that resolves the expression?
So, let's not put the expression (!) and put directly ( ? .T. ) or ( ? .F. ) depending on the result you want to obtain, right? It would be much simpler ( it's a joke ).
The colleague's question is why he obtains that result when the expression is evaluated, I don't think he should be induced as to how it would be resolved to obtain the expected result, that should be done by Harbour.
Use SET EXACT ON and SET EXACT OFF when needed, that's my advice

Quiere decir usted que lo que hay que hacer es inducir a nuestro codigo a obtener el resultado que nosotros esperamos y que no sea harbour, usando los comandos y funciones que nos proporciona, el que resuelva la expresión?
Entonces, no pongamos la expresion (!) y ponga directamente ( ? .T. ) o ( ? .F. ) dependiendo del resultado que usted desea obtener, no?, sería mucho más sencillo ( es una broma ).
La pregunta del compañero es por qué obtiene ese resultado al ser evaluada la expresión, no creo que se le deba inducir a como se resolvería para obtener el resultado esperado, eso debe hacerlo Harbour.
Use SET EXACT ON y SET EXACT OFF cuando se necesite, ese es mi consejo


Armando, por favor, prueba este codigo ( sin el SET EXACT ON )

Code: Select all | Expand


? "" <> "Text"
 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
Armando
Posts: 3279
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Been thanked: 4 times
Contact:

Re: Su ayuda con este código

Post by Armando »

Cristóbal:

? "" <> "Text"

Funciona como se espera, retorna (.T.)

Pero
? "Texto" <> ""
No funciona como se espera, retorna (.F.)

Me estoy volviendo loco

Saludos
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Enrico Maria Giordano
Posts: 8770
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: Su ayuda con este código

Post by Enrico Maria Giordano »

As I wrote, "Text" <> "" is the opposite of "Text" = "", so

Code: Select all | Expand

? "Text" <> ""


gives .F. because it is the opposite of

Code: Select all | Expand

"Text" = ""


that gives .T. because "Text" begins with "" (any strings contain or begins with ""). Moreover

Code: Select all | Expand

"" <> "Text"


gives .T. because it is the opposite of

Code: Select all | Expand

"" = "Text"


that gives .F. because "" (the empty string) doesn't begin with "Text".

EMG
User avatar
cnavarro
Posts: 6572
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Has thanked: 4 times
Been thanked: 6 times

Re: Su ayuda con este código

Post by cnavarro »

Enrico, I totally agree with you.
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Post Reply