Page 1 of 1

Why doesn't the program show "yes"

Posted: Sat Nov 14, 2020 2:14 pm
by huiyi_ch
Hello friends
Today, when I was debugging a program, I found a strange phenomenon. The program should display "yes", that is, "no". I don't know why? This problem also exists in pb12.

Code: Select all

#include <hmg.ch>
PROCEDURE Main()
local   ddd
ddd="±"+"13213213132"

if hb_at("±",ddd)>1
         msginfo("Yes","info")
else
         msginfo("No","info")
end if 
return
 

Re: Why doesn't the program show "yes"

Posted: Sat Nov 14, 2020 3:21 pm
by Carlos Britos
Hi
I'm sure what you mean when you say
should display "yes", that is, "no"
"±"+"13213213132" ---> ± is in pos 1
hb_at("±",ddd)>1 = .F.

hb_at("±",ddd)>0 = .T.

Re: Why doesn't the program show "yes"

Posted: Sat Nov 14, 2020 6:33 pm
by SALINETAS24
huiyi_ch wrote: Sat Nov 14, 2020 2:14 pm Hello friends
Today, when I was debugging a program, I found a strange phenomenon. The program should display "yes", that is, "no". I don't know why? This problem also exists in pb12.

Code: Select all

#include <hmg.ch>
PROCEDURE Main()
local   ddd
ddd="±"+"13213213132"

if hb_at("±",ddd)>1
         msginfo("Yes","info")
else
         msginfo("No","info")
end if 
return
 
Hola Huiyi_ch.
La función hb_at devuelve la posición que ocupa una subcadena en una cadena.
En tu ejemplo, la subcadena "±" ocupa la posición "=1"..., y NO mayor ">1"
Prueba el siguiente codigo.

Code: Select all

if hb_at("±",ddd) > 0      // Encontrada
         msginfo("Yes","info")
else
         msginfo("No","info")
end if 
Una cervecita fresquita con una saludo virtual.....

Re: Why doesn't the program show "yes"

Posted: Sun Nov 15, 2020 1:33 am
by huiyi_ch
Thank you for your help!
I'm sorry, I made a very stupid mistake!