Harbour e a IA, chegamos lá!

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

Moderador: Moderadores

Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 7928
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 1 vez

Harbour e a IA, chegamos lá!

Mensagem por Itamar M. Lins Jr. »

Olá!
https://hf.co/chat/assistant/66229318ae991ee8ad79a177
Screenshot_20240420_002015.png
Imagem

Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Harbour e a IA, chegamos lá!

Mensagem por JoséQuintas »

sei lá....
teste1.png
teste2.png
Acho que ela precisa que eu ensine pra ela fazer mais fácil kkkkk
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
sygecom
Administrador
Administrador
Mensagens: 7131
Registrado em: 21 Jul 2006 10:12
Localização: Alvorada-RS
Contato:

Harbour e a IA, chegamos lá!

Mensagem por sygecom »

A ideia é muito boa, talvez até para ensinar nos próprios sistemas.
Leonardo Machado
xHarbour.org + Hwgui + PostgreSql
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Harbour e a IA, chegamos lá!

Mensagem por JoséQuintas »

Sim, durante discussões comentaram sobre alimentar com as bases de dados.
A partir daí, pedir análises ou relatórios.


Sobre a resposta de IA, só fiz lá uma pergunta, e a resposta foi mais complexa do que deveria.
Mas talvez tenha faltado prosseguir e perguntar sobre soluções mais simples.
De qualquer forma, é direcionado a harbour.
Daí pra frente, questão de tempo.

Também lembro do Linares comentar sobre alimentar a IA com o fórum dele, pra ver que o que aconteceria.
Isso antes disso que vém sendo feito agora.

Um dos comentários é precisar mais de 16GB de RAM...
Não vai ser qualquer computador, apesar que já vi comentários que o Windows 12 vai exigir isso.
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

Harbour e a IA, chegamos lá!

Mensagem por JoséQuintas »

create a textbox on harbour

Código: Selecionar todos

#include "hbclass.ch"

CLASS TextBox

   DATA text INIT ""
   DATA x INIT 10
   DATA y INIT 10
   DATA width INIT 200
   DATA height INIT 20

   METHOD init( x, y, width, height )
   METHOD setText( text )
   METHOD getText()
   METHOD handleEvent( event )

ENDCLASS

METHOD init( x, y, width, height ) CLASS TextBox
   ::x := x
   ::y := y
   ::width := width
   ::height := height
   return nil

METHOD setText( text ) CLASS TextBox
   ::text := text
   return nil

METHOD getText() CLASS TextBox
   return ::text

METHOD handleEvent( event ) CLASS TextBox
   if event:Type == HB_EV_KEYPRESS
      if event:KeyCode == HB_K_ENTER
         // handle enter key press
      endif
   endif
   return nil

// create a textbox instance
local tb := TextBox():new( 10, 10, 200, 20 )

// set the text
tb:setText( "Hello, World!" )

// display the textbox
DispBox( tb:x, tb:y, tb:width, tb:height, tb:text )

// handle events
DO WHILE.T.
   local event := HB_GenerateEvent()
   tb:handleEvent( event )
ENDDO
This code creates a TextBox class with properties for text, x, y, width, and height. It also has methods for initializing the textbox, setting and getting the text, and handling events.

In the example code, we create a new instance of the TextBox class, set the text, and display the textbox using DispBox. We then enter an event loop to handle events, such as key presses.

Note that this is a very basic example, and you may want to add more features to your textbox class, such as handling mouse events, scrolling, and so on.
Conclusão até aqui:
Deve ter sido alimentado com fivewin.
Mas é só ir alimentando mais.

Como classe, está boa, textbox pode ser considerado um box pra texto, não precisa necessariamente ter digitação.
SetText() e GetText() parecem estilo xbase, seria mais interessante VALUE.
DispBox() acho que já existe no harbour, não tenho certeza.
Os demais são comuns em GUI, estão no estilo comum.
Se depender de console, trocaria HB_GenerateEvent() por Inkey(), seria quase isso, mas dá uma idéia de centralizar/generalizar.

Putz, gostei do HandleEvent(Event) !!!!!!
É uma coisa que as LIBs poderiam ter feito há muito tempo pra facilitar !!!!!!
É.... porque trazer API Windows para os fontes, se dá pra fazer estilo xbase.
É pra se pensar nesse uso, achei muito interessante, simples e funcional.
Só vai ser ruim fazer toda hora um de/para, mas isso ficaria centralizado.
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

Harbour e a IA, chegamos lá!

Mensagem por JoséQuintas »

Código: Selecionar todos

METHOD handleEvent( event ) CLASS TextBox
   if event:Type == HB_EV_KEYPRESS
      if event:KeyCode == HB_K_ENTER
Essa parte aí.
Quem mexe com minigui nem deve saber do que se trata, não é tão visível.
Fica visível em HWGUI ou GTWVG.

O intessante é também o HB_EV_KEYPRESS, termo usado no VB6, e o tratamento de teclas pelo harbour.
Esse negócio de testar VK_RETURN é chato, aí mostra que com rotina intermediária usaria a configuração de teclas do harbour.

Agora sim, comecei a gostar dessa IA, até me cadastrei, porque acabou o limite pra convidados.

Nota:
Mas pedi uma rotina de checagem de CNPJ e ela morreu kkkk
Não existe isso na Espanha....
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

Harbour e a IA, chegamos lá!

Mensagem por JoséQuintas »

Pedi pra analisar ze_digitodoc.prg da sefazclass.
I've reviewed your functions, and here are some observations and suggestions:

