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
DC
Posts: 59
Joined: Mon May 16, 2011 6:06 pm

Why don't the string or number comparisons work?

Postby DC » Mon Jul 24, 2017 6:06 pm

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.


Code: Select all

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
Attachments
Test.zip
(2.16 KiB) Downloaded 35 times
User avatar
ignacio
Site Admin
Posts: 8574
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

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

Postby ignacio » Mon Jul 24, 2017 6:24 pm

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

Code: Select all

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]
http://www.xailer.com
http://www.xailer.info
DC
Posts: 59
Joined: Mon May 16, 2011 6:06 pm

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

Postby DC » Mon Jul 24, 2017 7:27 pm

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.
User avatar
ignacio
Site Admin
Posts: 8574
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

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

Postby ignacio » Tue Jul 25, 2017 1:12 pm

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]
http://www.xailer.com
http://www.xailer.info

Return to “English”