Transformando o ebook em aplicativo

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

Moderador: Moderadores

Avatar do usuário
Vlademiro
Usuário Nível 4
Usuário Nível 4
Mensagens: 752
Registrado em: 11 Jul 2005 02:46

Transformando o ebook em aplicativo

Mensagem por Vlademiro »

Estou pensando em converter o ebook que escrevi em um aplicativo para facilitar o aprendizado de novos usuários. Considero o Harbour uma linguagem muito boa, apesar de desconhecida.

O objetivo é :

1. Fazer com que o usuário leigo não precise instalar o Harbour para conhecer a linguagem, quebrando essa barreira inicial.
2. Converter o que eu fiz no ebook em um conteúdo mais dinâmico.
3. Criar um conteúdo de fácil entendimento para leigos. Mesmo que eles decidam, no futuro, investir em outra linguagem o conteúdo vai servir.

Fiz um teste :

https://drive.google.com/drive/folders/ ... sp=sharing

É um servidor web com o curso em um formato mais dinâmico. Basta descompactar e executar o bat _start.bat (tem que desbloquear a porta 8002)

Use o navegador em http://localhost:8002

Se alguém quiser testar pode comentar aqui mesmo.
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Transformando o ebook em aplicativo

Mensagem por JoséQuintas »

Descobri há pouco tempo uma coisa interessante na documentação do Harbour:
Conversão em formato JSON.
Fica tudo disponível no Harbour, para pesquisa via hbmk2.

O formato json pode ser convertido em um array, e a partir daí, dá pra brincar à vontade.
E como extra, o arquivo pode ser adicionado como resource.
Neste caso, precisa do arquivo na compilação, mas fica embutido no EXE pra uso posterior.
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
Vlademiro
Usuário Nível 4
Usuário Nível 4
Mensagens: 752
Registrado em: 11 Jul 2005 02:46

Transformando o ebook em aplicativo

Mensagem por Vlademiro »

Como é isso ?
Daria para dar um exemplo ? Parece ser um ótimo recurso para gerar material para estudo.
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Transformando o ebook em aplicativo

Mensagem por JoséQuintas »

A documentação do Harbour, dá pra comparar com uma base de dados.
tem lá: NAME, SYNTAX, RETURN, DESCRIPTION, etc.

O formato json, permite dar nomes, ou usar como array.
Mais ou menos isto:

Código: Selecionar todos

[ 
   { "NAME: nome", 
     "SYNTAX: xxxxxx",
     "RETURN: xxxxx", ;
     "DESCRIPTION: xxxxx"
   },
   { "NAME: nome", 
     "SYNTAX: xxxxxx",
     "RETURN: xxxxx", ;
     "DESCRIPTION: xxxxx"
   }
]
O hbmk2 acaba permitindo pesquisar pelo nome.

hbmk2 -find nome
hbmk2 -doc nome

o find pesquisa, e o doc mostra documentação.

O manual é salvo em formato json, com a extensão hbd.

Pode criar usando array/hash array.
depois salvar como hb_JsonEncode( aArray )
E na leitura é o oposto: hb_JsonDecode( cTxt )
Assim já entram todas as conversões necessárias, de mudança de linha e/ou caracteres diferentes.

É ilimitado.

O resultado final é o manual ficar em uma única variável.
Essa variável vai funcionar como um banco de dados, que pode conter divisões/sub-divisões.
Se seguir o padrão da documentação do Harbour, basta salvar com extensão hbd na pasta de doc do Harbour.
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
Vlademiro
Usuário Nível 4
Usuário Nível 4
Mensagens: 752
Registrado em: 11 Jul 2005 02:46

Transformando o ebook em aplicativo

Mensagem por Vlademiro »

Vou ver aqui. Sabia do find, mas o doc não conhecia.

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

Transformando o ebook em aplicativo

Mensagem por JoséQuintas »

Só um exemplo do doc Harbour:

Código: Selecionar todos

