Jump to content
Fivewin Brasil

MatheusFarias

Membros
  • Posts

    69
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by MatheusFarias

  1. Se teu programa tem alguma variável declarada ou atribuída mesmo que não esteja com nenhum escopo(local,static,public,private) ele com certeza esta criticando isso. 

     

    verifica ai se não tem nenhuma atribuição, por exemplo:  banco="algo" ou banco:=" " 

    outra coisa é que dependendo da situação o forma como usa o IF nas comparações pode ser entendido como uma atribuição, se recentemente adicionou SET EXACT ON no código isso deve ser um dos motivos.

    Se usar o XDevStudio, manda um [CTRL]+[SHIFT]+[F3] e procura nos prgs da sua pasta, ou se não usa baixa o sublime text ou notepad++

     

  2.       cTextoAbreGaveta := ""
          nModeloComandoLocal := 1
          IF "MP" $ UPPER(PrnGetName()) // Bematech
             cTextoAbreGaveta := CHR(29) +CHR(249) +CHR(32) +CHR(0) +CHR(27) +CHR(116) +CHR(8) +CHR(27) +CHR(118) +CHR(140)
          ENDIF
          *
          IF "DARUMA" $ UPPER(PrnGetName())
             cTextoAbreGaveta := CHR(27) +CHR(112)
          ENDIF
          *
          IF "EPSON" $ UPPER(PrnGetName())
             cTextoAbreGaveta := chr(027)+chr(112)+chr(000)+chr(010)+chr(100)
             nModeloComandoLocal := 2
          ENDIF
          *
          *cCaminhoTXT := CurDrive()+":\"+CurDir()+"\GAVETA.TXT"
          cCaminhoTXT := "C:\SISTEMA\GAVETA.TXT"
          MemoWrit(cCaminhoTXT,cTextoAbreGaveta)
          cDestinoComando := ""
          if left(cImpressoraPadraoAbertura,2) == "\\"
             cDestinoComando := '"'+cImpressoraPadraoAbertura+'"'
          else
             do case
             case nModeloComandoLocal == 1
                cDestinoComando := PrnGetPort()
             case nModeloComandoLocal == 2
                cDestinoComando := '"'+"\\127.0.0.1\"+alltrim(PrnGetName())+'"'
             endcase
          endif
          *
          cComandoGaveta := 'CMD.EXE /C COPY '+cCaminhoTXT+' '+cDestinoComando
          WaitRun(cComandoGaveta,0)
          *

    **PS: A EPSON PRECISA ESTA COMPARTILHADA

  3. Cara sempre que preciso fazer isso faço a seguinte sequencia:

     

    → nConexao := Abre a conexão

    →SR_SetActiveConnection (nConexao)

    → Abre a tabela

    → nConexao2:=Abre a conexão 2

    →SR_SetActiveConnection (nConexao2)

    → Abre a tabela

    →SR_SetActiveConnection (nConexao)

    Depois que abri as tabelas cada qual em sua conexao pode ser feliz.

     

    Uso isso muito na consultas de produtos com estoques de matriz e filiais

    **PS: nConexaoPrincipal e nConexaoAtual são usadas para controlar o nº da conexão que estou trabalhando

    	   nConexaoPrincipal := nConexaoAtual
    	   select cemp
    	   go top
    	   While !Eof()
    	      if !Empty(cemp->cip) .and. alltrim(upper(cemp->cip)) == alltrim(upper(cIp)) .and. vcodiemp # cemp->cod_emp
    	         if ConectarOutraBase(cemp->cdatabase)
    	            SR_SetActiveConnection(nConexaoAtual)
    					if SR_ExistIndex("PRODUTOS")
    	               cAliasNovo:=cGetNewAlias("PRO")
    	               DbUseArea(.t.,"SQLRDD","PRODUTOS",cAliasNovo,.T.,.F.)
    	               IF NetErr()
    	                  MsgInfo("Arquivo Não Disponível no Momento" + CRLF + "PRODUTOS","Tente Novamente-Filial")
    	                  Dbcloseall()
    	                  Return .F.
    	               Endif
    	               (cAliasNovo)->(DbSetIndex())
    	               aadd(aALIAS_PRO,cAliasNovo)
    	               aadd(aConex_PRO,nConexaoAtual)
    	            else
    	               MsgWait("Não existe Índices para produtos na filial")
    	            endif
    	         endif
    	      endif
    	      select cemp
    	      skip
    	   End
    	   nConexaoAtual := nConexaoPrincipal
    	   SR_SetActiveConnection(nConexaoAtual)
    Function ConectarOutraBase(pDatabase)
    	lRetorno := .t.	   
    	
       fileMysql:=MemoRead("sql.ini")
       aDadosMysql:=HB_ATokens(fileMysql,CRLF)
       if len(aDadosMysql) > 5
          tcIp:=aDadosMysql[1]
          tcUser:=aDadosMysql[2]
          tcPassword:=aDadosMysql[3]
          tcPort:=aDadosMysql[5]
       else
          return .f.
       endif
    
       scriptConectarMysql:="MySQL="+alltrim(tcIp)
       scriptConectarMysql+=";UID=" +alltrim(tcUser)
       scriptConectarMysql+=";PWD=" +alltrim(tcPassword)
       scriptConectarMysql+=";DTB=" +alltrim(pDatabase)
       scriptConectarMysql+=";PRT=" +alltrim(tcPort)
       *
    	nConexaoAnterior := nConexaoAtual
    	*
       nConexaoAtual := SR_AddConnection(CONNECT_MYSQL,scriptConectarMysql)
       
       IF nConexaoAtual > 0
          Try
             SR_CheckConnection()
          catch
             lRetorno := .f.
          end
          SR_SetExclusiveManagement(.t.)
          SR_MaxRowCache(200)
          SR_FetchSize( 100 )
       ELSE
          lRetorno := .f.
       ENDIF
       return lRetorno

     

  4.  

     cHtml:=oIE:Document():All(0):OuterHTML

     

    olha a variável cHtml, e os comando depois da linha acima, dentro da rotina,

    Dentro da variável cHtml, ficha a página que contém os dados do xml da nfe capturada.

     

    ela baixa automático, falta corrigir o erro que mencionei

    Jovem qual a versão do FW que usa, no meu ja esta ok. Agora eu uso o captcha novo

  5.  

    Perfect Giovany Vecchi, many thanks!

     

    
    #include "FiveWin.ch"
    	#define  HKEY_LOCAL_MACHINE      2147483650
    	STATIC oWnd, oActivex
    	FUNCTION Main()
    	   LOCAL oBar
    	   /*
      http://fivewin.com.br/index.php?/topic/27339-problema-na-busca-do-cnpj-site-da-receita/
    	  http://forums.fivetechsupport.com/viewtopic.php?f=6&t=34901
       */
       INTER_APP_WEB_CONFIG("TESTE2.exe",11001)
    	   DEFINE WINDOW oWnd TITLE "Google Action"
    	   DEFINE BUTTONBAR oBar _3D OF oWnd
    	   DEFINE BUTTON OF oBar ACTION Receita( oWnd )
    	   SET MESSAGE OF oWnd TO "Google Action" NOINSET CLOCK DATE KEYBOARD
    	   ACTIVATE WINDOW oWnd
    	RETURN NIL
    	Function Receita( oWnd )
    	   Local cPortal
       local cEvents := ""
    	   If !IsInternet()
    	      Msgalert("Não conectado a internet.", "Aviso!")
    	      Return nil
    	   Endif
    	   MsgWait( "CONECTANDO AO PORTAL DA RECEITA ", ;
                "AGUARDE...                      ", 3.0 )
    	   DEFINE WINDOW oWnd FROM 0,0 TO 600,800 PIXEL TITLE "Receita.GOV"
    	   // oActiveX = TActiveX():New( oWnd, "Shell.Explorer.2" )  // nao funciona no IE
       // nao funciona no IE
       @ 0, 0 ACTIVEX oActiveX PROGID "Shell.Explorer.2" OF oWnd 
    	   oWnd:oClient = oActiveX
    	   // oActiveX:GoHome()
       oActivex:Silent     := .T.
       oActiveX:FullScreen := .T.
       oActiveX:Visible    := .T.
       oActiveX:ToolBar    := .T.
       oActiveX:StatusBar  := .T.
       oActiveX:MenuBar    := .T.
       oActivex:SetFocus()
    	   oActiveX:Do( "Navigate2", "https://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp" )
    	   oActiveX:bOnEvent = { | event, aParams, pParams | cEvents += EventInfo( event, aParams, pParams, oActiveX ) }
    	   ACTIVATE WINDOW oWnd CENTER ;
          VALID ( MemoEdit( cEvents ), .t. )
    	   // VALID( oActiveX:End() )
    	   // Com ShellExecute funciona perfeito no chrome.
    	   /*
       cPortal := "https://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp"
    	   If !IsInternet()
    	      Msgalert("Não conectado a internet.", "Aviso!")
    	      Return nil
    	   Endif
    	   MsgWait( "CONECTANDO AO PORTAL DA SEFAZ...", ;
                "AGUARDE...                      ", 3.0 )
    	   // Executa o navegador padrao... Google Chrome nao gosto do IE.
       ShellExecute( GetActiveWindow(), "open", cPortal,,,9 )
       */
    	Return nil
    	function EventInfo( event, aParams, pParams, oActiveX )
    	   local cMsg := "Evento: " + cValToChar( event ) + CRLF
       local n
       
       cMsg += "Params: " + CRLF
       
       for n = 1 to Len( aParams )
          cMsg += cValToChar( aParams[ n ] ) + CRLF
       next
       
       if event == "BeforeNavigate2"
          // MsgInfo( aParams[ 2 ] )
          // SetEventParam( pParams, 7, .t. ) // Comment this to allow navigation
       endif   
    	return cMsg + CRLF
    	/*
    Parametrize seu programa com a versão do seu navegador atual.
    	Ex: se seu navegador for iexplorer 11 coloque assim
    	INTER_APP_WEB_CONFIG("SeuPrograma.exe",11001)
    */
    	FUNCTION INTER_APP_WEB_CONFIG(f_cNameProg,f_nVersion_IE)
    	   Local oRegKey, cRegProgGet, lDeleteKey := .f.
      
       Default f_nVersion_IE := 11001
    	   if IsWow64()
        
          oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
               "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" )
          oRegKey:Set(f_cNameProg,f_nVersion_IE,4)
          oRegKey:Close()
    	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
               "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_AJAX_CONNECTIONEVENTS" )
          oRegKey:Set(f_cNameProg,0,4)  // Padrão 0
          oRegKey:Close()
    	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
               "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ZONE_ELEVATION" )
          oRegKey:Set(f_cNameProg,0,4)  // Padrão 1
          oRegKey:Close()
    	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
               "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_READ_ZONE_STRINGS_FROM_REGISTRY" )
          oRegKey:Set(f_cNameProg,1,4)  // Padrão 0
          oRegKey:Close()
    	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
               "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BEHAVIORS" )
          oRegKey:Set(f_cNameProg,1,4)
          oRegKey:Close()
    	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
               "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_WEB_CONTROL_VISUALS" )
          oRegKey:Set(f_cNameProg,1,4)
          oRegKey:Close()
    	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
               "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_SHOW_APP_PROTOCOL_WARN_DIALOG" )
          oRegKey:Set(f_cNameProg,1,4) // Padrao 0
          oRegKey:Close()
    	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
               "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_GPU_RENDERING" )
          oRegKey:Set(f_cNameProg,1,4) // Padrao 0
          oRegKey:Close()
    	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
               "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_NINPUT_LEGACYMODE" )
          oRegKey:Set(f_cNameProg,0,4) // Padrao 1
          oRegKey:Close()
    	
       Else
    	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
               "Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" )
          oRegKey:Set(f_cNameProg,f_nVersion_IE,4)
          oRegKey:Close()
    	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
               "SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BEHAVIORS" )
          cRegProgGet := oRegKey:GetBinary(f_cNameProg)
          //? cRegProgGet
          If Empty(cRegProgGet)
            oRegKey:Set(f_cNameProg,1,4)
          EndIf
          oRegKey:Close()
    	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
               "SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_ENABLE_WEB_CONTROL_VISUALS" )
            oRegKey:Set(f_cNameProg,1,4)
          oRegKey:Close()
    	   EndIf
    	RETURN NIL
    

     

    Era isso ai, faltava fazer essa rotina antes

  6.  

    será que é possível deixar esse modulo sem a necessidade de digitação do captcha???

     

    Por quem vai ficar reiniciando o modem, por errar na escolha do captcha?? ninguém, pois os modem geralmente ficam inacessíveis aos usuários

     

    que absurdo é esse novo captcha que fica na baixa dos xml da receita.

     

     

     

    Bem cara, é triste mesmo, aqui no meu estado PB os contadores tem acesso a um sistema do governo do estado para baixar os xml do mês de uma vez só, então essas rotinas ficam somente para os clientes que fazem entrada nas próprias empresas o que diminui o numero de acessos aos recursos e esses recorrentes bloqueios.

    Existe para você diversas opções:

    1º Consulta da SERPRO do governo porém pago https://minhaconta.serpro.gov.br/pfa/#/venda-api?produto=apinfe 
    2º Os contadores solicitarem o certificado sim dos clientes, já que o certificado é mais barato que pagar qualquer programa que disponibilize os XMLs

    3º Ver os serviços do fernando https://www.fsist.com.br/ eu utilizava a dll dele mas ele não deu continuidade para o serviço, ficou somente com o site.

    *Existe outros serviços também citei os que conheço que funcionam. 

  7.  

    Pessoal,

    Agora aparece a captcha novo, mas não sai, fica solicitando, ruas, via, carros, fachada de loja, etc, não sai disso.

    O que será de errado?

     

     

    Esse novo captcha caso você faça muitos testes ele vai bloquear o acesso, eu reinicio o modem para poder renovar meu ip da internet

  8.  

    meu navegador já é a ultima versão do explorer.

    e não aparece o aparece o captcha, só a janela da receita federal, sem essa opção.

     

    Entendi, mas a URL no seu IE não abre ou somente quando chama pelo programa?



    Testa isso aqui:

    - Abra o Internet Explorer

    - Ferramentas

    - Opções de Internet

    - Avançadas

    - Clique em Redefinir

    - Marque a opção "Excluir configurações pessoais"

    - ok

    - Feche o Internet Explorer e abra novamente.

  9.  

    Para o Matheus faria e o kapiaba,

     

    o modulo acima não exibe o captcha e dá erros

     

    Na tela que se abre da receita, não exibe o captcha e uma mensagem de verificando conteúdo de página não sai da tela, travando o programa.

     

    O que fazer para corrigir?

     

     

     

    Qual a versão do IE que você tem na máquina? 

    o teste basico antes de tudo é ver se a URL abre normalemente no seu navegador Internet Explorer da sua máquina, usa a ultima versão 11 ?

    Download 32Bits
    Download 64Bits

    Links para download da microsoft

    PS.: Uso essa rotina nos clientes e ta 100% 

  10. Alterações para nova URL da Sefaz e pedir o captcha novo tambem. 

     

    // --------- Download XML NFe --------- //
    #include "fivewin.ch"
    #include "image.ch"
    #include "directry.ch"
    #include "fileio.ch"
    #include "tip.ch"
    
    #define URL_CONSULTA          "http://www.nfe.fazenda.gov.br/portal/consultaRecaptcha.aspx?tipoConsulta=completa&tipoConteudo=XbSeqxE8pl8="
    #define URL_CONSULTA_COMPLETA "http://www.nfe.fazenda.gov.br/portal/consultaRecaptcha.aspx?tipoConsulta=completa&tipoConteudo=XbSeqxE8pl8="
    
    // ---------------------------------------- //
    // Download XML //
    
    /******************************************************************************/
    procedure DownloadNFe( cChave, cPasta )
       /*
       */
       local oDialog, oIcone, oFonte, hInput := HB_Hash()
       local cCaptcha       := Space( 6 )
       local lSemParametros := Empty( PCount() )
    
       if lSemParametros
          cChave := Space( 44 )
          cPasta := ''
       endif
       
       MsgRun( 'Aguarde! Realizando Download do XML...',, {|| BaixarXML(cChave, cCaptcha, hInput, nil, lSemParametros, cPasta)})
    
       return
    
       /***********************************************************************************/
    static function BaixarXML( cChave, cCaptcha, hInput, oDialog, lSemParametros, cPasta )
       /*
       */
       Local p, oInternet, cParm, cRetorno := '', cHtml := '', c_span := ''
       Local nIni, cPart, cParte, nFim, cFile, nTamTag, nTotPro
    	*
    	Public s_cVersao := "", s_cTpAmb      := "", s_cVerAplic      := "", s_cDhRecbto := "", s_cnProt := "", s_cDigVal := ""
    	Public s_cinfCpl := "", s_cInfAdFisco := "", s_cDiscAdicional := "", s_cxMotivo  := "", s_ccStat := ""
    	Public s_aIde    := {}, s_aEmit       := {}, s_aDest          := {}, s_aDet      := {}, s_aICMS  := {}, s_aIPI    := {}
    	Public s_aTransp := {}, s_aCobr       := {}, s_aMedicamentos  := {}, s_aTotais   := {}, s_aPIS   := {}, s_aCOFINS := {}
    	Public s_cViewState, s_cViewStateGenerator, s_cHiddenToken, s_cEventValidation, s_cStringCookie, s_cHiddenSom
    	*
       // Conteudo elementos da Matriz = {VALOR_TAG,TAG,TAG_PAI,Elemento_Final_TAG_PAI,LABEL_HTML,TAM_LABEL}
       // TAM_LABEL se ZERO pega tudo, se MAIOR que ZERO pega o tamanho no início e se MENOR que ZERO exclui o tamanho no início e pega o restante
    	*
       AADD(s_aIde,{{"","cUF","ide",21,"Chave de Acesso",2},; //1- tratamento especial
        {"","cNF","",0,"Número",0},; //2- tratamento especial
        {"","natOp","",0,"Natureza da Operação",0},; //3-
        {"","indPag","",0,"Forma de Pagamento",1},; //4-
        {"","mod","",0,"Modelo",0},; //5-
        {"","serie","",0,"Série",0},; //6-
        {"","nNF","",0,"Número",0},; //7-
        {"","dhEmi","",0,"Data de Emissão",0},; //8- tratamento especial
        {"","dhSaiEnt","",0,"Entrada",0},; //9- tratamento especial
        {"","tpNF","",0,"Tipo da Operação",1},; //10-
        {"","idDest","",0,"Destino da operação",1},; //11-
        {"","cMunFG","",0,"Município da Ocorrência do Fato Gerador do ICMS",0},; //12-
        {"","tpImp","",0,"Formato de Impressão DANFE",1},; //13- tratamento especial
        {"","tpEmis","",0,"Tipo de Emissão",1},; //14-
        {"","cDV","",0,"Chave de Acesso",0},; //15- tratamento especial
        {"","tpAmb","",0,"Ambiente de autorização:",0},; //16- tratamento especial
        {"","finNFe","",0,"Finalidade",1},; //17-
        {"","indFinal","",0,"Consumidor final",1},; //18-
        {"","indPres","",0,"Presença do Comprador",1},; //19-
        {"","procEmi","",0,"Processo",1},; //20-
        {"","verProc","",0,"Versão do Processo",0}}) //21-
    
       AADD(s_aEmit,{{"","CNPJ","emit",20,"CNPJ",0},; //1- tratamento especial
        {"","CPF","",0,"CPF",0},; //2-
        {"","xNome","",0,"Nome / Razão Social",0},; //3-
        {"","xFant","",0,"Nome Fantasia",0},; //4-
        {"","xLgr","enderEmit",15,"Endereço",0},; //5- tratamento especial
        {"","nro","",0,"Endereço",0},; //6- tratamento especial
        {"","xCpl","",0,"Endereço",0},; //7- tratamento especial
        {"","xBairro","",0,"Bairro / Distrito",0},; //8-
        {"","cMun","",0,"Município",7},; //9-
        {"","xMun","",0,"Município",-10},; //10-
        {"","UF","",0,"UF",0},; //11-
        {"","CEP","",0,"CEP",0},; //12- tratamento especial
        {"","cPais","",0,"País",4},; //13-
        {"","xPais","",0,"País",-7},; //14-
        {"","fone","",0,"Telefone",0},; //15- tratamento especial
        {"","IE","",0,"Inscrição Estadual",0},; //16-
        {"","IEST","",0,"Inscrição Estadual do Substituto Tributário",0},; //17-
        {"","IM","",0,"Inscrição Municipal",0},; //18-
        {"","CNAE","",0,"CNAE Fiscal",0},; //19-
        {"","CRT","",0,"Código de Regime Tributário",1}}) //20-
    
       AADD(s_aDest,{{"","CNPJ","dest",20,"CNPJ",0},; //1-
        {"","CPF","",0,"CPF",0},; //2-
        {"","idEstrangeiro","",0,"",0},; //3-
        {"","xNome","",0,"Nome / Razão Social",0},; //4-
        {"","xLgr","enderDest",15,"Endereço",0},; //5- tratamento especial
        {"","nro","",0,"Endereço",0},; //6- tratamento especial
        {"","xCpl","",0,"Endereço",0},; //7- tratamento especial
        {"","xBairro","",0,"Bairro / Distrito",0},; //8-
        {"","cMun","",0,"Município",7},; //9-
        {"","xMun","",0,"Município",-10},; //10-
        {"","UF","",0,"UF",0},; //11-
        {"","CEP","",0,"CEP",0},; //12- tratamento especial
        {"","cPais","",0,"País",4},; //13-
        {"","xPais","",0,"País",-7},; //14-
        {"","fone","",0,"Telefone",0},; //15- tratamento especial
        {"","indIEDest","",0,"Indicador IE",2},; //16- tratamento especial
        {"","IE","",0,"Inscrição Estadual",0},; //17-
        {"","ISUF","",0,"Inscrição SUFRAMA",0},; //18-
        {"","IM","",0,"IM",0},; //19-
        {"","email","",0,"E-mail",0}}) //20-
    
       //Conteudo elementos da Matriz = {VALOR_TAG,TAG,LABEL_HTML}
    
       AADD(s_aTotais,{{"0.00","vBC","Base de Cálculo ICMS"},; //1-
        {"0.00","vICMS","Valor do ICMS"},; //2-
        {"0.00","vICMSDeson","Valor do ICMS Desonerado"},; //3-
        {"0.00","vFCPUFDest","Valor Total ICMS FCP"},; //4-
        {"0.00","vBCST","Base de Cálculo ICMS ST"},; //5-
        {"0.00","vST","Valor ICMS Substituição"},; //6-
        {"0.00","vProd","Valor Total dos Produtos"},; //7-
        {"0.00","vFrete","Valor do Frete"},; //8-
        {"0.00","vSeg","Valor do Seguro"},; //9-
        {"0.00","vDesc","Valor Total dos Descontos"},; //10-
        {"0.00","vII","Valor Total do II"},; //11-
        {"0.00","vIPI","Valor Total do IPI"},; //12-
        {"0.00","vPIS","Valor do PIS"},; //13-
        {"0.00","vCOFINS","Valor da COFINS"},; //14-
        {"0.00","vOutro","Outras Despesas Acessórias"},; //15-
        {"0.00","vNF","Valor Total da NFe"}}) //16-
    
       //Conteudo elementos da Matriz = {VALOR_TAG,TAG,TAG_PAI,Elemento_Final_TAG_PAI,LABEL_HTML,TAM_LABEL}
    
       AADD(s_aTransp,{{"","modFrete","transp",17,"Modalidade do Frete",1},; //1-
        {"","CNPJ","transporta",8,"CNPJ",0},; //2-
        {"","CPF","",0,"CPF",0},; //3-
        {"","xNome","",0,"Razão Social / Nome",0},; //4-
        {"","IE","",0,"Inscrição Estadual",0},; //5-
        {"","xEnder","",0,"Endereço Completo",0},; //6-
        {"","xMun","",0,"Município",0},; //7-
        {"","UF","",0,"UF",0},; //8-
        {"",'placa','veicTransp',11,'Placa',0},; //9-
        {"","UF","",0,"UF",0},; //10-
        {"","RNTC","",0,"RNTC",0},; //11-
        {"","qVol","vol",17,"Quantidade",0},; //12-
        {"","esp","",0,"Espécie",0},; //13-
        {"","marca","",0,"Marca dos Volumes",0},; //14-
        {"","nVol","",0,"Volume",0},; //15-
        {"","pesoL","",0,"Peso Líquido",0},; //16-
        {"","pesoB","",0,"Peso Bruto",0}}) //17-
    
       //Conteudo elementos da Matriz = {VALOR_TAG,TAG}
    
       AADD(s_aCobr,{{"","nDup"},; //1-
        {"","dVenc"},; //2-
        {"","vDup"},; //3-
        {"","nDup"},; //4-
        {"","dVenc"},; //5-
        {"","vDup"},; //6-
        {"","nDup"},; //7-
        {"","dVenc"},; //8-
        {"","vDup"},; //9-
        {"","nDup"},; //10-
        {"","dVenc"},; //11-
        {"","vDup"},; //12-
        {"","nDup"},; //13-
        {"","dVenc"},; //14-
        {"","vDup"},; //15-
        {"","nDup"},; //16-
        {"","dVenc"},; //17-
        {"","vDup"},; //18-
        {"","nDup"},; //19-
        {"","dVenc"},; //20-
        {"","vDup"},; //21-
        {"","nDup"},; //22-
        {"","dVenc"},; //23-
        {"","vDup"},; //24-
        {"","nDup"},; //25-
        {"","dVenc"},; //26-
        {"","vDup"},; //27-
        {"","nDup"},; //28-
        {"","dVenc"},; //29-
        {"","vDup"}}) //30-
    
       // fazer o acesso
       nTentativas := 0
       REPEAT
       && http://msdn.microsoft.com/en-us/library/aa752084%28v=vs.85%29.aspx
       lErro:=.f.
    	*
    	Try
    		oIE:=TOleAuto():New( "InternetExplorer.Application" )
    	Catch
     		MsgStop("Procure o suporte: não foi possível inicializer InternetExplorer","Problemas no componente")
     		lErro:=.t.
    	End
       *
    	if lErro
          return 
    	endif
    	*
       Try
          oIE:ToolBar   := .T.
          oIE:StatusBar := .T.
          oIE:MenuBar   := .F.
          oIE:Visible   := .T.
          *
          oIE:Navigate2( "https://www.nfe.fazenda.gov.br/portal/consultaRecaptcha.aspx?tipoConsulta=completa&tipoConteudo=XbSeqxE8pl8=" )
          while oIE:Busy
             SysWait()
          end
          *
          oActdo:=oIE:Document()
          oActdo:All:Item("ctl00$ContentPlaceHolder1$txtChaveAcessoCompleta",0):Value:=cChave
          SysWait()
         	*
          GetWndDefault():Minimize()
    	   *
          hWndMain    := WndMain():hWnd
          *
          StopUntil( { || !testarConteudoHTML(oIE) .or. !IsWindow( hWndMain )} )
    		*
    		oIE:Visible   := .F.
          *
          SysWait()
    		while oIE:Busy
             SysWait()
          end
          *
          cHtml:=oIE:Document():All(0):OuterHTML
          while oIE:Busy
             SysWait()
          end
       Catch oErro
    		nTentativas ++
    		if file("c:\desenv.sys")
    			MsgStop(oErro:Description,"Erro")
    		endif	
       end
       
       TRY
          oIE:Quit()
       catch
       end
       Release oIE
       *
       cHtml:=strtran(cHtml,'&')
       cHtml:=strtran(cHtml,'nbsp;')
       *
       nTentativas ++
       UNTIL At('Realizar consulta com captcha sonoro',  cHtml) == 0 .or. nTentativas > 4
       if At('Realizar consulta com captcha sonoro',  cHtml) > 0 .or. nTentativas > 4
          MsgAlert("Atenção tente novamente!","Atenção")
          return .f.
       endif
       *
       
    	If !Empty(cHtml)
          nIni  := At('<html',  cHtml)
          cParte:= SubStr(cHtml, nIni)
          nIni  := At('<div class="divLarguraMaxima" id="ctl00_ContentPlaceHolder1_divBotoesConsulta"',  cParte)
          cParte:= SubStr(cParte, 1, nIni - 1)
          nFim  := At('</form>', cParte)
          cFile := SubStr(cParte, nFim)
          // memowrit('site.txt',cfile)
          
    		nIni   := RAt('fixo-prod-serv-numero',cFile)
          c_span := SubStr(cFile, nIni)
          nIni   := AT('<span>',c_span)+6
          nTamTag:= AT('</span>',c_span)-nIni
    		nTotPro:= 0
    		*
    		nPosicaoAtual:=1
    		while (nPosicaoAtual:=At("fixo-prod-serv-numero",cHTML,nPosicaoAtual)) > 0
      				nTotPro++
      				nPosicaoAtual++
    		end
    		if nTotPro > 0
    			nTotPro:=nTotPro-1
    		endif
    		*
    		//Val(AllTrim(SubStr(c_span,nIni,nTamTag)))
          *
          //Conteudo elementos da Matriz = {VALOR_TAG,TAG,LABEL_HTML,TAM_LABEL}
    		For p := 1 to nTotPro
             AADD(s_aDet,{{"","cProd","Código do Produto",0},; //1-
              {"","cEAN","Código EAN Comercial",0},; //2-
              {"","xProd","fixo-prod-serv-descricao",0},; //3-
              {"","NCM","Código NCM",0},; //4-
              {"","NVE","",0},; //5-
              {"","CEST","Código CEST",0},; //6-
              {"","EXTIPI","Código EX da TIPI",0},; //7-
              {"","CFOP","CFOP",0},; //8-
              {"","uCom","Unidade Comercial",0},; //9-
              {"","qCom","Quantidade Comercial",0},; //10-
              {"","vUnCom","Valor unitário de comercialização",0},; //11-
              {"","vProd","fixo-prod-serv-vb",0},; //12-
              {"","cEANTrib","Código EAN Tributável",0},; //13-
              {"","uTrib","Unidade Tributável",0},; //14-
              {"","qTrib","Quantidade Tributável",0},; //15-
              {"","vUnTrib","Valor unitário de tributação",0},; //16-
              {"","vFrete","Valor Total do Frete",0},; //17-
              {"","vSeg","Valor do Seguro",0},; //18-
              {"","vDesc","Valor do Desconto",0},; //19-
              {"","vOutro","Outras Despesas Acessórias",0},; //20-
              {"","indTot","Indicador de Composição do Valor Total da NF-e",1},; //21-
              {"","nItemPed","Item do pedido de compra",0}}) //22-
    
             AADD(s_aMedicamentos, {{"","Lote",'Nro. do Lote', 0},; //1-
              {"","qLote",'Quantidade de produtos no lote', 0},; //2-
              {"","dFab",'Data de fabricaçã', 0},; //3-
              {"","dVal",'Data de validade', 0},; //4-
              {"","vPMC",'Preço Máximo Consumido', 0},; //5-
              {"","infAdProd",'Descrição', 0}}) //6-
    
             AADD(s_aICMS,{{"","orig","Origem da Mercadoria",1},; //1- ICMS Normal e ST
              {"","CST","Tributação do ICMS",2},; //2-
              {"","CSOSN","Código de Situação da Operação",3},; //3-
              {"","modBC","Modalidade Definição da BC do ICMS",1},; //4-
              {"","pRedBC","Percentual Redução de BC do ICMS",0},; //5-
              {"","vBC","Base de Cálculo",0},; //6-
              {"","pICMS","Alíquota",0},; //7-
              {"","vICMS","Valor",0},; //8-
              {"","vICMSDeson","",0},; //9-
              {"","motDesICMS","",0},; //10-
              {"","modBCST","Modalidade de determinação da BC do ICMS ST",1},; //11-
              {"","pMVAST","Percentual Margem Valor Adicionado do ICMS ST",0},; //12-
              {"","pRedBCST","Percentual da Redução de BC do ICMS ST",0},; //13-
              {"","vBCST","Valor da BC do ICMS ST",0},; //14-
              {"","pICMSST","Alíquota do imposto do ICMS ST",0},; //15-
              {"","vICMSST","Valor do ICMS ST",0},; //16-
              {"","vBCSTRet","Valor da BC do ICMS ST retido",0},; //17-
              {"","vICMSSTRet","Valor do ICMS ST retido",0},; //18-
              {"","vICMSOp","",0},; //19-
              {"","pDif","",0},; //20-
              {"","vICMSDif","",0},; //21-
              {"","pCredSN","Alíquota aplicável de cálculo do crédito",0},; //22-
              {"","vCredICMSSN","Valor crédito do ICMS",0}}) //23-
    
             AADD(s_aIPI,{{"","cEnq","Código de Enquadramento", 3},;
              {"","CST","CST", 2},; //1-
              {"","vBC","Base de Cálculo", 0},; //2-
              {"","pIPI","Alíquota", 0},; //3-
              {"","vIPI","Valor IPI", 0},; //4-
              {"","qBCProd","", 0},; //5-
              {"","vAliqProd","", 0}}) //6-
    
             AADD(s_aPIS,{{"01","CST","CST",2},; //1-
              {"0.00","vBC","Base de Cálculo",0},; //2-
              {"0.00","pPIS","Alíquota",0},; //3-
              {"0.00","vPIS","Valor",0},; //4-
              {"","qBCProd","",0},; //5-
              {"","vAliqProd","",0}}) //6-
    
             AADD(s_aCOFINS,{{"01","CST","CST",2},; //1-
              {"0.00","vBC","Base de Cálculo",0},; //2-vBC
              {"0.00","pCOFINS","Alíquota",0},; //3-
              {"0.00","vCOFINS","Valor",0},; //4-
              {"","qBCProd","",0},; //5-
              {"","vAliqProd","",0}}) //6-
    
          Next
    
          nIni   := At('<div class="GeralXslt"',cFile)
          cParte := SubStr(cFile, nIni)
          nIni   := At('<div class="GeralXslt" id="Emitente"',cParte)
          cParte := SubStr(cParte, 1, nIni - 1) //ide
          //? "ide", !Empty(cParte)
          GeraTag("ide", cParte, cFile, cChave)
    
          nIni   := At('<div class="GeralXslt" id="Emitente"',cFile)
          cParte := SubStr(cFile, nIni)
          nIni   := At('</div>',cParte)
          cParte := SubStr(cParte, 1, nIni - 1) //emit
          //? "emit", !Empty(cParte)
          GeraTag("emit", cParte, cFile, cChave)
    
          *nIni   := At('<div id="DestRem"',cFile)
          nIni   := At('<div class="GeralXslt" id="DestRem"',cFile)
          cParte := SubStr(cFile, nIni)
          nIni   := At('</div>',cParte)
          cParte := SubStr(cParte, 1, nIni - 1) //dest
          *? "dest", !Empty(cParte)
          GeraTag("dest",cParte, cFile, cChave)
    
          *nIni   := At('<td class="fixo-prod-serv-numero"><span>', cFile)
          nIni   := At('<tr><td class="fixo-prod-serv-numero"><span>', cFile)
          cParte := SubStr(cFile, nIni)
          *nIni   := At('</body></html>', cParte)
          nIni   := At('<div class="nft" id="aba_nft_10">', cParte)
          if nIni == 0
          	nIni   := At('<div id="aba_nft_10" class="nft">', cParte)
    		endif
    		if nIni == 0
    			nIni   := At('<a id="ctl00_ContentPlaceHolder1_hplExibirAutorizacao" class="botao">', cParte)
    		endif
          cParte := SubStr(cParte, 1, nIni - 1) //det
          //? "det", !Empty(cParte)
          GeraTag("det", cParte, cFile, cChave)
    		
          nIni   := At('<legend class="titulo-aba">Totais</legend>',cFile)
          cParte := SubStr(cFile, nIni+42)
          *nIni   := At('<div id="aba_nft_5"',cParte)
          nIni   := At('<div class="nft" id="aba_nft_5"',cParte)
          cParte := SubStr(cParte, 1, nIni - 1) //totais
          //? "totais", !Empty(cParte)
          GeraTag("totais", cParte, cFile, cChave)
    
          nIni   := At('Dados do Transporte</legend>',cFile)
          cParte := SubStr(cFile, nIni+29)
          nIni   := At('<div class="GeralXslt" id="Cobranca"',cParte)
          cParte := SubStr(cParte, 1, nIni - 1) //transp
          //? "transp", !Empty(cParte)
          GeraTag("transp", cParte, cFile, cChave)
    
          nIni   := At('<legend>Duplicatas</legend><table',cFile)
    
          if nIni > 0
             cParte := SubStr(cFile, nIni)
             nIni   := At('</table>',cParte)
             cParte := SubStr(cParte, 1, nIni - 1) //cobr
             *? "cobr",  !Empty(cParte)
             GeraTag("cobr", cParte, cFile, cChave)
          endif
    
          GravaXML(cChave, hInput, oDialog, lSemParametros, cPasta)
    
       Else
          MsgInfo('Erro ao ler retorno da Consulta!', 'Atenção!')
          Return .f.
       EndIf
    
       Return .t.
    
       /********************************************************************/
    static function testarConteudoHTML(oIE)
       Local retorno:=.T.
       MsgWait("Verificando conteúdo da página")
       Try
          cHtml:=oIE:Document():All(0):OuterHTML
          retorno:=at('Realizar consulta com captcha sonoro',cHtml)>0
       catch
       end
       return retorno
    static Function Troca_Acento( cTexto )
       /*
       */
    
       cTexto := StrTran( cTexto, "&#243;", "ó" )
       cTexto := StrTran( cTexto, "&#225;", "á" )
       cTexto := StrTran( cTexto, "&#233;", "é" )
    
       Return cTexto
    
       /*******************************************************************/
    static Function GeraTag( _tag, cParte, cFile, cChave )
       /*
       */
       Local i, cPar_, c_Tag, nTamTag, nIni, c_span, cPar1_, nFim
    
       if _tag=="ide"
          cPar_:= StrTran(cFile,Chr(13)+Chr(10),"")
          cPar_:= StrTran(cPar_,Chr(160),"")
          nIni := At('<legend>Informações Complementares de Interesse do Contribuinte</legend>', cPar_)
    		
          if nIni>0
             c_span    := SubStr(cPar_, nIni+70)
             nIni      := AT('<div style="word-wrap: break-word">',c_span)
             c_span    := SubStr(c_span, nIni+35)
             nIni      := AT('</div></span>',c_span)
             s_cinfCpl := alltrim(SubStr(c_span,1,nIni-1))
          endif
    
          cPar_      := StrTran(cParte,Chr(13)+Chr(10),"")
          cPar_      := StrTran(cPar_,Chr(160),"")
    
          nIni       := AT('Situação Atual:',cPar_)
          c_span     := SubStr(cPar_, nIni+15)
          nIni       := AT('(Ambiente de autorização:',c_span)
          s_cxMotivo := Alltrim(SubStr(c_span,1,nIni-1))
    
          if "AUTORIZADA" $ s_cxMotivo
             s_ccStat   := "100"
             s_cxMotivo := "Autorizado o uso da NF-e"
          endif
    
          if "CANCELADA" $ s_cxMotivo
             s_ccStat   := "101"
             s_cxMotivo := "Cancelamento de NF-e homologado"
          endif
    
          nIni        := AT('Data Inclusão AN</label></td></tr><tr><td><span>',cPar_)
          c_span      := SubStr(cPar_, nIni+50)
          nIni        := AT('<span>',c_span)+6
          nTamTag     := AT('<input',c_span)-nIni
          s_cnProt    := alltrim(SubStr(c_span,nIni,nTamTag))
          c_span      := SubStr(c_span, nIni+nTamTag)
          nIni        := AT('<span>',c_span)+6
          c_span      := SubStr(c_span,nIni)
          nTamTag     := AT('</span>',c_span)-1 //nIni
          s_cDhRecbto := alltrim(SubStr(c_span,1,nTamTag))
          s_cDhRecbto := SubStr(s_cDhRecbto,7,4)+"-"+SubStr(s_cDhRecbto,4,2)+"-"+left(s_cDhRecbto,2)+"T"+Right(s_cDhRecbto,14)
          nIni        := AT('<i>Digest</i> Value da NF-e',cPar_)
          c_span      := SubStr(cPar_, nIni+20)
          nIni        := AT('<span>',c_span)+6
          nTamTag     := AT('</span>',c_span)-nIni
          s_cDigVal   := alltrim(SubStr(c_span,nIni,nTamTag))
    
          nIni        := AT('Versão XML',cParte)
          c_span      := SubStr(cParte, nIni)
          nIni        := AT('<span>',c_span)+6
          nTamTag     := AT('</span>',c_span)-nIni
          s_cVersao   := alltrim(SubStr(c_span,nIni,nTamTag))
    
          For i := 1 to Len(s_aIde[1])
    
             cPar_:= cParte
    
             if i == 12
                cPar_:= cFile
             endif
    
             if i == 13
                cPar_:= cFile
             endif
    
             nIni   := AT(s_aIde[1,i,5],cPar_)
             c_span := SubStr(cPar_, nIni)
    
             if i != 16
                nIni     := AT('<span>', c_span) + 6
                nTamTag  := AT('</span>', c_span) - nIni
                c_tag    := alltrim(SubStr(c_span, nIni, nTamTag))
             else
                nIni     := AT('</legend>', c_span)
                c_tag    := alltrim(SubStr(c_span, 1, nIni - 1))
                if AT('produção', c_tag) > 0
                   c_tag := "1"
                else
                   c_tag := "2"
                endif
                s_cTpAmb := c_tag
             endif
    
             if i == 2
                c_tag := SubStr(cChave, 36, 8)
                //c_tag:= StrZero(Val(c_tag), 9)
             endif
    
             if i == 8 .or. i == 9
                if !Empt(c_tag)
                   c_tag := SubStr(c_tag,7,4)+"-"+SubStr(c_tag,4,2)+"-"+left(c_tag,2)+"T"+SubStr(c_tag,12)
                endif
             endif
    
             if i == 15
                c_tag := right(c_tag,1)
             endif
    
             if s_aIde[1,i,6]!=0
                if s_aIde[1,i,6]>0
                   c_tag := left(c_tag,s_aIde[1,i,6])
                else
                   c_tag := SubStr(c_tag,Abs(s_aIde[1,i,6])+1)
                endif
             endif
    
             s_aIde[1,i,1] := c_tag
    
          Next
       endif
    
       if _tag == "emit"
    
          For i := 1 to Len(s_aEmit[1])
    
             cPar_ := StrTran(cParte,Chr(13)+Chr(10),"")
             cPar_ := StrTran(cPar_,Chr(160),"")
             nIni  := AT(s_aEmit[1,i,5],cPar_)
    
             if nIni > 0
                c_span  := SubStr(cPar_, nIni)
                nIni    := AT('<span>',c_span)+6
                nTamTag := AT('</span>',c_span)-nIni
                c_tag   := Alltrim(SubStr(c_span,nIni,nTamTag))
    
                if i >= 1 .and. i <= 2
                   c_tag := StrTran(c_tag,".","")
                   c_tag := StrTran(c_tag,"/","")
                   c_tag := StrTran(c_tag,"-","")
                endif
    
                if i >= 5 .and. i <= 7
    
                   nIni := AT(",",c_tag)
    
                   if i == 5
                      c_tag := Left(c_tag,nIni-1)
                   elseif i == 6
                      c_tag := AllTrim(SubStr(c_tag, nIni + 1))
                      nIni  := AT(" ", c_tag)
                      if nIni > 0
                         c_tag := Left(c_tag, nIni - 1)
                      endif
                   else
                      c_tag := AllTrim(SubStr(c_tag, nIni + 1))
                      nIni  := AT(" ", c_tag)
                      if nIni > 0
                         c_tag := alltrim(SubStr(c_tag, nIni + 1))
                      else
                         c_tag := ""
                      endif
                   endif
                endif
    
                if i == 12
                   c_tag := StrTran(c_tag,"-","")
                endif
    
                if i==15
                   c_tag := StrTran(c_tag,"(","")
                   c_tag := StrTran(c_tag,")","")
                   c_tag := StrTran(c_tag,"-","")
                endif
    
                if s_aEmit[1, i, 6] != 0
                   if s_aEmit[1, i, 6] > 0
                      c_tag := left(c_tag,s_aEmit[1, i, 6])
                   else
                      c_tag := alltrim(SubStr(c_tag, Abs(s_aEmit[1, i, 6]) + 1))
                      c_tag := alltrim(StrTran(c_tag, "-", ""))
                   endif
                endif
                s_aEmit[1, i, 1] := c_tag
             endif
          Next
    
       endif
    
       if _tag == "dest"
          For i := 1 to Len(s_aDest[1])
             cPar_ := StrTran(cParte, Chr(13) + Chr(10), "")
             cPar_ := StrTran(cPar_, Chr(160), "")
             nIni  := AT(s_aDest[1, i, 5], cPar_)
    			if nIni > 0
                c_span  := SubStr(cPar_, nIni)
                nIni    := AT('<span>',c_span)+6
                nTamTag := AT('</span>',c_span)-nIni
                c_tag   := AllTrim(SubStr(c_span, nIni, nTamTag))
                if i >= 1 .and. i <= 2
                   c_tag := StrTran(c_tag, ".", "")
                   c_tag := StrTran(c_tag, "/", "")
                   c_tag := StrTran(c_tag, "-", "")
                endif
                If i >= 5 .and. i <= 7
                   nIni := AT(",", c_tag)
                   if i == 5
                      c_tag := Left(c_tag,nIni-1)
                   elseif i == 6
                      c_tag := AllTrim(SubStr(c_tag, nIni + 1))
                      nIni  := AT(" ", c_tag)
                      if nIni > 0
                         c_tag := Left(c_tag, nIni - 1)
                      endif
                   else
                      c_tag := AllTrim(SubStr(c_tag, nIni + 1))
                      nIni  := AT(" ", c_tag)
                      if nIni > 0
                         c_tag := alltrim(SubStr(c_tag, nIni + 1))
                      else
                         c_tag := ""
                      endif
                   endif
                EndIf
                if i == 12
                   c_tag := StrTran(c_tag, "-", "")
                endif
                if i == 15
                   c_tag := StrTran(c_tag, "(", "")
                   c_tag := StrTran(c_tag, ")", "")
                   c_tag := StrTran(c_tag, "-", "")
                endif
                if i==16
                   c_tag := alltrim(Str(Val(c_tag)))
                endif
                if s_aDest[1, i, 6] != 0
                   if s_aDest[1, i, 6] > 0
                      c_tag := left(c_tag, s_aDest[1, i, 6])
                   else
                      c_tag := alltrim(SubStr(c_tag, Abs(s_aDest[1,i,6]) + 1))
                      c_tag := alltrim(StrTran(c_tag, "-", ""))
                   endif
                endif
                s_aDest[1, i, 1] := c_tag
             endif
          Next
    
       endif
    	
       if _tag == "det"
          cPar_ := StrTran(cParte, Chr(13) + Chr(10), "")
          cPar_ := StrTran(cPar_, Chr(160), "")
    		*
    		tPar_ := HB_ATokens(cPar_,'"fixo-prod-serv-numero"><span>')
    		*
    		For p := 1 to Len(s_aDet) // PASSA NOS PRODUTOS*
    			
    			cPar_:=tPar_[p+1]
    			
    			For i := 1 to Len(s_aDet[p])
    		      nIni := At(s_aDet[p, i, 3], cPar_)
    		      if nIni > 0
    		         c_span  := SubStr(cPar_, nIni)
    		         nIni    := At('<span>',c_span)+6
    		         nTamTag := At('</span>',c_span)-nIni
    		         c_tag   := AllTrim(SubStr(c_span,nIni,nTamTag))
    		         if s_aDet[p, i, 4] != 0
    		            if s_aDet[p, i, 4] > 0
    		               c_tag := left(c_tag, s_aDet[p, i, 4])
    		            else
    		               c_tag := alltrim(SubStr(c_tag, Abs(s_aDet[p, i, 4]) + 1))
    		               c_tag := alltrim(StrTran(c_tag, "-", ""))
    		            endif
    		         endif
    		         If i != 3
    		            c_tag := StrTran(c_tag, ".", "")
    		            c_tag := StrTran(c_tag, ",", ".")
    		         endIf
    		         s_aDet[p, i, 1] := c_tag
    		      endif
    		   Next
    					 
    		   For i := 1 To Len(s_aICMS[p])
    		      nIni := At(s_aICMS[p, i, 3], cPar_)
    		      if nIni > 0
    		         c_span  := SubStr(cPar_, nIni)
    		         nIni    := At('<span>', c_span) + 6
    		         nTamTag := At('</span>', c_span) - nIni
    		         c_tag   := AllTrim(SubStr(c_span, nIni, nTamTag))
    		         If s_aICMS[p, i, 4] != 0
    		            if s_aICMS[p, i, 4] > 0
    		               c_tag := Left(c_tag, s_aICMS[p, i, 4])
    		            else
    		               c_tag := AllTrim(SubStr(c_tag, Abs(s_aICMS[p, i, 4]) + 1))
    		               c_tag := AllTrim(StrTran(c_tag, "-", ""))
    		            endif
    		         endif
    		         c_tag            := StrTran(c_tag, ".", "")
    		         c_tag            := StrTran(c_tag, ",", ".")
    		         s_aICMS[p, i, 1] := c_tag
    		      endif
    		   Next
    		
    		   nIni := AT('<legend>Imposto Sobre Produtos Industrializados</legend>', cPar_)
    		
    		   if nIni > 0
    		      cPar_ := SubStr(cPar_, nIni)
    		      For i := 1 To Len(s_aIPI[p])
    		         nIni := AT(s_aIPI[p, i, 3], cPar_)
    		         if nIni > 0
    		            c_span  := SubStr(cPar_, nIni)
    		            nIni    := AT('<span>', c_span) + 6
    		            nTamTag := AT('</span>', c_span) - nIni
    		            c_tag   := AllTrim(SubStr(c_span, nIni, nTamTag))
    		            if s_aIPI[p, i, 4] != 0
    		               if s_aIPI[p, i, 4] > 0
    		                  c_tag := Left(c_tag, s_aIPI[p, i, 4])
    		               else
    		                  c_tag := Alltrim(SubStr(c_tag, Abs(s_aIPI[p, i, 4]) + 1))
    		                  c_tag := Alltrim(StrTran(c_tag, "-", ""))
    		               endif
    		            endif
    		            c_tag           := StrTran(c_tag, ".", "")
    		            c_tag           := StrTran(c_tag, ",", ".")
    		            s_aIPI[p, i, 1] := c_tag
    		         endif
    		      Next
    		   endif
    
    		   nIni := At('<legend class="toggle">PIS</legend>', cPar_)
    		
    		   if nIni > 0
    		      cPar_ := SubStr(cPar_, nIni)
    		      For i := 1 to Len(s_aPIS[p])
    		         IF P == Len(s_aPIS)
    		            nFim  := LEN(cPar_)
    		         ELSE
    		            nFim  := At('<td class="fixo-prod-serv-numero"><span>', cPar_)
    		         ENDIF
    		         cPar1_:= SubStr(cPar_, 1, nFim)
    		         nIni  := AT(s_aPIS[p, i, 3], cPar1_)
    		         if nIni > 0
    		            c_span  := SubStr(cPar1_, nIni)
    		            nIni    := At('<span>', c_span) + 6
    		            nTamTag := At('</span>', c_span) - nIni
    		            c_tag   := AllTrim(SubStr(c_span, nIni, nTamTag))
    		            if s_aPIS[p,i,4] != 0
    		               if s_aPIS[p,i,4] > 0
    		                  c_tag := Left(c_tag,s_aPIS[p,i,4])
    		               else
    		                  c_tag := AllTrim(SubStr(c_tag, Abs(s_aPIS[p, i, 4]) + 1))
    		                  c_tag := AllTrim(StrTran(c_tag, "-", ""))
    		               endif
    		            endif
    		            c_tag           := StrTran(c_tag, ".", "")
    		            c_tag           := StrTran(c_tag, ",", ".")
    		            s_aPIS[p, i, 1] := c_tag
    		         endif
    		      Next
    		   endif
    		   *
    
    			nIni := AT('<legend class="toggle">COFINS</legend>', cPar_)
    					 
    		   if nIni > 0
    		      cPar_ := SubStr(cPar_, nIni)
    		      For i := 1 to Len(s_aCOFINS[p])
    		         IF P == Len(s_aCOFINS)
    		            nFim  := LEN(cPar_)
    		         ELSE
    		            nFim  := At('<td class="fixo-prod-serv-numero"><span>', cPar_)
    		         ENDIF
    		         cPar1_:= SubStr(cPar_, 1, nFim)
    		         nIni  := AT(s_aCOFINS[p, i, 3], cPar1_)
    		         if nIni > 0
    		            c_span  := SubStr(cPar1_, nIni)
    		            nIni    := AT('<span>', c_span) + 6
    		            nTamTag := AT('</span>', c_span) - nIni
    		            c_tag   := alltrim(SubStr(c_span, nIni, nTamTag))
    		            if s_aCOFINS[p, i, 4] != 0
    		               if s_aCOFINS[p, i, 4] > 0
    		                  c_tag := left(c_tag, s_aCOFINS[p, i, 4])
    		               else
    		                  c_tag := alltrim(SubStr(c_tag, Abs(s_aCOFINS[p, i, 4]) + 1))
    		                  c_tag := alltrim(StrTran(c_tag, "-", ""))
    		               endif
    		            endif
    		            c_tag              := StrTran(c_tag, ".", "")
    		            c_tag              := StrTran(c_tag, ",", ".")
    		            s_aCOFINS[p, i, 1] := c_tag
    		         endif
    		      Next
    		   endif
    			nIni := At('<legend>Detalhamento específico dos medicamentos</legend>', cPar_)
    		
    		   if nIni > 0
    		      cPar_ := SubStr(cPar_, nIni)
    		      For i := 1 to Len(s_aMedicamentos[p])
    		         nIni := AT(s_aMedicamentos[p, i, 3], cPar_)
    		         if nIni > 0
    		            c_span  := SubStr(cPar_, nIni)
    		            nIni    := At('<span>', c_span) + 6
    		            nTamTag := At('</span>', c_span) - nIni
    		            c_tag   := AllTrim(SubStr(c_span, nIni, nTamTag))
    		            if s_aMedicamentos[p,i,4] != 0
    		               if s_aMedicamentos[p,i,4] > 0
    		                  c_tag := Left(c_tag,s_aMedicamentos[p,i,4])
    		               else
    		                  c_tag := AllTrim(SubStr(c_tag, Abs(s_aMedicamentos[p, i, 4]) + 1))
    		                  c_tag := AllTrim(StrTran(c_tag, "-", ""))
    		               endif
    		            endif
    		            If i != 6
    		               c_tag := StrTran(c_tag, ".", "")
    		               c_tag := StrTran(c_tag, ",", ".")
    		            endif
    		            if StrZero(i, 2) $ "-03-04"
    		               c_tag:=SubStr(c_tag,7,4)+"-"+SubStr(c_tag,4,2)+"-"+left(c_tag,2)
    		            endif
    		            s_aMedicamentos[p, i, 1] := c_tag
    		         endif
    		      Next
    		   endif
    
    			nIni  := At('<td class="fixo-prod-serv-numero"><span>', cPar_)
    		   cPar_ := SubStr(cPar_, nIni)
    		
    		Next
       endif
    
       if _tag=="totais"
          For i := 1 to Len(s_aTotais[1])
             cPar_ := StrTran(cParte,Chr(13)+Chr(10),"")
             cPar_ := StrTran(cPar_,Chr(160),"")
             nIni  := AT(s_aTotais[1,i,3],cPar_)
             if nIni > 0
                c_span           := SubStr(cPar_, nIni)
                nIni             := AT('<span>',c_span)+6
                nTamTag          := AT('</span>',c_span)-nIni
                c_tag            := alltrim(SubStr(c_span,nIni,nTamTag))
                c_tag            := StrTran(c_tag,".","")
                c_tag            := StrTran(c_tag,",",".")
                s_aTotais[1,i,1] := c_tag
             endif
          Next
       endif
    
       if _tag=="transp"
          For i := 1 to Len(s_aTransp[1])
             cPar_ := StrTran(cParte,Chr(13)+Chr(10),"")
             cPar_ := StrTran(cPar_,Chr(160),"")
             nIni  := AT(s_aTransp[1,i,5],cPar_)
             if nIni > 0
                c_span  := SubStr(cPar_, nIni)
                nIni    := AT('<span>',c_span)+6
                nTamTag := AT('</span>',c_span)-nIni
                c_tag   := alltrim(SubStr(c_span,nIni,nTamTag))
                if i >= 2 .and. i <= 3
                   c_tag := StrTran(c_tag,".","")
                   c_tag := StrTran(c_tag,"/","")
                   c_tag := StrTran(c_tag,"-","")
                endif
                if s_aTransp[1,i,6] != 0
                   if s_aTransp[1,i,6]>0
                      c_tag := left(c_tag,s_aTransp[1,i,6])
                   else
                      c_tag := alltrim(SubStr(c_tag,Abs(s_aTransp[1,i,6])+1))
                      c_tag := alltrim(StrTran(c_tag,"-",""))
                   endif
                endif
                s_aTransp[1,i,1] := c_tag
             endif
          Next
       endif
    
       if _tag == "cobr"
          cPar_ := StrTran(cParte,Chr(13)+Chr(10),"")
          cPar_ := StrTran(cPar_,Chr(160),"")
          For i := 1 to Len(s_aCobr[1])
             nIni := AT('<span>',cPar_)
             if nIni > 0
                cPar_   := SubStr(cPar_, nIni+6)
                nTamTag := AT('</span>',cPar_)-1
                c_tag   := alltrim(SubStr(cPar_,1,nTamTag))
                c_tag   := StrTran(c_tag,".","")
                c_tag   := StrTran(c_tag,",",".")
                if StrZero(i,2) $ "-02-05-08-11-14-17-20-23-26-29"
                   c_tag := SubStr(c_tag,7,4)+"-"+SubStr(c_tag,4,2)+"-"+left(c_tag,2)
                endif
                s_aCobr[1,i,1] := c_tag
             else
                Exit
             endif
          Next
       endif
    
       return Nil
    
       /**************************************************************************************************/
    static function GravaXML(cChave, hInput, oDialog, lSemParametros, cPasta)
       /*
       */
       Local i, p, lTemTag, cTagPai, nFimTagPai, nIni, cTag, nArqHandle, cArqXml, cTag_
       Local cXML :='<?xml version="1.0" encoding="UTF-8"?><nfeProc versao="'+s_cVersao+'" xmlns="http://www.portalfiscal.inf.br/nfe"><NFe xmlns="http://www.portalfiscal.inf.br/nfe"><infNFe versao="'+s_cVersao+'" Id="NFe'+cChave+'">'
    
       cTagPai    := ""
       nFimTagPai := 0
    
       For i := 1 to Len(s_aIde[1])
          if !Empt(s_aIde[1,i,3])
             nFimTagPai := s_aIde[1,i,4]
             cTagPai    += "|"+StrZero(nFimTagPai,2)+s_aIde[1,i,3]
             cXML       += '<'+s_aIde[1,i,3]+'>'
          endif
          if !Empty(s_aIde[1,i,1])
             cXML += '<'+s_aIde[1,i,2]+'>'+s_aIde[1,i,1]+'</'+s_aIde[1,i,2]+'>'
          endif
          if i == nFimTagPai
             nIni    := RAT("|",cTagPai)
             cTag    := Substr(cTagPai,nIni+1)
             cXML    += '</'+SubStr(cTag,3)+'>'
             cTagPai := SubStr(cTagPai,1,nIni-1)
             if nIni > 1
                nIni       := RAT("|",cTagPai)
                nFimTagPai := Val(Substr(cTagPai,nIni+1,2))
             else
                nFimTagPai := 0
             endif
          endif
       Next
    
       For i := 1 to Len(s_aEmit[1])
          if !Empty(s_aEmit[1,i,3])
             nFimTagPai := s_aEmit[1,i,4]
             cTagPai    += "|"+StrZero(nFimTagPai,2)+s_aEmit[1,i,3]
             cXML       += '<'+s_aEmit[1,i,3]+'>'
          endif
          if !Empty(s_aEmit[1,i,1])
             cXML += '<'+s_aEmit[1,i,2]+'>'+s_aEmit[1,i,1]+'</'+s_aEmit[1,i,2]+'>'
          endif
          if i == nFimTagPai
             nIni    := RAT("|",cTagPai)
             cTag    := Substr(cTagPai,nIni+1)
             cXML    += '</'+SubStr(cTag,3)+'>'
             cTagPai := SubStr(cTagPai,1,nIni-1)
             if nIni > 1
                nIni       := RAT("|",cTagPai)
                nFimTagPai := Val(Substr(cTagPai,nIni+1,2))
             else
                nFimTagPai := 0
             endif
          endif
       Next
    
       For i := 1 to Len(s_aDest[1])
          if !Empt(s_aDest[1,i,3])
             nFimTagPai := s_aDest[1,i,4]
             cTagPai    += "|"+StrZero(nFimTagPai,2)+s_aDest[1,i,3]
             cXML       += '<'+s_aDest[1,i,3]+'>'
          endif
          if !Empt(s_aDest[1,i,1])
             cXML += '<'+s_aDest[1,i,2]+'>'+s_aDest[1,i,1]+'</'+s_aDest[1,i,2]+'>'
          endif
          if i == nFimTagPai
             nIni    := RAT("|",cTagPai)
             cTag    := Substr(cTagPai,nIni+1)
             cXML    += '</'+SubStr(cTag,3)+'>'
             cTagPai := SubStr(cTagPai,1,nIni-1)
             if nIni > 1
                nIni       := RAT("|",cTagPai)
                nFimTagPai := Val(Substr(cTagPai,nIni+1,2))
             else
                nFimTagPai := 0
             endif
          endif
       Next
    	
       For p := 1 to Len(s_aDet)
          cXML += '<det nItem="'+alltrim(Str(p))+'"><prod>'
          For i := 1 to Len(s_aDet[p])
             if !Empt(s_aDet[p,i,1])
                cXML += '<'+s_aDet[p,i,2]+'>'+s_aDet[p,i,1]+'</'+s_aDet[p,i,2]+'>'
             endif
          Next
    
          lTemTag := .F.
          For i := 1 to Len(s_aMedicamentos[p])
             if i == 1
                if !Empty(s_aMedicamentos[p,i,1])
                   cXML    += '<med><nLote>' + s_aMedicamentos[p,i,1] + '</nLote>'
                   lTemTag := .t.
                endif
             Else
                if !Empty(s_aMedicamentos[p,i,1])
                   If i == 6
                      s_cDiscAdicional := '<'+s_aMedicamentos[p,i,2]+'>'+ s_aMedicamentos[p,i,1] + '</'+s_aMedicamentos[p,i,2]+'>'
                   Else
                      cXML             += '<'+s_aMedicamentos[p,i,2]+'>'+ s_aMedicamentos[p,i,1] + '</'+s_aMedicamentos[p,i,2]+'>'
                   Endif
                endif
             EndIf
          Next
    
          if lTemTag
             cXML += '</med>'
          endif
    
          cXML  += '</prod><imposto><ICMS>'
          cTag_ := 'ICMS'
    
          For i := 1 to Len(s_aICMS[p])
             if i == 1
                if !Empty(s_aICMS[p, 2, 1])
                   cTag_ += s_aICMS[p, 2, 1]
                else
                   cTag_ += 'SN' + s_aICMS[p, 3, 1]
                endif
                cXML += '<' + cTag_ + '>'
             endif
             if !Empty(s_aICMS[p, i, 1])
                If s_aICMS[p, 2, 1] == '00'
                   If StrZero(i, 2) $ "-01-02-04-06-07-08"
                      cXML += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                   EndIf
                ElseIf s_aICMS[p, 2, 1] == '10'
                   If StrZero(i, 2) $ "-01-02-04-06-07-08-11-12-13-14-15-16"
                      cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                   EndIf
                ElseIf s_aICMS[p, 2, 1] == '20'
                   If StrZero(i, 2) $ "-01-02-04-05-06-07-08-09-10"
                      cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                   EndIf
                ElseIf s_aICMS[p, 2, 1] == '30'
                   If StrZero(i, 2) $ "-01-02-11-12-13-14-15-16-09-10"
                      cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                   EndIf
                ElseIf s_aICMS[p, 2, 1] == '40' .or. s_aICMS[p, 2, 1] == '41' .Or. s_aICMS[p, 2, 1] == '50'
                   If StrZero(i, 2) $ "-01-02-09-10"
                      cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                   EndIf
                ElseIf s_aICMS[p, 2, 1] == '51'
                   If StrZero(i, 2) $ "-01-02-04-05-06-07-08-19-20-21"
                      cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                   EndIf
                ElseIf s_aICMS[p, 2, 1] == '60'
                   If StrZero(i, 2) $ "-01-02-17-18"
                      cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                   EndIf
                ElseIf s_aICMS[p, 2, 1] == '70'
                   If StrZero(i, 2) $ "-01-02-04-05-06-07-08-09-10-11-12-13-14-15-16"
                      cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                   EndIf
                ElseIf s_aICMS[p, 2, 1] == '90'
                   If StrZero(i, 2) $ "-01-02-04-05-06-07-08-11-12-13-14-15-16"
                      cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                   EndIf
                Else
                   cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                EndIf
             endif
          Next
    
          cXML    += '</'+cTag_+'></ICMS>'
          lTemTag := .F.
    
          For i := 1 to Len(s_aIPI[p])
             if i == 1
                if !Empty(s_aIPI[p,i,1])
                   cXML    += '<IPI><cEnq>' + s_aIPI[p,i,1] + '</cEnq><IPITrib>'
                   lTemTag := .T.
                endif
             Else
                if !Empty(s_aIPI[p,i,1])
                   cXML += '<'+s_aIPI[p,i,2]+'>'+ s_aIPI[p,i,1] + '</'+s_aIPI[p,i,2]+'>'
                endif
             EndIf
          Next
    
          if lTemTag
             cXML += '</IPITrib></IPI>'
          endif
    
          lTemTag := .F.
    
          For i:= 1 to Len(s_aPIS[p])
             if i == 1
                if !Empty(s_aPIS[p, i, 1])
                   If Val(s_aPIS[p, 1, 1]) >= 1 .And. Val(s_aPIS[p, 1, 1]) <= 2
                      cXML += '<PIS><PISAliq>'
                   ElseIf Val(s_aPIS[p, 1, 1]) == 3
                      cXML += '<PIS><PISQte>'
                   ElseIf Val(s_aPIS[p, 1, 1]) >= 4 .And. Val(s_aPIS[p, 1, 1]) <= 9
                      cXML += '<PIS><PISNT>'
                   ElseIf Val(s_aPIS[p, 1, 1]) >= 49 .And. Val(s_aPIS[p, 1, 1]) <= 99
                      cXML += '<PIS><PISOutr>'
                   EndIf
                   lTemTag := .T.
                endif
             endif
             if !Empty(s_aPIS[p, i, 1])
                cXML += '<' + s_aPIS[p,i,2] + '>' + s_aPIS[p,i,1] + '</' + s_aPIS[p,i,2] + '>'
             endif
          Next
    
          if lTemTag
             If Val(s_aPIS[p, 1, 1]) >= 1 .And. Val(s_aPIS[p, 1, 1]) <= 2
                cXML += '</PISAliq></PIS>'
             ElseIf Val(s_aPIS[p, 1, 1]) == 3
                cXML += '</PISQte></PIS>'
             ElseIf Val(s_aPIS[p, 1, 1]) >= 4 .And. Val(s_aPIS[p, 1, 1]) <= 9
                cXML += '</PISNT></PIS>'
             ElseIf Val(s_aPIS[p, 1, 1]) >= 49 .And. Val(s_aPIS[p, 1, 1]) <= 99
                cXML+= '</PISOutr></PIS>'
             EndIf
          endif
    
          lTemTag := .F.
    
          For i := 1 to Len(s_aCOFINS[p])
             if i == 1
                if !Empty(s_aCOFINS[p,i,1])
                   If Val(s_aPIS[p, 1, 1]) >= 1 .And. Val(s_aPIS[p, 1, 1]) <= 2
                      cXML += '<COFINS><COFINSAliq>'
                   ElseIf Val(s_aPIS[p, 1, 1]) == 3
                      cXML += '<COFINS><COFINSQte>'
                   ElseIf Val(s_aPIS[p, 1, 1]) >= 4 .And. Val(s_aPIS[p, 1, 1]) <= 9
                      cXML += '<COFINS><COFINSNT>'
                   ElseIf Val(s_aPIS[p, 1, 1]) >= 49 .And. Val(s_aPIS[p, 1, 1]) <= 99
                      cXML += '<COFINS><COFINSOutr>'
                   EndIf
                   lTemTag := .T.
                endif
             endif
             if !Empty(s_aCOFINS[p,i,1])
                cXML += '<' + s_aCOFINS[p, i, 2] + '>' + s_aCOFINS[p, i, 1] + '</' + s_aCOFINS[p, i, 2] + '>'
             endif
          Next
    
          if lTemTag
             If Val(s_aPIS[p, 1, 1]) >= 1 .And. Val(s_aPIS[p, 1, 1]) <= 2
                cXML += '</COFINSAliq></COFINS>'
             ElseIf Val(s_aPIS[p, 1, 1]) == 3
                cXML += '</COFINSQte></COFINS>'
             ElseIf Val(s_aPIS[p, 1, 1]) >= 4 .And. Val(s_aPIS[p, 1, 1]) <= 9
                cXML += '</COFINSNT></COFINS>'
             ElseIf Val(s_aPIS[p, 1, 1]) >= 49 .And. Val(s_aPIS[p, 1, 1]) <= 99
                cXML+= '</COFINSOutr></COFINS>'
             EndIf
          endif
          cXML += '</imposto>'
          If !Empty(s_cDiscAdicional)
             cXml += s_cDiscAdicional
          EndIf
          cXML += '</det>'
       Next
    
       cXML += '<total><ICMSTot>'
    
       For i := 1 to Len(s_aTotais[1])
          if !Empty(s_aTotais[1,i,1])
             cXML+='<'+s_aTotais[1,i,2]+'>'+s_aTotais[1,i,1]+'</'+s_aTotais[1,i,2]+'>'
          endif
       Next
    
       cXML += '</ICMSTot></total>'
    
       For i := 1 to Len(s_aTransp[1])
          if !Empty(s_aTransp[1,i,3])
             nFimTagPai := s_aTransp[1,i,4]
             cTagPai    += "|"+StrZero(nFimTagPai,2)+s_aTransp[1,i,3]
             cXML       += '<'+s_aTransp[1,i,3]+'>'
          endif
          if !Empty(s_aTransp[1,i,1])
             cXML += '<'+s_aTransp[1,i,2]+'>'+s_aTransp[1,i,1]+'</'+s_aTransp[1,i,2]+'>'
          endif
          if i == nFimTagPai
             nIni    := RAT("|",cTagPai)
             cTag    := Substr(cTagPai,nIni+1)
             cXML    += '</'+SubStr(cTag,3)+'>'
             cTagPai := SubStr(cTagPai,1,nIni-1)
             if nIni > 1
                nIni       := RAT("|",cTagPai)
                nFimTagPai := Val(Substr(cTagPai,nIni+1,2))
             else
                nFimTagPai := 0
             endif
             if SubStr(cTag,3) == "vol"
                cXML += '</transp>'
             endif
          endif
       Next
    
       if !Empty(s_aCobr[1,1,1])
          cXML += '<cobr>'
          For i := 1 to Len(s_aCobr[1])
             if !Empty(s_aCobr[1,i,1])
                if StrZero(i,2) $ "-01-04-07-10-13-16-19-22-25-28"
                   if i > 2
                      cXML += '</dup>'
                   endif
                   cXML += '<dup>'
                endif
                cXML += '<'+s_aCobr[1,i,2]+'>'+s_aCobr[1,i,1]+'</'+s_aCobr[1,i,2]+'>'
             endif
          Next
          cXML += '</dup></cobr>'
       endif
    
       if !Empty(s_cinfCpl) .or. !Empty(s_cInfAdFisco)
          //      cXML += '<infAdic>'
          //      if !Empty(s_cInfAdFisco)
             //         cXML += '<infAdFisco>'+s_cInfAdFisco+'</infAdFisco>'
          //      endif
          //      if !Empty(s_cinfCpl)
             //         cXML += '<infCpl>'+s_cinfCpl+'</infCpl>'
          //      endif
          //      cXML += '</infAdic>'
       endif
    
       cXML       += '</infNFe>'
       cXML       += '<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />'
       cXML       += '<Reference URI="#NFe'+cChave+'">'
       cXML       += '<Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /><Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />'
       cXML       += '<DigestValue>'+s_cDigVal+'</DigestValue></Reference></SignedInfo><SignatureValue></SignatureValue><KeyInfo></KeyInfo></Signature></NFe>'
       cXML       += '<protNFe versao="'+s_cVersao+'"><infProt>'
       cXML       += '<tpAmb>'+s_cTpAmb+'</tpAmb><verAplic>'+s_cVerAplic+'</verAplic><chNFe>'+cChave+'</chNFe><dhRecbto>'+s_cDhRecbto+'</dhRecbto>'
       cXML       += '<nProt>'+s_cnProt+'</nProt><digVal>'+s_cDigVal+'</digVal><cStat>'+s_ccStat+'</cStat><xMotivo>'+s_cxMotivo+'</xMotivo>'
       cXML       += '</infProt></protNFe></nfeProc>'
    
       cArqXml    := cPasta + '\' + cChave + '.xml'
       nArqHandle := FCreate(cArqXml, 0 )
    
       FWrite(nArqHandle,cXML)
       FClose(nArqHandle)
    
       *MsgInfo( 'Download realizado com sucesso! Arquivo gerado:' + CRLF + cArqXml, 'NF-e ')
    
    
       return nil
    function EventInfo( event, aParams )
    
       local cMsg := "Event: " + cValToChar( event ) + CRLF + CRLF
       local n
       
       cMsg += "Params: "
       
       for n = 1 to Len( aParams )
          cMsg += cValToChar( aParams[ n ] ) + CRLF
       next
       
       MsgInfo( cMsg )
       
       return nil
    
       /***********************************************************/

     

  11. Ainda usamos na empresa a da FSIST porem enquanto ele não avisava do comunicado, corri e ressuscitei  uma rotina antiga que tinha achado por aqui no forum e no pctoledo.

    Fiz uma adaptações para o xHarbour e esta funcional.

    Funcionamento: a URL atual do novo captcha não esta validando o click do usuário, caso acessem e digitem a chave e clique em continuar vai direto para area de visualização e download, me usei desse recurso para não solicitar nada ao usuário é só passar a chave e ser feliz

     

    Segue código abaixo

     

    // --------- Download XML NFe --------- //
    #include "fivewin.ch"
    #include "image.ch"
    #include "directry.ch"
    #include "fileio.ch"
    #include "tip.ch"
    
    #define URL_CONSULTA          "http://www.nfe.fazenda.gov.br/portal/consultaRecaptcha.aspx?tipoConsulta=completa&tipoConteudo=XbSeqxE8pl8="
    #define URL_CONSULTA_COMPLETA "http://www.nfe.fazenda.gov.br/portal/consultaRecaptcha.aspx?tipoConsulta=completa&tipoConteudo=XbSeqxE8pl8="
    
    Static s_cVersao := "", s_cTpAmb      := "", s_cVerAplic      := "", s_cDhRecbto := "", s_cnProt := "", s_cDigVal := ""
    Static s_cinfCpl := "", s_cInfAdFisco := "", s_cDiscAdicional := "", s_cxMotivo  := "", s_ccStat := ""
    Static s_aIde    := {}, s_aEmit       := {}, s_aDest          := {}, s_aDet      := {}, s_aICMS  := {}, s_aIPI    := {}
    Static s_aTransp := {}, s_aCobr       := {}, s_aMedicamentos  := {}, s_aTotais   := {}, s_aPIS   := {}, s_aCOFINS := {}
    Static s_cViewState, s_cViewStateGenerator, s_cHiddenToken, s_cEventValidation, s_cStringCookie, s_cHiddenSom
    // ---------------------------------------- //
    // Download XML //
    
    /******************************************************************************/
    procedure DownloadNFe( cChave, cPasta )
    /*
    */
       local oDialog, oIcone, oFonte, hInput := HB_Hash()
       local cCaptcha       := Space( 6 )
       local lSemParametros := Empty( PCount() )
    
       if lSemParametros
          cChave := Space( 44 )
          cPasta := ''
       endif
       
       MsgRun( 'Aguarde! Realizando Download do XML...',, {|| BaixarXML(cChave, cCaptcha, hInput, nil, lSemParametros, cPasta)})
    
    return
    
    /***********************************************************************************/
    static function BaixarXML( cChave, cCaptcha, hInput, oDialog, lSemParametros, cPasta )
    /*
    */
       Local p, oInternet, cParm, cRetorno := '', cHtml := '', c_span := ''
       Local nIni, cPart, cParte, nFim, cFile, nTamTag, nTotPro
    
       // Conteudo elementos da Matriz = {VALOR_TAG,TAG,TAG_PAI,Elemento_Final_TAG_PAI,LABEL_HTML,TAM_LABEL}
       // TAM_LABEL se ZERO pega tudo, se MAIOR que ZERO pega o tamanho no início e se MENOR que ZERO exclui o tamanho no início e pega o restante
    
       AADD(s_aIde,{{"","cUF","ide",21,"Chave de Acesso",2},; //1- tratamento especial
                    {"","cNF","",0,"Número",0},; //2- tratamento especial
                    {"","natOp","",0,"Natureza da Operação",0},; //3-
                    {"","indPag","",0,"Forma de Pagamento",1},; //4-
                    {"","mod","",0,"Modelo",0},; //5-
                    {"","serie","",0,"Série",0},; //6-
                    {"","nNF","",0,"Número",0},; //7-
                    {"","dhEmi","",0,"Data de Emissão",0},; //8- tratamento especial
                    {"","dhSaiEnt","",0,"Entrada",0},; //9- tratamento especial
                    {"","tpNF","",0,"Tipo da Operação",1},; //10-
                    {"","idDest","",0,"Destino da operação",1},; //11-
                    {"","cMunFG","",0,"Município da Ocorrência do Fato Gerador do ICMS",0},; //12-
                    {"","tpImp","",0,"Formato de Impressão DANFE",1},; //13- tratamento especial
                    {"","tpEmis","",0,"Tipo de Emissão",1},; //14-
                    {"","cDV","",0,"Chave de Acesso",0},; //15- tratamento especial
                    {"","tpAmb","",0,"Ambiente de autorização:",0},; //16- tratamento especial
                    {"","finNFe","",0,"Finalidade",1},; //17-
                    {"","indFinal","",0,"Consumidor final",1},; //18-
                    {"","indPres","",0,"Presença do Comprador",1},; //19-
                    {"","procEmi","",0,"Processo",1},; //20-
                    {"","verProc","",0,"Versão do Processo",0}}) //21-
    
       AADD(s_aEmit,{{"","CNPJ","emit",20,"CNPJ",0},; //1- tratamento especial
                     {"","CPF","",0,"CPF",0},; //2-
                     {"","xNome","",0,"Nome / Razão Social",0},; //3-
                     {"","xFant","",0,"Nome Fantasia",0},; //4-
                     {"","xLgr","enderEmit",15,"Endereço",0},; //5- tratamento especial
                     {"","nro","",0,"Endereço",0},; //6- tratamento especial
                     {"","xCpl","",0,"Endereço",0},; //7- tratamento especial
                     {"","xBairro","",0,"Bairro / Distrito",0},; //8-
                     {"","cMun","",0,"Município",7},; //9-
                     {"","xMun","",0,"Município",-10},; //10-
                     {"","UF","",0,"UF",0},; //11-
                     {"","CEP","",0,"CEP",0},; //12- tratamento especial
                     {"","cPais","",0,"País",4},; //13-
                     {"","xPais","",0,"País",-7},; //14-
                     {"","fone","",0,"Telefone",0},; //15- tratamento especial
                     {"","IE","",0,"Inscrição Estadual",0},; //16-
                     {"","IEST","",0,"Inscrição Estadual do Substituto Tributário",0},; //17-
                     {"","IM","",0,"Inscrição Municipal",0},; //18-
                     {"","CNAE","",0,"CNAE Fiscal",0},; //19-
                     {"","CRT","",0,"Código de Regime Tributário",1}}) //20-
    
       AADD(s_aDest,{{"","CNPJ","dest",20,"CNPJ",0},; //1-
                     {"","CPF","",0,"CPF",0},; //2-
                     {"","idEstrangeiro","",0,"",0},; //3-
                     {"","xNome","",0,"Nome / Razão Social",0},; //4-
                     {"","xLgr","enderDest",15,"Endereço",0},; //5- tratamento especial
                     {"","nro","",0,"Endereço",0},; //6- tratamento especial
                     {"","xCpl","",0,"Endereço",0},; //7- tratamento especial
                     {"","xBairro","",0,"Bairro / Distrito",0},; //8-
                     {"","cMun","",0,"Município",7},; //9-
                     {"","xMun","",0,"Município",-10},; //10-
                     {"","UF","",0,"UF",0},; //11-
                     {"","CEP","",0,"CEP",0},; //12- tratamento especial
                     {"","cPais","",0,"País",4},; //13-
                     {"","xPais","",0,"País",-7},; //14-
                     {"","fone","",0,"Telefone",0},; //15- tratamento especial
                     {"","indIEDest","",0,"Indicador IE",2},; //16- tratamento especial
                     {"","IE","",0,"Inscrição Estadual",0},; //17-
                     {"","ISUF","",0,"Inscrição SUFRAMA",0},; //18-
                     {"","IM","",0,"IM",0},; //19-
                     {"","email","",0,"E-mail",0}}) //20-
    
       //Conteudo elementos da Matriz = {VALOR_TAG,TAG,LABEL_HTML}
    
       AADD(s_aTotais,{{"0.00","vBC","Base de Cálculo ICMS"},; //1-
                       {"0.00","vICMS","Valor do ICMS"},; //2-
                       {"0.00","vICMSDeson","Valor do ICMS Desonerado"},; //3-
                       {"0.00","vFCPUFDest","Valor Total ICMS FCP"},; //4-
                       {"0.00","vBCST","Base de Cálculo ICMS ST"},; //5-
                       {"0.00","vST","Valor ICMS Substituição"},; //6-
                       {"0.00","vProd","Valor Total dos Produtos"},; //7-
                       {"0.00","vFrete","Valor do Frete"},; //8-
                       {"0.00","vSeg","Valor do Seguro"},; //9-
                       {"0.00","vDesc","Valor Total dos Descontos"},; //10-
                       {"0.00","vII","Valor Total do II"},; //11-
                       {"0.00","vIPI","Valor Total do IPI"},; //12-
                       {"0.00","vPIS","Valor do PIS"},; //13-
                       {"0.00","vCOFINS","Valor da COFINS"},; //14-
                       {"0.00","vOutro","Outras Despesas Acessórias"},; //15-
                       {"0.00","vNF","Valor Total da NFe"}}) //16-
    
       //Conteudo elementos da Matriz = {VALOR_TAG,TAG,TAG_PAI,Elemento_Final_TAG_PAI,LABEL_HTML,TAM_LABEL}
    
       AADD(s_aTransp,{{"","modFrete","transp",17,"Modalidade do Frete",1},; //1-
                       {"","CNPJ","transporta",8,"CNPJ",0},; //2-
                       {"","CPF","",0,"CPF",0},; //3-
                       {"","xNome","",0,"Razão Social / Nome",0},; //4-
                       {"","IE","",0,"Inscrição Estadual",0},; //5-
                       {"","xEnder","",0,"Endereço Completo",0},; //6-
                       {"","xMun","",0,"Município",0},; //7-
                       {"","UF","",0,"UF",0},; //8-
                       {"",'placa','veicTransp',11,'Placa',0},; //9-
                       {"","UF","",0,"UF",0},; //10-
                       {"","RNTC","",0,"RNTC",0},; //11-
                       {"","qVol","vol",17,"Quantidade",0},; //12-
                       {"","esp","",0,"Espécie",0},; //13-
                       {"","marca","",0,"Marca dos Volumes",0},; //14-
                       {"","nVol","",0,"Volume",0},; //15-
                       {"","pesoL","",0,"Peso Líquido",0},; //16-
                       {"","pesoB","",0,"Peso Bruto",0}}) //17-
    
       //Conteudo elementos da Matriz = {VALOR_TAG,TAG}
    
       AADD(s_aCobr,{{"","nDup"},; //1-
                     {"","dVenc"},; //2-
                     {"","vDup"},; //3-
                     {"","nDup"},; //4-
                     {"","dVenc"},; //5-
                     {"","vDup"},; //6-
                     {"","nDup"},; //7-
                     {"","dVenc"},; //8-
                     {"","vDup"},; //9-
                     {"","nDup"},; //10-
                     {"","dVenc"},; //11-
                     {"","vDup"},; //12-
                     {"","nDup"},; //13-
                     {"","dVenc"},; //14-
                     {"","vDup"},; //15-
                     {"","nDup"},; //16-
                     {"","dVenc"},; //17-
                     {"","vDup"},; //18-
                     {"","nDup"},; //19-
                     {"","dVenc"},; //20-
                     {"","vDup"},; //21-
                     {"","nDup"},; //22-
                     {"","dVenc"},; //23-
                     {"","vDup"},; //24-
                     {"","nDup"},; //25-
                     {"","dVenc"},; //26-
                     {"","vDup"},; //27-
                     {"","nDup"},; //28-
                     {"","dVenc"},; //29-
                     {"","vDup"}}) //30-
    
    	// fazer o acesso
    	nTentativas := 0
    	REPEAT 
       && http://msdn.microsoft.com/en-us/library/aa752084%28v=vs.85%29.aspx
       oIE:=TOleAuto():New( "InternetExplorer.Application" )
    	*
       oIE:ToolBar   := .T.
       oIE:StatusBar := .T.
       oIE:MenuBar   := .F.
       oIE:Visible   := .F.
       *
       oIE:Navigate2( "https://www.nfe.fazenda.gov.br/portal/consultaRecaptcha.aspx?tipoConsulta=completa&tipoConteudo=XbSeqxE8pl8=" )
       while oIE:Busy
          SysWait(.2)
       end
       *
    	oActdo:=oIE:Document()
       oActdo:All:Item("ctl00$ContentPlaceHolder1$txtChaveAcessoCompleta",0):Value:=cChave
    	SysWait()
    	*
    	oActdo:All:Item("ctl00$ContentPlaceHolder1$btnConsultar"):Click()
    	SysWait()
    	*
       GetWndDefault():Minimize()
    	while oIE:Busy
          SysWait()
       end
       *
       cHtml:=oIE:Document():All(0):OuterHTML
    	while oIE:Busy
          SysWait()
       end
       TRY
          oIE:Quit()
       catch
       end
       Release oIE                                                                    	
    	*
       cHtml:=strtran(cHtml,'&')
       cHtml:=strtran(cHtml,'nbsp;')
    	*
    	nTentativas ++ 
       UNTIL At('Realizar consulta com captcha sonoro',  cHtml) == 0 .or. nTentativas > 4
       if At('Realizar consulta com captcha sonoro',  cHtml) > 0 .or. nTentativas > 4
    		MsgAlert("Atenção tente novamente!","Atenção")
    		return .f.
    	endif
    	*
    	If !Empty(cHtml)
          nIni  := At('<html',  cHtml)
          cParte:= SubStr(cHtml, nIni)
          nIni  := At('<div class="divLarguraMaxima" id="ctl00_ContentPlaceHolder1_divBotoesConsulta"',  cParte)
          cParte:= SubStr(cParte, 1, nIni - 1)
          nFim  := At('</form>', cParte)
          cFile := SubStr(cParte, nFim)
    		// memowrit('site.txt',cfile)
          nIni   := RAt('fixo-prod-serv-numero',cFile)
          c_span := SubStr(cFile, nIni)
          nIni   := AT('<span>',c_span)+6                  
          nTamTag:= AT('</span>',c_span)-nIni
          nTotPro:= Val(AllTrim(SubStr(c_span,nIni,nTamTag)))
    		*
    		//Conteudo elementos da Matriz = {VALOR_TAG,TAG,LABEL_HTML,TAM_LABEL}
          For p := 1 to nTotPro
              AADD(s_aDet,{{"","cProd","Código do Produto",0},; //1-
                           {"","cEAN","Código EAN Comercial",0},; //2-
                           {"","xProd","fixo-prod-serv-descricao",0},; //3-
                           {"","NCM","Código NCM",0},; //4-
                           {"","NVE","",0},; //5-
                           {"","CEST","Código CEST",0},; //6-
                           {"","EXTIPI","Código EX da TIPI",0},; //7-
                           {"","CFOP","CFOP",0},; //8-
                           {"","uCom","Unidade Comercial",0},; //9-
                           {"","qCom","Quantidade Comercial",0},; //10-
                           {"","vUnCom","Valor unitário de comercialização",0},; //11-
                           {"","vProd","fixo-prod-serv-vb",0},; //12-
                           {"","cEANTrib","Código EAN Tributável",0},; //13-
                           {"","uTrib","Unidade Tributável",0},; //14-
                           {"","qTrib","Quantidade Tributável",0},; //15-
                           {"","vUnTrib","Valor unitário de tributação",0},; //16-
                           {"","vFrete","Valor Total do Frete",0},; //17-
                           {"","vSeg","Valor do Seguro",0},; //18-
                           {"","vDesc","Valor do Desconto",0},; //19-
                           {"","vOutro","Outras Despesas Acessórias",0},; //20-
                           {"","indTot","Indicador de Composição do Valor Total da NF-e",1},; //21-
                           {"","nItemPed","Item do pedido de compra",0}}) //22-
    
             AADD(s_aMedicamentos, {{"","Lote",'Nro. do Lote', 0},; //1-
                                    {"","qLote",'Quantidade de produtos no lote', 0},; //2-
                                    {"","dFab",'Data de fabricaçã', 0},; //3-
                                    {"","dVal",'Data de validade', 0},; //4-
                                    {"","vPMC",'Preço Máximo Consumido', 0},; //5-
                                    {"","infAdProd",'Descrição', 0}}) //6-
    
             AADD(s_aICMS,{{"","orig","Origem da Mercadoria",1},; //1- ICMS Normal e ST
                           {"","CST","Tributação do ICMS",2},; //2-
                           {"","CSOSN","Código de Situação da Operação",3},; //3-
                           {"","modBC","Modalidade Definição da BC do ICMS",1},; //4-
                           {"","pRedBC","Percentual Redução de BC do ICMS",0},; //5-
                           {"","vBC","Base de Cálculo",0},; //6-
                           {"","pICMS","Alíquota",0},; //7-
                           {"","vICMS","Valor",0},; //8-
                           {"","vICMSDeson","",0},; //9-
                           {"","motDesICMS","",0},; //10-
                           {"","modBCST","Modalidade de determinação da BC do ICMS ST",1},; //11-
                           {"","pMVAST","Percentual Margem Valor Adicionado do ICMS ST",0},; //12-
                           {"","pRedBCST","Percentual da Redução de BC do ICMS ST",0},; //13-
                           {"","vBCST","Valor da BC do ICMS ST",0},; //14-
                           {"","pICMSST","Alíquota do imposto do ICMS ST",0},; //15-
                           {"","vICMSST","Valor do ICMS ST",0},; //16-
                           {"","vBCSTRet","Valor da BC do ICMS ST retido",0},; //17-
                           {"","vICMSSTRet","Valor do ICMS ST retido",0},; //18-
                           {"","vICMSOp","",0},; //19-
                           {"","pDif","",0},; //20-
                           {"","vICMSDif","",0},; //21-
                           {"","pCredSN","Alíquota aplicável de cálculo do crédito",0},; //22-
                           {"","vCredICMSSN","Valor crédito do ICMS",0}}) //23-
    
             AADD(s_aIPI,{{"","cEnq","Código de Enquadramento", 3},;
                          {"","CST","CST", 2},; //1-
                          {"","vBC","Base de Cálculo", 0},; //2-
                          {"","pIPI","Alíquota", 0},; //3-
                          {"","vIPI","Valor IPI", 0},; //4-
                          {"","qBCProd","", 0},; //5-
                          {"","vAliqProd","", 0}}) //6-
    
             AADD(s_aPIS,{{"","CST","CST",2},; //1-
                          {"","vBC","Base de Cálculo",0},; //2-
                          {"","pPIS","Alíquota",0},; //3-
                          {"","vPIS","Valor",0},; //4-
                          {"","qBCProd","",0},; //5-
                          {"","vAliqProd","",0}}) //6-
    
             AADD(s_aCOFINS,{{"","CST","CST",2},; //1-
                             {"","vBC","Base de Cálculo",0},; //2-vBC
                             {"","pCOFINS","Alíquota",0},; //3-
                             {"","vCOFINS","Valor",0},; //4-
                             {"","qBCProd","",0},; //5-
                             {"","vAliqProd","",0}}) //6-
    
         Next
    
         nIni   := At('<div class="GeralXslt"',cFile)
         cParte := SubStr(cFile, nIni)
         nIni   := At('<div class="GeralXslt" id="Emitente"',cParte)
         cParte := SubStr(cParte, 1, nIni - 1) //ide
         //? "ide", !Empty(cParte)
    	  GeraTag("ide", cParte, cFile, cChave)
    
         nIni   := At('<div class="GeralXslt" id="Emitente"',cFile)
         cParte := SubStr(cFile, nIni)
         nIni   := At('</div>',cParte)
         cParte := SubStr(cParte, 1, nIni - 1) //emit
    	  //? "emit", !Empty(cParte)
         GeraTag("emit", cParte, cFile, cChave)
    
         *nIni   := At('<div id="DestRem"',cFile)
         nIni   := At('<div class="GeralXslt" id="DestRem"',cFile)
         cParte := SubStr(cFile, nIni)
         nIni   := At('</div>',cParte)
         cParte := SubStr(cParte, 1, nIni - 1) //dest
    	  *? "dest", !Empty(cParte)
         GeraTag("dest",cParte, cFile, cChave)
    
         *nIni   := At('<td class="fixo-prod-serv-numero"><span>', cFile)
         nIni   := At('<tr><td class="fixo-prod-serv-numero"><span>', cFile)
         cParte := SubStr(cFile, nIni)
    	  *nIni   := At('</body></html>', cParte)
    	  nIni   := At('<div class="nft" id="aba_nft_10">', cParte)
         cParte := SubStr(cParte, 1, nIni - 1) //det
         //? "det", !Empty(cParte)
    	  GeraTag("det", cParte, cFile, cChave)
    
         nIni   := At('<legend class="titulo-aba">Totais</legend>',cFile)
         cParte := SubStr(cFile, nIni+42)
    	  *nIni   := At('<div id="aba_nft_5"',cParte)
         nIni   := At('<div class="nft" id="aba_nft_5"',cParte)
         cParte := SubStr(cParte, 1, nIni - 1) //totais
         //? "totais", !Empty(cParte)
    	  GeraTag("totais", cParte, cFile, cChave)
    
         nIni   := At('Dados do Transporte</legend>',cFile)
         cParte := SubStr(cFile, nIni+29)
         nIni   := At('<div class="GeralXslt" id="Cobranca"',cParte)
         cParte := SubStr(cParte, 1, nIni - 1) //transp
         //? "transp", !Empty(cParte)
         GeraTag("transp", cParte, cFile, cChave)
    
         nIni   := At('<legend>Duplicatas</legend><table',cFile)
    
         if nIni > 0
            cParte := SubStr(cFile, nIni)
            nIni   := At('</table>',cParte)
            cParte := SubStr(cParte, 1, nIni - 1) //cobr
            *? "cobr",  !Empty(cParte)
    		  GeraTag("cobr", cParte, cFile, cChave)
         endif
    
         GravaXML(cChave, hInput, oDialog, lSemParametros, cPasta)
    
       Else
          MsgInfo('Erro ao ler retorno da Consulta!', 'Atenção!')
          Return .f.
       EndIf
    
    Return .t.
    
    /***********************************************************/
    static Function DigitoChave(cCodigoChave)
    /*
    */
       Local cIndice := '4329876543298765432987654329876543298765432'
       Local nDigito, nContador, nSoma := 0
    
       For nContador := 1 to 43
           nSoma += (Val(SubStr(cCodigoChave, nContador, 1)) * Val(SubStr(cIndice, nContador, 1)))
       Next
    
       nDigito := (nSoma % 11)
    
       If nDigito == 0 .Or. nDigito == 1
          nDigito := 0
       Else
          nDigito := (11 - nDigito)
       EndIf
    
       If SubStr(cCodigoChave, 44, 1) != LTrim(Str(nDigito, 1))
         MsgStop('A chave informada é inválida!', 'Atenção!')
         Return .f.
       EndIf
    
    Return .t.
    
    /********************************************************************/
    static Function Troca_Acento( cTexto )
    /*
    */
    
       cTexto := StrTran( cTexto, "&#243;", "ó" )
       cTexto := StrTran( cTexto, "&#225;", "á" )
       cTexto := StrTran( cTexto, "&#233;", "é" )
    
    Return cTexto
    
    /*******************************************************************/
    static Function GeraTag( _tag, cParte, cFile, cChave )
    /*
    */
       Local i, cPar_, c_Tag, nTamTag, nIni, c_span, cPar1_, nFim
    
       if _tag=="ide"
          cPar_:= StrTran(cFile,Chr(13)+Chr(10),"")
          cPar_:= StrTran(cPar_,Chr(160),"")
          nIni := At('<legend>Informações Complementares de Interesse do Contribuinte</legend>', cPar_)
    		
          if nIni>0
             c_span    := SubStr(cPar_, nIni+70)
             nIni      := AT('<div style="word-wrap: break-word">',c_span)
             c_span    := SubStr(c_span, nIni+35)
             nIni      := AT('</div></span>',c_span)
             s_cinfCpl := alltrim(SubStr(c_span,1,nIni-1))
          endif
    
          cPar_      := StrTran(cParte,Chr(13)+Chr(10),"")
          cPar_      := StrTran(cPar_,Chr(160),"")
    
          nIni       := AT('Situação Atual:',cPar_)
          c_span     := SubStr(cPar_, nIni+15)
          nIni       := AT('(Ambiente de autorização:',c_span)
          s_cxMotivo := Alltrim(SubStr(c_span,1,nIni-1))
    
          if "AUTORIZADA" $ s_cxMotivo
             s_ccStat   := "100"
             s_cxMotivo := "Autorizado o uso da NF-e"
          endif
    
          if "CANCELADA" $ s_cxMotivo
             s_ccStat   := "101"
             s_cxMotivo := "Cancelamento de NF-e homologado"
          endif
    
          nIni        := AT('Data Inclusão AN</label></td></tr><tr><td><span>',cPar_)
          c_span      := SubStr(cPar_, nIni+50)
          nIni        := AT('<span>',c_span)+6
          nTamTag     := AT('<input',c_span)-nIni
          s_cnProt    := alltrim(SubStr(c_span,nIni,nTamTag))
          c_span      := SubStr(c_span, nIni+nTamTag)
          nIni        := AT('<span>',c_span)+6
          c_span      := SubStr(c_span,nIni)
          nTamTag     := AT('</span>',c_span)-1 //nIni
          s_cDhRecbto := alltrim(SubStr(c_span,1,nTamTag))
          s_cDhRecbto := SubStr(s_cDhRecbto,7,4)+"-"+SubStr(s_cDhRecbto,4,2)+"-"+left(s_cDhRecbto,2)+"T"+Right(s_cDhRecbto,14)
          nIni        := AT('<i>Digest</i> Value da NF-e',cPar_)
          c_span      := SubStr(cPar_, nIni+20)
          nIni        := AT('<span>',c_span)+6
          nTamTag     := AT('</span>',c_span)-nIni
          s_cDigVal   := alltrim(SubStr(c_span,nIni,nTamTag))
    
          nIni        := AT('Versão XML',cParte)
          c_span      := SubStr(cParte, nIni)
          nIni        := AT('<span>',c_span)+6
          nTamTag     := AT('</span>',c_span)-nIni
          s_cVersao   := alltrim(SubStr(c_span,nIni,nTamTag))
    
          For i := 1 to Len(s_aIde[1])
    
              cPar_:= cParte
    
              if i == 12
                 cPar_:= cFile
              endif
    
              if i == 13
                 cPar_:= cFile
              endif
    
              nIni   := AT(s_aIde[1,i,5],cPar_)
              c_span := SubStr(cPar_, nIni)
    
              if i != 16
                 nIni     := AT('<span>', c_span) + 6
                 nTamTag  := AT('</span>', c_span) - nIni
                 c_tag    := alltrim(SubStr(c_span, nIni, nTamTag))
              else
                 nIni     := AT('</legend>', c_span)
                 c_tag    := alltrim(SubStr(c_span, 1, nIni - 1))
                 if AT('produção', c_tag) > 0
                    c_tag := "1"
                 else
                    c_tag := "2"
                 endif
                 s_cTpAmb := c_tag
              endif
    
              if i == 2
                 c_tag := SubStr(cChave, 36, 8)
                 //c_tag:= StrZero(Val(c_tag), 9)
              endif
    
              if i == 8 .or. i == 9
                 if !Empt(c_tag)
                    c_tag := SubStr(c_tag,7,4)+"-"+SubStr(c_tag,4,2)+"-"+left(c_tag,2)+"T"+SubStr(c_tag,12)
                 endif
              endif
    
              if i == 15
                 c_tag := right(c_tag,1)
              endif
    
              if s_aIde[1,i,6]!=0
                 if s_aIde[1,i,6]>0
                    c_tag := left(c_tag,s_aIde[1,i,6])
                 else
                    c_tag := SubStr(c_tag,Abs(s_aIde[1,i,6])+1)
                 endif
              endif
    
              s_aIde[1,i,1] := c_tag
    
          Next
       endif
    
       if _tag == "emit"
    
          For i := 1 to Len(s_aEmit[1])
    
              cPar_ := StrTran(cParte,Chr(13)+Chr(10),"")
              cPar_ := StrTran(cPar_,Chr(160),"")
              nIni  := AT(s_aEmit[1,i,5],cPar_)
    
              if nIni > 0
                 c_span  := SubStr(cPar_, nIni)
                 nIni    := AT('<span>',c_span)+6
                 nTamTag := AT('</span>',c_span)-nIni
                 c_tag   := Alltrim(SubStr(c_span,nIni,nTamTag))
    
                 if i >= 1 .and. i <= 2
                    c_tag := StrTran(c_tag,".","")
                    c_tag := StrTran(c_tag,"/","")
                    c_tag := StrTran(c_tag,"-","")
                 endif
    
                 if i >= 5 .and. i <= 7
    
                    nIni := AT(",",c_tag)
    
                    if i == 5
                       c_tag := Left(c_tag,nIni-1)
                    elseif i == 6
                       c_tag := AllTrim(SubStr(c_tag, nIni + 1))
                       nIni  := AT(" ", c_tag)
                       if nIni > 0
                          c_tag := Left(c_tag, nIni - 1)
                       endif
                    else
                       c_tag := AllTrim(SubStr(c_tag, nIni + 1))
                       nIni  := AT(" ", c_tag)
                       if nIni > 0
                          c_tag := alltrim(SubStr(c_tag, nIni + 1))
                       else
                          c_tag := ""
                       endif
                    endif
                 endif
    
                 if i == 12
                    c_tag := StrTran(c_tag,"-","")
                 endif
    
                 if i==15
                    c_tag := StrTran(c_tag,"(","")
                    c_tag := StrTran(c_tag,")","")
                    c_tag := StrTran(c_tag,"-","")
                 endif
    
                 if s_aEmit[1, i, 6] != 0
                    if s_aEmit[1, i, 6] > 0
                       c_tag := left(c_tag,s_aEmit[1, i, 6])
                    else
                       c_tag := alltrim(SubStr(c_tag, Abs(s_aEmit[1, i, 6]) + 1))
                       c_tag := alltrim(StrTran(c_tag, "-", ""))
                    endif
                 endif
                 s_aEmit[1, i, 1] := c_tag
              endif
          Next
    
       endif
    
       if _tag == "dest"
          For i := 1 to Len(s_aDest[1])
              cPar_ := StrTran(cParte, Chr(13) + Chr(10), "")
              cPar_ := StrTran(cPar_, Chr(160), "")
              nIni  := AT(s_aDest[1, i, 5], cPar_)
              if nIni > 0
                 c_span  := SubStr(cPar_, nIni)
                 nIni    := AT('<span>',c_span)+6
                 nTamTag := AT('</span>',c_span)-nIni
                 c_tag   := AllTrim(SubStr(c_span, nIni, nTamTag))
                 if i >= 1 .and. i <= 2
                    c_tag := StrTran(c_tag, ".", "")
                    c_tag := StrTran(c_tag, "/", "")
                    c_tag := StrTran(c_tag, "-", "")
                 endif
                 If i >= 5 .and. i <= 7
                    nIni := AT(",", c_tag)
                    if i == 5
                       c_tag := Left(c_tag,nIni-1)
                    elseif i == 6
                       c_tag := AllTrim(SubStr(c_tag, nIni + 1))
                       nIni  := AT(" ", c_tag)
                       if nIni > 0
                          c_tag := Left(c_tag, nIni - 1)
                       endif
                    else
                       c_tag := AllTrim(SubStr(c_tag, nIni + 1))
                       nIni  := AT(" ", c_tag)
                       if nIni > 0
                          c_tag := alltrim(SubStr(c_tag, nIni + 1))
                       else
                          c_tag := ""
                       endif
                    endif
                 EndIf
                 if i == 12
                    c_tag := StrTran(c_tag, "-", "")
                 endif
                 if i == 15
                    c_tag := StrTran(c_tag, "(", "")
                    c_tag := StrTran(c_tag, ")", "")
                    c_tag := StrTran(c_tag, "-", "")
                 endif
                 if i==16
                    c_tag := alltrim(Str(Val(c_tag)))
                 endif
                 if s_aDest[1, i, 6] != 0
                    if s_aDest[1, i, 6] > 0
                       c_tag := left(c_tag, s_aDest[1, i, 6])
                    else
                       c_tag := alltrim(SubStr(c_tag, Abs(s_aDest[1,i,6]) + 1))
                       c_tag := alltrim(StrTran(c_tag, "-", ""))
                    endif
                 endif
                 s_aDest[1, i, 1] := c_tag
              endif
          Next
    
       endif
    	
       if _tag == "det"
    		cPar_ := StrTran(cParte, Chr(13) + Chr(10), "")
    		cPar_ := StrTran(cPar_, Chr(160), "")
    		For p := 1 to Len(s_aDet)
    			 For i := 1 to Len(s_aDet[p])
    				  nIni := At(s_aDet[p, i, 3], cPar_)
                  if nIni > 0
                     c_span  := SubStr(cPar_, nIni)
                     nIni    := At('<span>',c_span)+6
                     nTamTag := At('</span>',c_span)-nIni
                     c_tag   := AllTrim(SubStr(c_span,nIni,nTamTag))
                     if s_aDet[p, i, 4] != 0
                        if s_aDet[p, i, 4] > 0
                           c_tag := left(c_tag, s_aDet[p, i, 4])
                        else
                           c_tag := alltrim(SubStr(c_tag, Abs(s_aDet[p, i, 4]) + 1))
                           c_tag := alltrim(StrTran(c_tag, "-", ""))
                        endif
                     endif
                     If i != 3
                        c_tag := StrTran(c_tag, ".", "")
                        c_tag := StrTran(c_tag, ",", ".")
                     endIf
                     s_aDet[p, i, 1] := c_tag
                  endif
              Next
    			 
              For i := 1 To Len(s_aICMS[p])
                  nIni := At(s_aICMS[p, i, 3], cPar_)
                  if nIni > 0
                     c_span  := SubStr(cPar_, nIni)
                     nIni    := At('<span>', c_span) + 6
                     nTamTag := At('</span>', c_span) - nIni
                     c_tag   := AllTrim(SubStr(c_span, nIni, nTamTag))
                     If s_aICMS[p, i, 4] != 0
                        if s_aICMS[p, i, 4] > 0
                           c_tag := Left(c_tag, s_aICMS[p, i, 4])
                        else
                           c_tag := AllTrim(SubStr(c_tag, Abs(s_aICMS[p, i, 4]) + 1))
                           c_tag := AllTrim(StrTran(c_tag, "-", ""))
                        endif
                     endif
                     c_tag            := StrTran(c_tag, ".", "")
                     c_tag            := StrTran(c_tag, ",", ".")
                     s_aICMS[p, i, 1] := c_tag
                  endif
              Next
    
              nIni := AT('<legend>Imposto Sobre Produtos Industrializados</legend>', cPar_)
    
              if nIni > 0
                 cPar_ := SubStr(cPar_, nIni)
                 For i := 1 To Len(s_aIPI[p])
                     nIni := AT(s_aIPI[p, i, 3], cPar_)
                     if nIni > 0
                        c_span  := SubStr(cPar_, nIni)
                        nIni    := AT('<span>', c_span) + 6
                        nTamTag := AT('</span>', c_span) - nIni
                        c_tag   := AllTrim(SubStr(c_span, nIni, nTamTag))
                        if s_aIPI[p, i, 4] != 0
                           if s_aIPI[p, i, 4] > 0
                              c_tag := Left(c_tag, s_aIPI[p, i, 4])
                           else
                              c_tag := Alltrim(SubStr(c_tag, Abs(s_aIPI[p, i, 4]) + 1))
                              c_tag := Alltrim(StrTran(c_tag, "-", ""))
                           endif
                        endif
                        c_tag           := StrTran(c_tag, ".", "")
                        c_tag           := StrTran(c_tag, ",", ".")
                        s_aIPI[p, i, 1] := c_tag
                     endif
                 Next
              endif
    
              nIni := At('<legend class="toggle">PIS</legend>', cPar_)
    
              if nIni > 0
                 cPar_ := SubStr(cPar_, nIni)
                 For i := 1 to Len(s_aPIS[p])
    	  		     	  IF P == Len(s_aPIS)
    					  	  nFim  := LEN(cPar_)
    					  ELSE	  
    	                 nFim  := At('<td class="fixo-prod-serv-numero"><span>', cPar_)
    	              ENDIF   
                     cPar1_:= SubStr(cPar_, 1, nFim)
                     nIni  := AT(s_aPIS[p, i, 3], cPar1_)
                     if nIni > 0
                        c_span  := SubStr(cPar1_, nIni)
                        nIni    := At('<span>', c_span) + 6
                        nTamTag := At('</span>', c_span) - nIni
                        c_tag   := AllTrim(SubStr(c_span, nIni, nTamTag))
                        if s_aPIS[p,i,4] != 0
                           if s_aPIS[p,i,4] > 0
                              c_tag := Left(c_tag,s_aPIS[p,i,4])
                           else
                              c_tag := AllTrim(SubStr(c_tag, Abs(s_aPIS[p, i, 4]) + 1))
                              c_tag := AllTrim(StrTran(c_tag, "-", ""))
                           endif
                        endif
                        c_tag           := StrTran(c_tag, ".", "")
                        c_tag           := StrTran(c_tag, ",", ".")
                        s_aPIS[p, i, 1] := c_tag
                     endif
                 Next
              endif
    			 *
    			 nIni := AT('<legend class="toggle">COFINS</legend>', cPar_)
    			 
    			 if nIni > 0
                 cPar_ := SubStr(cPar_, nIni)
                 For i := 1 to Len(s_aCOFINS[p])
    	  		     	  IF P == Len(s_aCOFINS)
    					  	  nFim  := LEN(cPar_)
    					  ELSE	  
    					  	  nFim  := At('<td class="fixo-prod-serv-numero">', cPar_)
    					  ENDIF	
    	  		    	  cPar1_:= SubStr(cPar_, 1, nFim)
    					  nIni  := AT(s_aCOFINS[p, i, 3], cPar1_)
                     if nIni > 0
                        c_span  := SubStr(cPar1_, nIni)
                        nIni    := AT('<span>', c_span) + 6
                        nTamTag := AT('</span>', c_span) - nIni
                        c_tag   := alltrim(SubStr(c_span, nIni, nTamTag))
                        if s_aCOFINS[p, i, 4] != 0
                           if s_aCOFINS[p, i, 4] > 0
                              c_tag := left(c_tag, s_aCOFINS[p, i, 4])
                           else
                              c_tag := alltrim(SubStr(c_tag, Abs(s_aCOFINS[p, i, 4]) + 1))
                              c_tag := alltrim(StrTran(c_tag, "-", ""))
                           endif
                        endif
                        c_tag              := StrTran(c_tag, ".", "")
                        c_tag              := StrTran(c_tag, ",", ".")
                        s_aCOFINS[p, i, 1] := c_tag
                     endif
                 Next
              endif
    			 
              nIni := At('<legend>Detalhamento específico dos medicamentos</legend>', cPar_)
    
              if nIni > 0
                 cPar_ := SubStr(cPar_, nIni)
                 For i := 1 to Len(s_aMedicamentos[p])
                     nIni := AT(s_aMedicamentos[p, i, 3], cPar_)
                     if nIni > 0
                        c_span  := SubStr(cPar_, nIni)
                        nIni    := At('<span>', c_span) + 6
                        nTamTag := At('</span>', c_span) - nIni
                        c_tag   := AllTrim(SubStr(c_span, nIni, nTamTag))
                        if s_aMedicamentos[p,i,4] != 0
                           if s_aMedicamentos[p,i,4] > 0
                              c_tag := Left(c_tag,s_aMedicamentos[p,i,4])
                           else
                              c_tag := AllTrim(SubStr(c_tag, Abs(s_aMedicamentos[p, i, 4]) + 1))
                              c_tag := AllTrim(StrTran(c_tag, "-", ""))
                           endif
                        endif
                        If i != 6
                           c_tag := StrTran(c_tag, ".", "")
                           c_tag := StrTran(c_tag, ",", ".")
                        endif
                        if StrZero(i, 2) $ "-03-04"
                           c_tag:=SubStr(c_tag,7,4)+"-"+SubStr(c_tag,4,2)+"-"+left(c_tag,2)
                        endif
                        s_aMedicamentos[p, i, 1] := c_tag
                     endif
                 Next
              endif
    
              nIni  := At('<td class="fixo-prod-serv-numero"><span>', cPar_)
              cPar_ := SubStr(cPar_, nIni)
    
          Next
       endif
    
       if _tag=="totais"
          For i := 1 to Len(s_aTotais[1])
              cPar_ := StrTran(cParte,Chr(13)+Chr(10),"")
              cPar_ := StrTran(cPar_,Chr(160),"")
              nIni  := AT(s_aTotais[1,i,3],cPar_)
              if nIni > 0
                 c_span           := SubStr(cPar_, nIni)
                 nIni             := AT('<span>',c_span)+6
                 nTamTag          := AT('</span>',c_span)-nIni
                 c_tag            := alltrim(SubStr(c_span,nIni,nTamTag))
                 c_tag            := StrTran(c_tag,".","")
                 c_tag            := StrTran(c_tag,",",".")
                 s_aTotais[1,i,1] := c_tag
              endif
          Next
       endif
    
       if _tag=="transp"
          For i := 1 to Len(s_aTransp[1])
              cPar_ := StrTran(cParte,Chr(13)+Chr(10),"")
              cPar_ := StrTran(cPar_,Chr(160),"")
              nIni  := AT(s_aTransp[1,i,5],cPar_)
              if nIni > 0
                 c_span  := SubStr(cPar_, nIni)
                 nIni    := AT('<span>',c_span)+6
                 nTamTag := AT('</span>',c_span)-nIni
                 c_tag   := alltrim(SubStr(c_span,nIni,nTamTag))
                 if i >= 2 .and. i <= 3
                    c_tag := StrTran(c_tag,".","")
                    c_tag := StrTran(c_tag,"/","")
                    c_tag := StrTran(c_tag,"-","")
                 endif
                 if s_aTransp[1,i,6] != 0
                    if s_aTransp[1,i,6]>0
                       c_tag := left(c_tag,s_aTransp[1,i,6])
                    else
                       c_tag := alltrim(SubStr(c_tag,Abs(s_aTransp[1,i,6])+1))
                       c_tag := alltrim(StrTran(c_tag,"-",""))
                    endif
                 endif
                 s_aTransp[1,i,1] := c_tag
              endif
          Next
       endif
    
       if _tag == "cobr"
          cPar_ := StrTran(cParte,Chr(13)+Chr(10),"")
          cPar_ := StrTran(cPar_,Chr(160),"")
          For i := 1 to Len(s_aCobr[1])
              nIni := AT('<span>',cPar_)
              if nIni > 0
                 cPar_   := SubStr(cPar_, nIni+6)
                 nTamTag := AT('</span>',cPar_)-1
                 c_tag   := alltrim(SubStr(cPar_,1,nTamTag))
                 c_tag   := StrTran(c_tag,".","")
                 c_tag   := StrTran(c_tag,",",".")
                 if StrZero(i,2) $ "-02-05-08-11-14-17-20-23-26-29"
                    c_tag := SubStr(c_tag,7,4)+"-"+SubStr(c_tag,4,2)+"-"+left(c_tag,2)
                 endif
                 s_aCobr[1,i,1] := c_tag
              else
                 Exit
              endif
          Next
       endif
    
    return Nil
    
    /**************************************************************************************************/
    static function GravaXML(cChave, hInput, oDialog, lSemParametros, cPasta)
    /*
    */
       Local i, p, lTemTag, cTagPai, nFimTagPai, nIni, cTag, nArqHandle, cArqXml, cTag_
       Local cXML :='<?xml version="1.0" encoding="UTF-8"?><nfeProc versao="'+s_cVersao+'" xmlns="http://www.portalfiscal.inf.br/nfe"><NFe xmlns="http://www.portalfiscal.inf.br/nfe"><infNFe versao="'+s_cVersao+'" Id="NFe'+cChave+'">'
    
       cTagPai    := ""
       nFimTagPai := 0
    
       For i := 1 to Len(s_aIde[1])
           if !Empt(s_aIde[1,i,3])
              nFimTagPai := s_aIde[1,i,4]
              cTagPai    += "|"+StrZero(nFimTagPai,2)+s_aIde[1,i,3]
              cXML       += '<'+s_aIde[1,i,3]+'>'
           endif
           if !Empty(s_aIde[1,i,1])
              cXML += '<'+s_aIde[1,i,2]+'>'+s_aIde[1,i,1]+'</'+s_aIde[1,i,2]+'>'
           endif
           if i == nFimTagPai
              nIni    := RAT("|",cTagPai)
              cTag    := Substr(cTagPai,nIni+1)
              cXML    += '</'+SubStr(cTag,3)+'>'
              cTagPai := SubStr(cTagPai,1,nIni-1)
              if nIni > 1
                 nIni       := RAT("|",cTagPai)
                 nFimTagPai := Val(Substr(cTagPai,nIni+1,2))
              else
                 nFimTagPai := 0
              endif
           endif
       Next
    
       For i := 1 to Len(s_aEmit[1])
           if !Empty(s_aEmit[1,i,3])
              nFimTagPai := s_aEmit[1,i,4]
              cTagPai    += "|"+StrZero(nFimTagPai,2)+s_aEmit[1,i,3]
              cXML       += '<'+s_aEmit[1,i,3]+'>'
           endif
           if !Empty(s_aEmit[1,i,1])
              cXML += '<'+s_aEmit[1,i,2]+'>'+s_aEmit[1,i,1]+'</'+s_aEmit[1,i,2]+'>'
           endif
           if i == nFimTagPai
              nIni    := RAT("|",cTagPai)
              cTag    := Substr(cTagPai,nIni+1)
              cXML    += '</'+SubStr(cTag,3)+'>'
              cTagPai := SubStr(cTagPai,1,nIni-1)
              if nIni > 1
                 nIni       := RAT("|",cTagPai)
                 nFimTagPai := Val(Substr(cTagPai,nIni+1,2))
              else
                 nFimTagPai := 0
              endif
           endif
       Next
    
       For i := 1 to Len(s_aDest[1])
           if !Empt(s_aDest[1,i,3])
              nFimTagPai := s_aDest[1,i,4]
              cTagPai    += "|"+StrZero(nFimTagPai,2)+s_aDest[1,i,3]
              cXML       += '<'+s_aDest[1,i,3]+'>'
           endif
           if !Empt(s_aDest[1,i,1])
              cXML += '<'+s_aDest[1,i,2]+'>'+s_aDest[1,i,1]+'</'+s_aDest[1,i,2]+'>'
           endif
           if i == nFimTagPai
              nIni    := RAT("|",cTagPai)
              cTag    := Substr(cTagPai,nIni+1)
              cXML    += '</'+SubStr(cTag,3)+'>'
              cTagPai := SubStr(cTagPai,1,nIni-1)
              if nIni > 1
                 nIni       := RAT("|",cTagPai)
                 nFimTagPai := Val(Substr(cTagPai,nIni+1,2))
              else
                 nFimTagPai := 0
              endif
           endif
       Next
    	
    	For p := 1 to Len(s_aDet)
           cXML += '<det nItem="'+alltrim(Str(p))+'"><prod>'
           For i := 1 to Len(s_aDet[p])
               if !Empt(s_aDet[p,i,1])
                  cXML += '<'+s_aDet[p,i,2]+'>'+s_aDet[p,i,1]+'</'+s_aDet[p,i,2]+'>'
               endif
           Next
    
           lTemTag := .F.
           For i := 1 to Len(s_aMedicamentos[p])
               if i == 1
                  if !Empty(s_aMedicamentos[p,i,1])
                     cXML    += '<med><nLote>' + s_aMedicamentos[p,i,1] + '</nLote>'
                     lTemTag := .t.
                  endif
               Else
                  if !Empty(s_aMedicamentos[p,i,1])
                     If i == 6
                        s_cDiscAdicional := '<'+s_aMedicamentos[p,i,2]+'>'+ s_aMedicamentos[p,i,1] + '</'+s_aMedicamentos[p,i,2]+'>'
                     Else
                        cXML             += '<'+s_aMedicamentos[p,i,2]+'>'+ s_aMedicamentos[p,i,1] + '</'+s_aMedicamentos[p,i,2]+'>'
                     Endif
                  endif
               EndIf
           Next
    
           if lTemTag
              cXML += '</med>'
           endif
    
           cXML  += '</prod><imposto><ICMS>'
           cTag_ := 'ICMS'
    
           For i := 1 to Len(s_aICMS[p])
               if i == 1
                  if !Empty(s_aICMS[p, 2, 1])
                     cTag_ += s_aICMS[p, 2, 1]
                  else
                     cTag_ += 'SN' + s_aICMS[p, 3, 1]
                  endif
                  cXML += '<' + cTag_ + '>'
               endif
               if !Empty(s_aICMS[p, i, 1])
                  If s_aICMS[p, 2, 1] == '00'
                     If StrZero(i, 2) $ "-01-02-04-06-07-08"
                        cXML += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                     EndIf
                  ElseIf s_aICMS[p, 2, 1] == '10'
                     If StrZero(i, 2) $ "-01-02-04-06-07-08-11-12-13-14-15-16"
                        cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                     EndIf
                  ElseIf s_aICMS[p, 2, 1] == '20'
                     If StrZero(i, 2) $ "-01-02-04-05-06-07-08-09-10"
                        cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                     EndIf
                  ElseIf s_aICMS[p, 2, 1] == '30'
                     If StrZero(i, 2) $ "-01-02-11-12-13-14-15-16-09-10"
                        cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                     EndIf
                  ElseIf s_aICMS[p, 2, 1] == '40' .or. s_aICMS[p, 2, 1] == '41' .Or. s_aICMS[p, 2, 1] == '50'
                     If StrZero(i, 2) $ "-01-02-09-10"
                        cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                     EndIf
                  ElseIf s_aICMS[p, 2, 1] == '51'
                     If StrZero(i, 2) $ "-01-02-04-05-06-07-08-19-20-21"
                        cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                     EndIf
                  ElseIf s_aICMS[p, 2, 1] == '60'
                     If StrZero(i, 2) $ "-01-02-17-18"
                        cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                     EndIf
                  ElseIf s_aICMS[p, 2, 1] == '70'
                     If StrZero(i, 2) $ "-01-02-04-05-06-07-08-09-10-11-12-13-14-15-16"
                        cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                     EndIf
                  ElseIf s_aICMS[p, 2, 1] == '90'
                     If StrZero(i, 2) $ "-01-02-04-05-06-07-08-11-12-13-14-15-16"
                        cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                     EndIf
                  Else
                     cXml += '<' + s_aICMS[p, i, 2] + '>' + s_aICMS[p, i, 1] + '</' + s_aICMS[p, i, 2] + '>'
                  EndIf
               endif
           Next
    
           cXML    += '</'+cTag_+'></ICMS>'
           lTemTag := .F.
    
           For i := 1 to Len(s_aIPI[p])
               if i == 1
                  if !Empty(s_aIPI[p,i,1])
                     cXML    += '<IPI><cEnq>' + s_aIPI[p,i,1] + '</cEnq><IPITrib>'
                     lTemTag := .T.
                  endif
               Else
                  if !Empty(s_aIPI[p,i,1])
                     cXML += '<'+s_aIPI[p,i,2]+'>'+ s_aIPI[p,i,1] + '</'+s_aIPI[p,i,2]+'>'
                  endif
               EndIf
           Next
    
           if lTemTag
              cXML += '</IPITrib></IPI>'
           endif
    
           lTemTag := .F.
    
           For i:= 1 to Len(s_aPIS[p])
               if i == 1
                  if !Empty(s_aPIS[p, i, 1])
                     If Val(s_aPIS[p, 1, 1]) >= 1 .And. Val(s_aPIS[p, 1, 1]) <= 2
                        cXML += '<PIS><PISAliq>'
                     ElseIf Val(s_aPIS[p, 1, 1]) == 3
                        cXML += '<PIS><PISQte>'
                     ElseIf Val(s_aPIS[p, 1, 1]) >= 4 .And. Val(s_aPIS[p, 1, 1]) <= 9
                        cXML += '<PIS><PISNT>'
                     ElseIf Val(s_aPIS[p, 1, 1]) >= 49 .And. Val(s_aPIS[p, 1, 1]) <= 99
                        cXML += '<PIS><PISOutr>'
                     EndIf
                     lTemTag := .T.
                  endif
               endif
               if !Empty(s_aPIS[p, i, 1])
                  cXML += '<' + s_aPIS[p,i,2] + '>' + s_aPIS[p,i,1] + '</' + s_aPIS[p,i,2] + '>'
               endif
           Next
    
           if lTemTag
              If Val(s_aPIS[p, 1, 1]) >= 1 .And. Val(s_aPIS[p, 1, 1]) <= 2
                 cXML += '</PISAliq></PIS>'
              ElseIf Val(s_aPIS[p, 1, 1]) == 3
                 cXML += '</PISQte></PIS>'
              ElseIf Val(s_aPIS[p, 1, 1]) >= 4 .And. Val(s_aPIS[p, 1, 1]) <= 9
                 cXML += '</PISNT></PIS>'
              ElseIf Val(s_aPIS[p, 1, 1]) >= 49 .And. Val(s_aPIS[p, 1, 1]) <= 99
                 cXML+= '</PISOutr></PIS>'
              EndIf
           endif
    
           lTemTag := .F.
    
           For i := 1 to Len(s_aCOFINS[p])
               if i == 1
                  if !Empty(s_aCOFINS[p,i,1])
                     If Val(s_aPIS[p, 1, 1]) >= 1 .And. Val(s_aPIS[p, 1, 1]) <= 2
                        cXML += '<COFINS><COFINSAliq>'
                     ElseIf Val(s_aPIS[p, 1, 1]) == 3
                        cXML += '<COFINS><COFINSQte>'
                     ElseIf Val(s_aPIS[p, 1, 1]) >= 4 .And. Val(s_aPIS[p, 1, 1]) <= 9
                        cXML += '<COFINS><COFINSNT>'
                     ElseIf Val(s_aPIS[p, 1, 1]) >= 49 .And. Val(s_aPIS[p, 1, 1]) <= 99
                        cXML += '<COFINS><COFINSOutr>'
                     EndIf
                     lTemTag := .T.
                  endif
               endif
               if !Empty(s_aCOFINS[p,i,1])
                  cXML += '<' + s_aCOFINS[p, i, 2] + '>' + s_aCOFINS[p, i, 1] + '</' + s_aCOFINS[p, i, 2] + '>'
               endif
           Next
    
           if lTemTag
              If Val(s_aPIS[p, 1, 1]) >= 1 .And. Val(s_aPIS[p, 1, 1]) <= 2
                 cXML += '</COFINSAliq></COFINS>'
              ElseIf Val(s_aPIS[p, 1, 1]) == 3
                 cXML += '</COFINSQte></COFINS>'
              ElseIf Val(s_aPIS[p, 1, 1]) >= 4 .And. Val(s_aPIS[p, 1, 1]) <= 9
                 cXML += '</COFINSNT></COFINS>'
              ElseIf Val(s_aPIS[p, 1, 1]) >= 49 .And. Val(s_aPIS[p, 1, 1]) <= 99
                 cXML+= '</COFINSOutr></COFINS>'
              EndIf
           endif
           cXML += '</imposto>'
           If !Empty(s_cDiscAdicional)
              cXml += s_cDiscAdicional
           EndIf
           cXML += '</det>'
       Next
    
       cXML += '<total><ICMSTot>'
    
       For i := 1 to Len(s_aTotais[1])
           if !Empty(s_aTotais[1,i,1])
              cXML+='<'+s_aTotais[1,i,2]+'>'+s_aTotais[1,i,1]+'</'+s_aTotais[1,i,2]+'>'
           endif
       Next
    
       cXML += '</ICMSTot></total>'
    
       For i := 1 to Len(s_aTransp[1])
           if !Empty(s_aTransp[1,i,3])
              nFimTagPai := s_aTransp[1,i,4]
              cTagPai    += "|"+StrZero(nFimTagPai,2)+s_aTransp[1,i,3]
              cXML       += '<'+s_aTransp[1,i,3]+'>'
           endif
           if !Empty(s_aTransp[1,i,1])
              cXML += '<'+s_aTransp[1,i,2]+'>'+s_aTransp[1,i,1]+'</'+s_aTransp[1,i,2]+'>'
           endif
           if i == nFimTagPai
              nIni    := RAT("|",cTagPai)
              cTag    := Substr(cTagPai,nIni+1)
              cXML    += '</'+SubStr(cTag,3)+'>'
              cTagPai := SubStr(cTagPai,1,nIni-1)
              if nIni > 1
                 nIni       := RAT("|",cTagPai)
                 nFimTagPai := Val(Substr(cTagPai,nIni+1,2))
              else
                 nFimTagPai := 0
              endif
              if SubStr(cTag,3) == "vol"
                 cXML += '</transp>'
              endif
           endif
       Next
    
       if !Empty(s_aCobr[1,1,1])
          cXML += '<cobr>'
          For i := 1 to Len(s_aCobr[1])
              if !Empty(s_aCobr[1,i,1])
                 if StrZero(i,2) $ "-01-04-07-10-13-16-19-22-25-28"
                    if i > 2
                       cXML += '</dup>'
                    endif
                    cXML += '<dup>'
                 endif
                 cXML += '<'+s_aCobr[1,i,2]+'>'+s_aCobr[1,i,1]+'</'+s_aCobr[1,i,2]+'>'
              endif
          Next
          cXML += '</dup></cobr>'
       endif
    
       if !Empty(s_cinfCpl) .or. !Empty(s_cInfAdFisco)
    //      cXML += '<infAdic>'
    //      if !Empty(s_cInfAdFisco)
    //         cXML += '<infAdFisco>'+s_cInfAdFisco+'</infAdFisco>'
    //      endif
    //      if !Empty(s_cinfCpl)
    //         cXML += '<infCpl>'+s_cinfCpl+'</infCpl>'
    //      endif
    //      cXML += '</infAdic>'
       endif
    
       cXML       += '</infNFe>'
       cXML       += '<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />'
       cXML       += '<Reference URI="#NFe'+cChave+'">'
       cXML       += '<Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /><Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />'
       cXML       += '<DigestValue>'+s_cDigVal+'</DigestValue></Reference></SignedInfo><SignatureValue></SignatureValue><KeyInfo></KeyInfo></Signature></NFe>'
       cXML       += '<protNFe versao="'+s_cVersao+'"><infProt>'
       cXML       += '<tpAmb>'+s_cTpAmb+'</tpAmb><verAplic>'+s_cVerAplic+'</verAplic><chNFe>'+cChave+'</chNFe><dhRecbto>'+s_cDhRecbto+'</dhRecbto>'
       cXML       += '<nProt>'+s_cnProt+'</nProt><digVal>'+s_cDigVal+'</digVal><cStat>'+s_ccStat+'</cStat><xMotivo>'+s_cxMotivo+'</xMotivo>'
       cXML       += '</infProt></protNFe></nfeProc>'
    
       cArqXml    := cPasta + '\' + cChave + '.xml'
       nArqHandle := FCreate(cArqXml, 0 )
    
       FWrite(nArqHandle,cXML)
       FClose(nArqHandle)
    
       *MsgInfo( 'Download realizado com sucesso! Arquivo gerado:' + CRLF + cArqXml, 'NF-e ')
    
    
    return nil

     

  12.  

    Amiguinhos,

    Matheus Farias,

    O CRUD é baseado em PHP, C#, ...?

    Interessante ver a sintaxe xBase, pois facilitaria muito a programação para os conhecedores.

    Não consegui ver a imagem.

     

    Exemplo ORM
     

    CLASS Usuario FROM Entidade
    
       DATA cNome AS CHARACTER INIT SPACE(50)
       DATA cSenha AS CHARACTER INIT SPACE(50)
       DATA lAdministrador AS LOGICAL INIT .F.
       DATA cOBS AS CHARACTER INIT Memo()
       
    	METHOD New() CONSTRUCTOR
    
    ENDCLASS
    
    METHOD New() CLASS Usuario
    		 ::Super():New()
    return Self

    Exemplo da Instancia 
     

    Function ManterTabela()
    
    			MsgMeter( { | oMeter, oText, oDlg, lEnd | ;
                 ManterTabela_Meter( oMeter, oText, oDlg, @lEnd ) },;
                 "Manutenção de Tabelas", "Aguarde um momento..." )
    
    
    Function ManterTabela_Meter(oMeter, oText, oDlg, lEnd)
    			Local aTabelas:={},oTabela:=NIL,nTabela:=1
    			*
    			oUsuario := Usuario():New()
    			oControleUsuario:= Tabela():New(oUsuario)
    			oControleUsuario:AdicionarIndice("cNome","NOME")
    			aadd(aTabelas,oControleUsuario)
    			*
    			oMeter:SetTotal(len(aTabelas))
    			*
    			For each oTabela in aTabelas
    				oTabela:ManterTabela()
    		      oTabela:ManterIndice()
    				oMeter:Set(nTabela++)
    			Next
    			

     

  13. Pessoa estou desenvolvendo umas classes para agilizar alguns novos projetos e durante o meu processo da graduação vi que alguns Frameworks agilizam bastante certas rotinas do sistema, como procurei algo semelhante no fivewin e não tive muito sucesso, decidi desenvolver por conta própria baseado no funcionamento que já tive dos projetos da faculdade e feitos em outras linguagens.

    Inicialmente desenvolvi para o conceito de ORM ( ORM (Object Relational Mapper) é uma técnica de mapeamento objeto relacional que permite fazer uma relação dos objetos com os dados que os mesmos representam. http://www.devmedia.com.br/orm-object-relational-mapper/19056)
    Para quem não conhece algo do tipo resumidamente é você cria a classe e instancia ela em um controller ( outra classe responsável por fazer acesso ao BD, criar tabelas e índices, alem de inserir, altera, excluir, e pesquisar ) 

    Essa classe hoje está compatível com a SQLRDD e os BD que ela é compatível. Infelizmente alguns conceitos do ORM não permitem que seja usado com DBF. 

    e sobre a parte de CRUD View ( CRUD (acrónimo de Create, Read, Update e Delete na língua Inglesa) para as quatro operações básicas utilizadas em bases de dados relacionais (RDBMS) ou em interface para utilizadores para criação, consulta, atualização e destruição de dados. )
    É que pretendo desenvolver outra classe para criação de janelas padronizadas, nos novos projetos sempre encontro uma demanda maior no desenvolvimento dos cadastros básicos e de nível médio do programa pois sei que poderia ser padronizado. 

     

    Hoje para uso proprio estou investindo algum tempo nesses sub-projetos que hoje ja me trazem um bom retorno no tempo de desenvolvimento. 

    Gostaria de saber dos colegas o nível de interesse que tem sobre esse tipo de experiencia de programação. E se tinham interesse em conhecer essas metodologias no fivewin. 

     Alguns desses projetos podem ser usados separadamente. 

    A imagem em anexo é de uma adaptação a classe datarow para criar dialogs sem @ say e redefine 

     

       lSave := EDITVARS vcodise2,vnomese2,;
        vcodigru,vnomegru,;
        vcodisec,vnomesec,;
        vcodiloc,vnomeloc,;
        vcodifor,vnomefor,;
        talfa,trefe,tzera,tinsc,tocio;
        PROMPTS "Sub-Seção","say:"+cbitmaps+"lupa2.bmp" ,;
        "Sub-Grupo","say:"+cbitmaps+"lupa2.bmp" ,;
        "Seção","say:"+cbitmaps+"lupa2.bmp" ,;
        "Grupo","say:"+cbitmaps+"lupa2.bmp" ,;
        "Fornecedor","say:"+cbitmaps+"lupa2.bmp" ,;
        "Imprimir em ordem alfabética",;
        "Imprimir somente com referência",;
        "Imprimir sem estoque gerencial",;
        "Imprimir somente inconsistências",;
        "Imprimir somente desativados";
        PICTURES "@R 999999",nil,"@R 999999",nil,"@R 999999",nil,"@R 999999",nil,"@R 999999",nil ;
        VALIDS {|oGetBlock| EditVarsGetValid(oGetBlock,@ocodise2,@onomese2) .and. iif(!empty(vcodise2),checkse2(),.t.) },;
        {|oGetBlock| EditVarsGetValid(oGetBlock,@ocodise2,@onomese2) .and. Pesqse2(.t.) } ,;
        {|oGetBlock| EditVarsGetValid(oGetBlock,@ocodigru,@onomegru) .and. iif(!empty(vcodigru),checkgru(),.t.) },;
        {|oGetBlock| EditVarsGetValid(oGetBlock,@ocodigru,@onomegru) .and. Pesqgru(.t.) } ,;
        {|oGetBlock| EditVarsGetValid(oGetBlock,@ocodisec,@onomesec) .and. iif(!empty(vcodisec),checksec(),.t.) },;
        {|oGetBlock| EditVarsGetValid(oGetBlock,@ocodisec,@onomesec) .and. Pesqsec(.t.) } ,;
        {|oGetBlock| EditVarsGetValid(oGetBlock,@ocodiloc,@onomeloc) .and. iif(!empty(vcodiloc),checkloc(),.t.) },;
        {|oGetBlock| EditVarsGetValid(oGetBlock,@ocodiloc,@onomeloc) .and. Pesqloc(.t.) } ,;
        {|oGetBlock| EditVarsGetValid(oGetBlock,@ocodifor,@onomefor) .and. iif(!empty(vcodifor),checkfor(),.t.) },;
        {|oGetBlock| EditVarsGetValid(oGetBlock,@ocodifor,@onomefor) .and. Pesqfor(.t.) } ;
        TITLE "Digite os Codigos ou Deixe em Branco Para Selecionar Todos"
       *
    

    capturar1.jpg

     

  14.  

    Bom dia

    Tentei rodar o exemplo mas deu o erro abaixo:

    Error: Unresolved external '_hb_partdt' referenced from H:\FWH1608\LIB\FIVEHX.LIB|VALTOSTR

    Esse exemplo é para xHarbour ou Harbour? Se for para Harbour como passo para funcionar com xHarbour?

    Herberson Gontijo

    O exemplo é em xHarbour sim, foi compilada com 
    xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603)
    Copyright 1999-2015, http://www.xharbour.org http://www.harbour-project.org/
     

    As libs que tem nos meus projetos são essas
     

    echo FiveHx.lib FiveHC.lib + >> "b32.bc"
     echo rtl.lib +       >> "b32.bc"
     echo vm.lib +        >> "b32.bc"
     echo gtgui.lib  +  >> "b32.bc"
     echo lang.lib +      >> "b32.bc"
     echo macro.lib +     >> "b32.bc"
     echo rdd.lib +       >> "b32.bc"
     echo codepage.lib +  >> "b32.bc"
     echo dbfntx.lib +    >> "b32.bc"
     echo dbfcdx.lib +    >> "b32.bc"
     echo dbffpt.lib +    >> "b32.bc"
     echo hbsix.lib    +  >> "b32.bc"
     echo common.lib +    >> "b32.bc"
     echo pp.lib +        >> "b32.bc"
     echo ct.lib +        >> "b32.bc"
     echo lang.lib +        >> "b32.bc"
     echo pcrepos.lib +        >> "b32.bc"
     echo png.lib +        >> "b32.bc"
     echo tip.lib +        >> "b32.bc"
     echo zlib.lib +        >> "b32.bc"
     echo hbzip.lib +        >> "b32.bc"
     echo cw32.lib +      >> "b32.bc"
     echo import32.lib +  >> "b32.bc"
     echo nddeapi.lib + >> "b32.bc"
     echo iphlpapi.lib + >> "b32.bc"
     echo rasapi32.lib + >> "b32.bc"
     echo shell32.lib + >> "b32.bc"
     

     

  15. Ola, geralmente uso exportação no meus reports essas propriedades:

        FrPrn:SetProperty("PDFExport"        , "Title"        , "" )
        FrPrn:SetProperty("PDFExport"        , "Author"        , "" )
        FrPrn:SetProperty("PDFExport"        , "Subject"        , "" )
        FrPrn:SetProperty("PDFExport"        , "Keywords"    , "" )
        FrPrn:SetProperty("PDFExport"        , "Creator"        , "" )
        FrPrn:SetProperty("PDFExport"        , "Producer"    , "" )
        FrPrn:SetProperty("PDFExport"        , "EmbeddedFonts"    , .T. ) // essa ultima é responsavel por "imbutir a fonte no pdf"

  16. Bem a um ano tive uma boa experiencia de migração para o MySQL usando o SQLRDD. Não tenho nada contra o dBase, foi o primeiro que aprendi, entretanto conheço algumas linguagens a mais e alguns frameworks comerciais que ja faz o que o CLIPPER fazia a muito tempo, por exemplo: para quem trata com java para web e uso os novos padroes de projeto como dados relacionados dentro de uma classe ele automaticamente gera do DB e faz a cada de persistencia onde voce chama os comando dos bancos e as alteraçoes no objeto nao obstante temos um exemplo classico no clipper :
    select cliente // no java eles chamam isso de camada de persistencia

    append blank // no java eles chamam isso de camada de persistencia

    replace nome with vnome

    replace idade with 19

    commit // no java eles chamam isso de camada de persistencia

    Nos novos Frameworks seria
    DBConnection.Insert() // classe da camada de persistencia
    oCliente.setNome(tTextFieldNome.getText()) // o proprio framework faz a tradução da atribuição e sabe q o objeto oCliente é um Cliente do DB

    oCliente.setIdade(tTextFieldIdade.getText())

    DBConnection.commit() // classe da camada de persistencia

    Então colegas aliados ao que hoje no java é novidade o abençoado do Nosso Fivewin Ja nasceu assim mas como o nome carrega muita coisa não temos esse credito todo.

    No que tange aos beneficios do MySQL acredito que é preciso conhecer BEEEEEEEEMMMM a linguagem para banco que tem umm Poder incoparevel com DBF gaste um tempo no Site da Oracle e veja o tanto de recursos que voce pode ter com essa ferramente, e no trivial tambem da para ser adptado, somente é preciso gastar tempo e não ter medo da mudança. Recomendo que migrem :)

×
×
  • Create New...