Function naming conventions

Your function names are mostly descriptive and follow a consistent naming convention. However, I noticed that some functions have underscores (e.g., Valid_Cnpj_Cpf) while others don't (e.g., ValidCnpj). To maintain consistency, I suggest using underscores to separate words in function names.

Function organization

Your functions are organized into related groups (e.g., CNPJ, CPF, RENAVAM, etc.). This is a good practice, as it makes it easier to find and maintain related functions.

Code style

Your code is generally well-formatted, with consistent indentation and spacing. However, I noticed some inconsistencies in the use of whitespace between lines and around operators. To maintain readability, I suggest using a consistent number of spaces around operators and between lines.

Functionality

I didn't test your functions extensively, but they appear to be implementing various validation and formatting rules for different types of Brazilian documents (e.g., CNPJ, CPF, RENAVAM, etc.). The functions seem to be well-structured and easy to follow.

Suggestions

Consider adding more comments to your functions, especially for complex calculations or algorithms. This will make it easier for others (and yourself) to understand the code.
You might want to consider using more descriptive variable names, especially for temporary variables. This will make the code easier to read and understand.
In some functions, you're using hb_Default to set default values for parameters. While this is a good practice, you might want to consider using more explicit default values or error handling for invalid input.
Some functions have similar logic or calculations. You might want to consider extracting common functionality into separate functions or modules to reduce code duplication.
Overall, your functions appear to be well-structured and easy to follow. With some minor adjustments to naming conventions, code style, and commenting, they can be even more maintainable and readable.
translate to brasilian

Here is the translation of my previous response to Brazilian Portuguese:

Convenções de nomenclatura de funções

Os nomes das suas funções são em sua maioria descritivos e seguem uma convenção de nomenclatura consistente. No entanto, notei que algumas funções têm underscores (ex: Valid_Cnpj_Cpf) enquanto outras não (ex: ValidCnpj). Para manter a consistência, sugiro usar underscores para separar palavras nos nomes de funções.

Organização de funções

As suas funções estão organizadas em grupos relacionados (ex: CNPJ, CPF, RENAVAM, etc.). Isso é uma boa prática, pois torna mais fácil encontrar e manter funções relacionadas.

Estilo de código

O seu código está geralmente bem formatado, com indentação e espaçamento consistentes. No entanto, notei algumas inconsistências no uso de espaços entre linhas e ao redor de operadores. Para manter a legibilidade, sugiro usar um número consistente de espaços ao redor de operadores e entre linhas.

Funcionalidade

Não testei suas funções extensivamente, mas elas parecem implementar várias regras de validação e formatação para diferentes tipos de documentos brasileiros (ex: CNPJ, CPF, RENAVAM, etc.). As funções parecem estar bem estruturadas e fáceis de seguir.

Sugestões

Considere adicionar mais comentários às suas funções, especialmente para cálculos ou algoritmos complexos. Isso tornará mais fácil para os outros (e para você mesmo) entender o código.
Você pode querer considerar usar nomes de variáveis mais descritivos, especialmente para variáveis temporárias. Isso tornará o código mais fácil de ler e entender.
Em algumas funções, você está usando hb_Default para definir valores padrão para parâmetros. Embora isso seja uma boa prática, você pode querer considerar usar valores padrão mais explícitos ou tratamento de erro para entrada inválida.
Algumas funções têm lógica ou cálculos semelhantes. Você pode querer considerar extrair funcionalidade comum em funções ou módulos separados para reduzir a duplicação de código.
No geral, as suas funções parecem estar bem estruturadas e fáceis de seguir. Com algumas ajustes menores nas convenções de nomenclatura, estilo de código e comentários, elas podem ser ainda mais mantidas e legíveis.
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

Harbour e a IA, chegamos lá!

Mensagem por JoséQuintas »

pode fazer e me mostrar alguns ajustes?

Here are some adjustments I made to your code:

Function naming conventions

I added underscores to separate words in function names:

Código: Selecionar todos

FUNCTION Valid_Cnpj_Cpf( cValue )
...
FUNCTION Format_Cnpj( cValue )
...
Code style

I added consistent spacing around operators and between lines:

Código: Selecionar todos

LOCAL lOk :=.F.
LOCAL nSoma := 0
LOCAL cChar
...
IF Val( cCodigo ) == 0
   cCodigo := Pad( "SEM GTIN", 14 )
ELSE
   cCodigo := SoNumeros( cCodigo )
  ...
Comments

I added comments to explain the purpose of each function and some complex calculations:

Código: Selecionar todos

/*
 * Validates a CNPJ (Brazilian company ID) number
 */
FUNCTION Valid_Cnpj( cCnpj )
  ...
/*
 * Calculates the digit of a CNPJ number
 */
FUNCTION Calcula_Digito( cNumero, cModulo )
  ...
Variable naming
I used more descriptive variable names:

Código: Selecionar todos

LOCAL cCnpj_Fornecido := cCnpj
LOCAL nSoma_Digitos := 0
LOCAL cChar_Atual
...
Code organization

I grouped related functions together:

Código: Selecionar todos

// CNPJ validation functions
FUNCTION Valid_Cnpj( cCnpj )
...
FUNCTION Calcula_Digito( cNumero, cModulo )
...

// CPF validation functions
FUNCTION Valid_Cpf( cCpf )
...
These are just some minor adjustments to improve code readability and maintainability. Let me know if you have any specific requests or questions!
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/
Responder