Su ayuda con este código

Su ayuda con este código

Postby Armando » Fri Mar 11, 2022 11:46 pm

Hola Amigos del foro:

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

Code: Select all  Expand view

   ? "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
Armando
 
Posts: 3061
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Su ayuda con este código

Postby cnavarro » Sat Mar 12, 2022 12:17 am

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
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Su ayuda con este código

Postby Armando » Sat Mar 12, 2022 3:12 am

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
Armando
 
Posts: 3061
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Su ayuda con este código

Postby nageswaragunupudi » Sat Mar 12, 2022 5:38 am

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
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Su ayuda con este código

Postby Armando » Sat Mar 12, 2022 7:18 am

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
Armando
 
Posts: 3061
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Su ayuda con este código

Postby Enrico Maria Giordano » Sat Mar 12, 2022 9:20 am

The opposite of

Code: Select all  Expand view
? "Texto" <> ""


is

Code: Select all  Expand view
? "Texto" = ""


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Su ayuda con este código

Postby cnavarro » Sat Mar 12, 2022 11:16 am

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 view

? "" <> "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
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Su ayuda con este código

Postby Armando » Sat Mar 12, 2022 3:41 pm

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
Armando
 
Posts: 3061
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Su ayuda con este código

Postby Enrico Maria Giordano » Sat Mar 12, 2022 3:55 pm

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

Code: Select all  Expand view
? "Text" <> ""


gives .F. because it is the opposite of

Code: Select all  Expand view
"Text" = ""


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

Code: Select all  Expand view
"" <> "Text"


gives .T. because it is the opposite of

Code: Select all  Expand view
"" = "Text"


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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Su ayuda con este código

Postby cnavarro » Sat Mar 12, 2022 10:01 pm

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
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 92 guests