In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Why don't the string or number comparisons work?

Xailer professional forum in English
Responder
DC
Mensajes: 122
Registrado: Lun May 16, 2011 6:06 pm

Why don't the string or number comparisons work?

Mensaje por DC »

Hi,

In the code below, the problem is that the string and number conversions don't work. Below, we assign 5 to n_Number; and "test" to s_String. But when we run it, the condition is never executed.

I tried setting the 's_BreakPointString := s_BreakPointString' lines as breakpoints, and it never gets there. I also tried stepping through, and the condition is ignored; it just skips to the next line, after the endif.

Código: Seleccionar todo

METHOD TestThis( oSender ) CLASS frm_Test
   Local n_Number := 5
   Local s_String := "test"
   Local s_BreakPointString := "Breakpoint"

   If n_Number == 5
      s_BreakPointString := s_BreakPointString
   Endif

   If s_String == "test"
      s_BreakPointString := s_BreakPointString
   Endif


   s_BreakPointString := s_BreakPointString

RETURN Nil
Adjuntos
Test.zip
(2.16 KiB) Descargado 186 veces
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9246
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: Why don't the string or number comparisons work?

Mensaje por ignacio »

Hi,

All the IF..ENDIF conditions are true and its internal code is evaluated. Please try this version of your code and see on the debugger windows how the logdebug() calls are excuted.

Regards

Código: Seleccionar todo

METHOD Button1Click( oSender ) CLASS TForm1

   Local n_Number := 5
   Local s_String := "test"
   Local s_BreakPointString := "Breakpoint"

   If n_Number == 5
      s_BreakPointString := s_BreakPointString
      LogDebug( "1" )
   Endif

   If s_String == "test"
      s_BreakPointString := s_BreakPointString
      LogDebug( "2" )
   Endif

   s_BreakPointString := s_BreakPointString
   LogDebug( "3" )

RETURN Nil
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
DC
Mensajes: 122
Registrado: Lun May 16, 2011 6:06 pm

Re: Why don't the string or number comparisons work?

Mensaje por DC »

If the LogDebug() statements are thrown in, then they are executed.

But the statement

s_BreakPointString := s_BreakPointString


is never reached. It's just skipped over.

It looks like Harbour is just ignoring trivial statements that assign variables to themselves.

Anyway, I seem to have the main program working now, so it doesn't matter now. It was related to some Sql Server tables that were generating an error when they were opened, specifically when the load() method was executed.

If any further problems, I'll check in, thanks.
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9246
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: Why don't the string or number comparisons work?

Mensaje por ignacio »

Hello,

Compilers, at least, MingGW simply ignores useless code on a lot of circunstancies. Is a really smart guy! :)

Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Responder