/* $DOC$
   $AUTHOR$
      2016 Pete D. <pete_westg@yahoo.gr>
   $TEMPLATE$
      Function
   $NAME$
      hb_AtI()
   $CATEGORY$
      API
   $SUBCATEGORY$
      Strings
   $ONELINER$
      Locates the position of a substring in a main string.
   $SYNTAX$
      hb_AtI( <cSearch>, <cString>, [<nStart>], [<nEnd>] ) --> nPos
   $ARGUMENTS$
      <cSearch> the sub-string to search for

      <cString> The main string to search into, for <cSearch>

      <nStart> Beginning search position into <cString>, default: 1

      <nEnd> Ending search position, default: Length of <cString> (i.e. entire <cString>)

   $RETURNS$
      hb_AtI() returns the position (if any), into main string,
      where first time the substring appears.
   $DESCRIPTION$
      This function has same functionality as hb_At() with the significant
      difference that it's case Insensitive.

      Optionally, with <nStart> can be defined the position into main string
      from where the search of <cSearch> must begin and with <nEnd> the position
      where it must stop. If neither of them is defined, <nStart> is 1st position
      and <nEnd> the ending of <cString>.
   $EXAMPLES$
      ? hb_At( "AS", "as simple as possible", 5 )   // --> 0
      ? hb_AtI( "AS", "as simple as possible", 5 )  // --> 11
   $STATUS$
      R
   $COMPLIANCE$
      H
   $PLATFORMS$
      All
   $FILES$
      Library is core
   $SEEALSO$
      hb_At()
   $END$
 */
Aqui o teste básico que fiz pra converter, pegando alguns blocos, mas foi só pra um item.

Código: Selecionar todos

#include "directry.ch"

PROCEDURE Main

   LOCAL aDocList, cJSON, aTxtList, cTxt, aFile

   SetMode(25,80)
   CLS
   Inkey(0)
   aDocList := Directory( "*.txt" )
   cJSON := "[" + hb_LF()
   FOR EACH aFile IN aDocList
      aTxtList := hb_RegExSplit( "$END$", MemoRead( aFile[ F_NAME ] ) )
      FOR EACH cTxt IN aTxtList
         cJSON += "{" + hb_LF()
         cJSON += [ "NAME: ] + FromTo( cTxt, "NAME", "SYNTAX" ) + [" ,] + hb_LF()
         cJSON += [ "SYNTAX: ] + FromTo( cTxt, "SYNTAX", "RETURNS" ) + [", ] + hb_LF()
         cJSON += [ "RETURN: ] + FromTo( cTxt, "RETURNS", "DESCRIPTION" ) + [", ] + hb_LF()
         cJSON += [ "DESCRIPTION: ] + FromTo( cTxt, "DESCRIPTION", "END" ) + ["]
         cJSON += [, ] + hb_LF()
      NEXT
   NEXT
   cJSON := Left( cJSON, Len( cJSON ) - 2 )
   cJSON += hb_LF() + "]" + hb_LF()
   hb_MemoWrit( "hwgui.hbd", cJSON )

   RETURN

FUNCTION hb_LF()

   RETURN Chr(10)

FUNCTION FromTo( cTxt, cFrom, cTo )

   LOCAL nPosi, nPosf

   cTxt := StrTran( cTxt, hb_EOL(), hb_LF() )
   nPosi := hb_At( "$" + cFrom + "$", cTxt ) + Len( cFrom ) + 3
   nPosf := hb_At( "$" + cTo + "$", cTxt ) - 1
   IF nPosf == 0
      nPosf := Len( cTxt )
   ENDIF
   cTxt := Substr( cTxt, nPosi, nPosf - nPosi + 1 )
   DO WHILE Left( cTxt, 1 ) == hb_LF()
      cTxt := Substr( cTxt, 2 )
   ENDDO
   DO WHILE Right( cTxt, 1 ) == hb_LF()
      cTxt := Left( cTxt, Len( cTxt ) - 1 )
   ENDDO
   cTxt := StrTran( cTxt, hb_LF(), "\n" )

   RETURN AllTrim( cTxt )
basicamente a rotina pega o que tem entre $NAME$ e $SYNTAX$, entre $SYNTAX$ e $RETURN$, etc.
E cria o TXT como json, com a extensão hbd, pronto pra ser usado pelo hbmk2.
Foi um teste só pra um comando, pra ver se funcionava.
Falta ajustar "}" e "]" pra fechar conjuntos de muitos comandos, e até de um comando só.
Fiz o acerto manualmente no teste.
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
Vlademiro
Usuário Nível 4
Usuário Nível 4
Mensagens: 752
Registrado em: 11 Jul 2005 02:46

Transformando o ebook em aplicativo

Mensagem por Vlademiro »

Ficou muito bom. Amanhã vou fazer uns testes.
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Transformando o ebook em aplicativo

