E na última parte ..... bug?

Projeto [x]Harbour - Compilador de código aberto compatível com o Clipper.

Moderador: Moderadores

Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

E na última parte ..... bug?

Mensagem por JoséQuintas »

nfnotfis.png
Está indicando que o conteúdo 57027 é diferente de 57027....
Comparar usando STR()... piorou....

Código: Selecionar todos

            CASE xField == "IDNOTFIS" .AND. xValue != StrZero( :Number( xField ), 6 )
               lOk := .F.
               SayScroll( jpnotfis->idNotFis + " - ID - [" + jpnotfis->idNotFis + "] - [" + StrZero( :Number( xField ), 6 ) + "]" )
Por mais que eu recompile, isso não entra no EXE....
Já apaguei o EXE, a pasta temporária com fontes C, etc, e o EXE não muda.

Mistérios....

Importante:
Além de comparar com StrZero(x, 6 ) TAMBÉM é pra mostrar com StrZero( x, 6 )

Parece meio esquisito, mas só resta reiniciar o Windows....
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

E na última parte ..... bug?

Mensagem por JoséQuintas »

Sim... bug.... do programador....

Parecia certo, mas não estava...

Código: Selecionar todos

CASE xField == "IDNOTFIS" .AND. xValue != StrZero( :Number( xField ), 6 )
Isso fazia com que fosse usada outra condição, quando o número fosse igual.
Agora sim:

Código: Selecionar todos

            CASE xField == "IDNOTFIS"
               IF xValue != StrZero( :Number( xField ), 6 )
                  lOk := .F.
                  SayScroll( jpnotfis->idNotFis + " - ID - [" + jpnotfis->idNotFis + "] - [" + StrZero( :Number( xField ), 6 ) + "]" )
               ENDIF
Quando era igual, entrava na análise genérica como string.
Justo esse campo, é string no DBF e numérico no MySQL, por isso precisa comparar diferente.
E não dava erro ao entrar na validação como string.

Código: Selecionar todos

STATIC FUNCTION Update0210A()

   LOCAL xValue, xField, xType, nCont, lOk, nTotal
   LOCAL cnMySql := ADOClass():New( AppConexao() )

   IF AppConexao() == NIL
      RETURN NIL
   ENDIF
   SayScroll( "2020/02/10 Apagando DBF JPNOTFIS" )

   IF ! UseSoDbf( "jpnotfis", .T. )
      RETURN NIL
   ENDIF
   GrafTempo( "JPNOTFIS.DBF" )
   DO WHILE RecNo() < 1000 .AND. ! Eof()
      GrafTempo( RecNo(), LastRec() )
      WITH OBJECT cnMySql
         :cSql := "SELECT * FROM JPNOTFIS WHERE IDNOTFIS = " + StringSql( jpnotfis->IdNotFis )
         :Execute()
         lOK := .T.
         FOR nCont = 1 TO FCount()
            xValue := FieldGet( nCont )
            xField := Upper( FieldName( nCont ) )
            xType  := ValType( xValue )
            DO CASE
            CASE xField == "IDNOTFIS"
               IF xValue != StrZero( :Number( xField ), 6 )
                  lOk := .F.
                  SayScroll( jpnotfis->idNotFis + " - ID - [" + jpnotfis->idNotFis + "] - [" + StrZero( :Number( xField ), 6 ) + "]" )
               ENDIF
            CASE xType == "N"
               IF xValue != :Number( xField )
                  lOk := .F.
                  SayScroll( jpnotfis->idNotFis + " - " + xField + " - [" + Str( xValue ) + "] - [" + Str( :Number( xField ) ) + "]" )
               ENDIF
            CASE xType == "D"
               IF xValue != :Date( xField )
                  lOk := .F.
                  SayScroll( jpnotfis->idNotFis + " - " + xField + "- [" + Dtoc( xField ) + "] - [" + Dtoc( :Date( xField ) ) + "]" )
               ENDIF
            OTHERWISE
               IF Trim( xValue ) != :String( xField )
                  lOk := .F.
                  SayScroll( jpnotfis->idNotFis + " - " + xField + " - [" + xValue + "] - [" + :String( xField ) + "]" )
               ENDIF
            ENDCASE
            IF ! lOk
               EXIT
            ENDIF
         NEXT
         :CloseRecordset()
      ENDWITH
      IF lOK
         RecLock()
         DELETE
         RecUnlock()
      ENDIF
      SKIP
   ENDDO
   COUNT TO nTotal
   PACK
   CLOSE DATABASES
   SayScroll( "QT NFs Processadas " + Str( LastRec() - nTotal ) )
   Inkey(100)

   RETURN NIL
É um DBF que vou apagar.
Por precaução, antes de apagar de vez, estou comparando com o salvo no MySQL.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

E na última parte ..... bug?

Mensagem por JoséQuintas »

E mais outra alteração, pra comparar direito:

troquei x != y
por ! x == y

parece a mesma coisa, mas não é.

"ABA" = "A" retorna verdadeiro, enquanto "ABA" == "A" retorna falso

"ABA" != "A" retorna falso, enquanto ! "ABA" == "A" retorna verdadeiro

Só aproveitei que lembrei disso, pra também lembrar aos demais, pra não parecer mais outro bug... rs
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
asimoes
Colaborador
Colaborador
Mensagens: 4919
Registrado em: 26 Abr 2007 16:48
Localização: RIO DE JANEIRO-RJ

E na última parte ..... bug?

Mensagem por asimoes »

Isso vale para comparar número ?
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
rossine
Usuário Nível 3
Usuário Nível 3
Mensagens: 325
Registrado em: 06 Ago 2007 09:57
Localização: Divinópolis-MG

E na última parte ..... bug?

Mensagem por rossine »

Boa tarde,

Para comparar números eu bolei uma função.

Código: Selecionar todos

*************
function main
*************

local aRet

cls

nVar1 := 10.45
nVar2 := 10.453

? COMPARA_NUM( nVar1, nVar2, 10, 2, @aRet, 2 )

? hb_valtoexp(aRet)

nVar1 := 10.45
nVar2 := 10.457

? COMPARA_NUM( nVar1, nVar2, 10, 2, @aRet, 2 )

? hb_valtoexp(aRet)

return NIL

********************
function COMPARA_NUM( nNum1, nNum2, nInt, nDec, aRet, nRound )
********************

   __DefaultNIL( @nInt, 16 )
   __DefaultNIL( @nDec, 0 )
   __DefaultNIL( @nRound, 0 )

   if nRound = 0
      aRet := { strzero( nNum1, nInt, nDec ), strzero( nNum2, nInt, nDec ) }
   else
      aRet := { strzero( round( nNum1, nRound ), nInt, nDec ), strzero( round( nNum2, nRound ), nInt, nDec ) }
   endif

return iif( aRet[1] == aRet[2], .T., .F. )
Rossine.

Harbour 3.4, MingW / Msvc, QT, Qt5xhb, GtQtc, DbfCdx, MySql/MariaDB.
Responder