Mensagem por JoséQuintas »

Código: Selecionar todos

hbmk2 -find hb_ati

Núcleo Harbour (instalado):
   hb_AtI()

Código: Selecionar todos

hbmk2 -doc hb_ati

AUTHOR
------
2016 Pete D. <pete_westg@yahoo.gr>

TEMPLATE
--------
Function

NAME
----
hb_AtI()

CATEGORY
--------
API

SUBCATEGORY
-----------
Strings

ONELINER
--------
Locates the position of a substring in a main string.

SYNTAX
------
hb_AtI( <cSearch>, <cString>, [<nStart>], [<nEnd>] ) --> nPos

ARGUMENTS
---------
<cSearch> the sub-string to search for

<cString> The main string to search into, for <cSearch>

<nStart> Beginning search position into <cString>, default: 1

<nEnd> Ending search position, default: Length of <cString> (i.e. entire <cString>)


RETURNS
-------
hb_AtI() returns the position (if any), into main string,
where first time the substring appears.

DESCRIPTION
-----------
This function has same functionality as hb_At() with the significant
difference that it's case Insensitive.

Optionally, with <nStart> can be defined the position into main string
from where the search of <cSearch> must begin and with <nEnd> the position
where it must stop. If neither of them is defined, <nStart> is 1st position
and <nEnd> the ending of <cString>.

EXAMPLES
--------
? hb_At( "AS", "as simple as possible", 5 )   // --> 0
? hb_AtI( "AS", "as simple as possible", 5 )  // --> 11

SEEALSO
-------
hb_At()
Antigamente eu achava que isso vinha dos fontes do Harbour, das pastas doc.
Depois é que vi que tudo estava transformado em json.

Código: Selecionar todos

 Pasta de d:\harbour\doc

26/08/2020  08:55           269.579 gtwvw.hbd
28/08/2020  21:08           641.930 harbour.hbd
26/08/2020  08:55           186.621 hbct.hbd
26/08/2020  08:55            18.759 hbgt.hbd
26/08/2020  08:55            11.625 hbmisc.hbd
26/08/2020  08:55           275.894 hbnf.hbd
26/08/2020  08:55             5.872 hbxpp.hbd
26/08/2020  08:55            17.095 hbziparc.hbd
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
Vlademiro
Usuário Nível 4
Usuário Nível 4
Mensagens: 752
Registrado em: 11 Jul 2005 02:46

Transformando o ebook em aplicativo

Mensagem por Vlademiro »

Acho q vou ligar o computador de novo.
Avatar do usuário
ANDRIL
Usuário Nível 5
Usuário Nível 5
Mensagens: 1297
Registrado em: 06 Jul 2004 00:44
Contato:

Transformando o ebook em aplicativo

Mensagem por ANDRIL »

O meu hbmk2 NÃO tem a opção -doc, quando coloco na linha de comando dá
hbmk2 -doc hb_atokens
Harbour 3.2.0dev (r1502201040)
Copyright (c) 1999-2015, http://harbour-project.org/
Cannot open hb_atokens.prg, assumed external

No code generated.
hbmk2: Erro: Executando o compilador Harbour (interno): 1
(e:\hb32\bin\harbour.exe) -n2 hb_atokens.prg -doc -oC:\Users\usuario\AppData\Loc
al\Temp\hbmk_gwkpwl.dir\ -ie:\hb32\include
Estou com a versão
Harbour Make (hbmk2) 3.2.0dev (r2015-02-20 10:40)
Copyright (c) 1999-2013, Viktor Szakáts
Clipper 5.2e / Blinker 5.1 / Harbour 3.2 / GTwvg
Avatar do usuário
Vlademiro
Usuário Nível 4
Usuário Nível 4
Mensagens: 752
Registrado em: 11 Jul 2005 02:46

Transformando o ebook em aplicativo

Mensagem por Vlademiro »

Testa com uma versão mais nova. O seu é de 2015.
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Transformando o ebook em aplicativo

Mensagem por JoséQuintas »

Vixe...
Será que só tem isso no 3.4 ?

Dá uma olhada no help.
hbmk2 -longhelp
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

Transformando o ebook em aplicativo

Mensagem por JoséQuintas »

hbmk2.png

Só aproveitando que apareceu na tela, não tem a ver com doc, mas pode interessar pra outros:
Também aceita projetos do hbmake, xBuild ou xMate.
Acho que são builds do XHarbour.
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