/* * Programador: Wanderlei Cardoso de Oliveira * Modulo de impressão da Sweda */ #define DC_CALL_STD 0x0020 #define LF chr(13)+chr(10) memvar NrDocto, cNome, cEnder, vpUserDir, VRetorno, Abrelib, ECF ************************************************************************************************ FUNCTION Sweda(vComando) ************************************************************************************************ local iRetorno := 0, vLogCom := "" Local oErr, Servico := "" vRetorno := "" vArgumento := "" Arg := {} FLogEcf := "EcfSweda"+dtos(date())+".log" vComando := vComando + iif(Right(vComando,1)<>'|','|','') if at('|',vComando) > 0 vArgumento := right(vComando,len(vComando)-at('|',vComando) ) vComando := left(vComando,at("|",VComando)-1) Do while Len(vArgumento)>0 aadd(Arg, left(vArgumento,(at("|",vArgumento)-1)) ) vArgumento := right(vArgumento,len(vArgumento)-at("|",vArgumento) ) Enddo Endif vLogCom += 'Comando...: '+vComando+Space(15)+'Recebido em.: '+Time()+LF vLogCom += 'Argumento.: ' if len(Arg)>0 for y := 1 to Len(Arg) vLogCom += Arg[y]+'|' Next vLogCom += LF Else vLogCom += 'Sem Argumento'+LF Endif fwrite( FLogEcf, vLogCom ) VLogCom := '' Servico := '('+vComando+')' if vComando == 'B00' .or. vComando = 'B03' //Abrir Cupom iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_AbreCupom", iif(len(Arg)>0,Arg[1],'') ) Elseif vComando == 'B01' .or. vComando == 'B01A' //:= Definir_Cupom_VenderItem if len(Arg)<>7 iRetorno := -2 return endi Cod := Arg[1] Descr := Arg[2] Aliq := Arg[3] if Aliq = 'IS' Aliq := 'II' elseif Aliq = 'NT' Aliq := 'NN' Endi Decimais := 2 iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_VendeItem", ; Cod, Descr, Aliq, 'F', Arg[4], Decimais, Arg[6], '$', Arg[7]) Elseif vComando == 'B04' //'Cupom_Cancelar Item'; OK iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_CancelaItemGenerico", Arg[1]) Elseif vComando=='B05A' .or. vComando=='B05B' .or. vComando=='B05C' .or. vComando=='B05D' //Definir_Cupom_Iniciar Fechamento TipoAD := iif(Val(Arg[1])>0,'A$','D$') iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_IniciaFechamentoCupom", TipoAd, if(vComando='B05A' .or. vComando='B05B',"$",'%'), Arg[1]) Elseif vComando=='B06' // Programacao_FormasPagto iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_ProgramaFormasPagamento", Arg[1]) Elseif vComando=='B12' iRetorno := DLLCall(abrelib, DC_CALL_STD, 'ECF_NomeiaTotalizadorNaoSujeitoIcms', Arg[1], Arg[2]) Elseif vComando=='B13' .or. vComando=='B14' iRetorno := DLLCall(abrelib, DC_CALL_STD, 'ECF_ProgramaAliquota', Arg[1], iif(vComando='B13', '0', '1') ) Elseif vComando=='B07' //Cupom_EfetuarFormaPagto iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_EfetuaFormaPagamento", Arg[1], Arg[2]) Elseif vComando=='B08' //Cupom_TerminarFechamento Mensag := '' for x := 1 to Len(Arg) Mensag += Arg[x]+Chr(13)+Chr(10) Next iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_TerminaFechamentoCupom", Mensag) Elseif vComando=='B09' //Programacao_HorarioVerao iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_ProgramaHorarioVerao") //Habilita/Desabilita Elseif vComando=='B11' //Cupom_Cancelar iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_CancelaCupom") Elseif vComando=='C00' //RelatorioFiscal_EmitirReducaoZ dia := Iif(Len(Arg)>=1,arg[1],'') Hs := Iif(Len(Arg)>=2,arg[2],'') iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_ReducaoZ", Dia, Hs ) elseif VComando == 'C01' iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_LeituraX" ) Elseif vComando=='C02A' .or. vComando=='C02B' .or. vComando=='C02C' .or. vComando=='C02D' .or. vComando=='C02E' //'Programacao_LinhasEntreCupons'; iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_LinhasEntreCupons", Arg[1] ) Elseif vComando=='C03A' .or. vComando=='C03E' .or. ; //RelatorioFiscal_EmitirLeituraMemoriaFiscalPorData vComando=='C03B' .or. vComando=='C03C' //RelatorioFiscal_EmitirLeituraMemoriaFiscalPorReducao DLLCall(abrelib, 32, "ECF_Registry_PathMFD",vpUserDir+"\Sintegra") if At(Right(vComando,1),'AE')>0 Arg[1] := Left(Arg[1],2)+'/'+SubStr(Arg[1],3,2)+'/'+Right(Arg[1],2) Arg[2] := Left(Arg[2],2)+'/'+SubStr(Arg[2],3,2)+'/'+Right(Arg[2],2) iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_LeituraMemoriaFiscalDataMFD", Arg[1], Arg[2], Upper(Arg[3]) ) Else iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_LeituraMemoriaFiscalReducaoMFD", Arg[1], Arg[2], Upper(Arg[3]) ) Endif Elseif vComando=='C03D' .or. vComando=='C03F' //RelatorioFiscal_EmitirLeituraMemoriaFiscalSerialPorReducao DLLCall(abrelib, 32, "ECF_Registry_PathMFD",vpUserDir+"\Sintegra") if right(vComando,1)='D' //por reducao iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_LeituraMemoriaFiscalSerialReducaoMFD", Arg[1], Arg[2], Upper(Arg[3]) ) Else Arg[1] := Left(Arg[1],2)+'/'+SubStr(Arg[1],3,2)+'/'+Right(Arg[1],2) Arg[2] := Left(Arg[2],2)+'/'+SubStr(Arg[2],3,2)+'/'+Right(Arg[2],2) iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_LeituraMemoriaFiscalSerialDataMFD", Arg[1], Arg[2], Upper(Arg[3]) ) Endif Elseif vComando=='D00' //RelatorioGerencial_Abrir iRetorno := DLLCall(abrelib, 32, "ECF_AbreRelatorioGerencial") Elseif vComando=='D01' //RelatorioGerencial_Fechar iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_FechaRelatorioGerencial") iRetorno := 1 Elseif vComando=='D02' //RelatorioGerencial_Emitir LinImp := 0 Texto := '' TImp := round(len(Arg[1])/40,0) for x = 1 to TImp if len(Arg[1])>40 Texto += space(4)+Left(Arg[1],40)+LF Arg[1] := Right(Arg[1],len(Arg[1])-40) Else Texto += Arg[1]+LF Arg[1] := '' Endif LinImp += 1 if LinImp >= 3 .or. Arg[1]='' .or. len(Arg[1])=0 iRetorno := DLLCall(abrelib, 32, "ECF_RelatorioGerencial", Texto) Texto := '' LinImp := 0 Endif Next Elseif vComando=='D03' //Comprovante_Abrir CCD-TEF ABRE("FPAGTO") if FPAGTO->( bof() ) .and. FPAGTO->( eof() ) if Arg[1] == "01" .or. Arg[1] == "02" Arg[1] := "A Vista" elseif Arg[1] == "03" Arg[1] := "Convenio" elseif Arg[1] == "04" Arg[1] := "Credito" elseif Arg[1] == "05" Arg[1] := "Cartao" elseif Arg[1] == "06" Arg[1] := "Cheque" elseif Arg[1] == "07" Arg[1] := "Trn-centre" elseif Arg[1] == "08" Arg[1] := "Subsidio" elseif Arg[1] == "09" Arg[1] := "FarmaciaPopular" elseif Arg[1] == "10" Arg[1] := "E-Pharma" elseif Arg[1] == "11" Arg[1] := "Vidalink" endif else if Arg[1] == "01" Arg[1] := "02" endif if FPAGTO->( dbseek(ECF+Arg[1]) ) .and. !empty(FPAGTO->NMFORMA) Arg[1] := FPAGTO->NMFORMA else if Arg[1] == "01" .or. Arg[1] == "02" Arg[1] := "A Vista" elseif Arg[1] == "03" Arg[1] := "Convenio" elseif Arg[1] == "04" Arg[1] := "Credito" elseif Arg[1] == "05" Arg[1] := "Cartao" elseif Arg[1] == "06" Arg[1] := "Cheque" elseif Arg[1] == "07" Arg[1] := "Trn-centre" elseif Arg[1] == "08" Arg[1] := "Subsidio" elseif Arg[1] == "09" Arg[1] := "FarmaciaPopular" elseif Arg[1] == "10" Arg[1] := "E-Pharma" elseif Arg[1] == "11" Arg[1] := "Vidalink" endif endif endif FPAGTO->( dbclosearea() ) if left(Right(Arg[3],3),1) = '.' Arg[3] = Left(Arg[3],len(Arg[3])-3)+','+Right(Arg[3],2) Endif iRetorno := DLLCall(abrelib, 32, "ECF_AbreComprovanteNaoFiscalVinculado", Arg[2], Arg[3]) Elseif vComando=='D04' //Comprovante_Emitir LinImp := 0 Texto := '' TImp := round(len(Arg[1])/40,0) for x = 1 to TImp if len(Arg[1])>40 Texto += space(4)+Left(Arg[1],40)+LF Arg[1] := Right(Arg[1],len(Arg[1])-40) Else Texto += Arg[1]+LF Arg[1] := '' Endif LinImp += 1 if LinImp >= 3 .or. len(Arg[1])=0 iRetorno := DLLCall(abrelib, 32, "ECF_UsaComprovanteNaoFiscalVinculado", Texto) Texto := '' LinImp := 0 Endif Next Elseif vComando=='D05' //Comprovante_Fechar iRetorno := DLLCall(abrelib, 32, "ECF_FechaComprovanteNaoFiscalVinculado") Elseif vComando=='D06' //Caixa_EfetuarSangria iRetorno := DLLCall(abrelib, 32, "ECF_Sangria", Arg[1] ) Elseif vComando=='D07' //Caixa - Suprimento iRetorno := DLLCall(abrelib, 32, "ECF_Suprimento", Arg[1], Arg[2] ) Elseif vComando=='D08' //CupomNFV_Cancelar; iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_EstornoNaoFiscalVinculadoMFD") if iRetorno = 1 iRetorno := DLLCall(abrelib, 32, "ECF_FechaComprovanteNaoFiscalVinculado") endif iRetorno := 1 //Sempre retorno 1, pois há momento em que não existe Vinculado/CNFV. ElseIf vComando = 'F00' iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_AcionaGaveta") Elseif vComando == 'G00' //Estado Impressora xEstado := VerificaEstadoSweda(.f.) vLogCom += 'Retorno...: '+xEstado+Space(15)+'Finalizado em.: '+Time()+LF+LF fwrite( FLogEcf, vLogCom ) vLogCom := '' Return(xEstado) iRetorno = 1 Elseif vComando=='G06' //ObterNumeroSerie Str_Info := Space(20) iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_NumeroSerieMFD", Str_Info) vRetorno := AllTrim(Str_Info) elseif vComando=='G12' //ObterNumeroUltimoCupom Str_Info := Space(6) iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_NumeroCupom", Str_Info) vRetorno := Str_Info Elseif vComando=='G29' //ObterDataAtual vD := Space(6) vH := Space(6) iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_DataHoraImpressora", vD, vH) vRetorno := Left(vD,4)+'20'+SubStr(vD,5,2)+vH Elseif vComando = 'S6A' //RelatorioTipo60Analitico DLLCall(abrelib, 32, "ECF_Registry_PathMFD",vpUserDir+"\Sintegra") iRetorno := DLLCall(abrelib, 32, "ECF_RelatorioTipo60AnaliticoMFD") if iRetorno = 1 vRetorno = vpUserDir + '\sintegra\retorno.txt' Endif Elseif vComando=='S6M' //RelatorioTipo60Mestre_Gerar DLLCall(abrelib, 32, "ECF_Registry_PathMFD",vpUserDir+"\Sintegra") iRetorno := DLLCall(abrelib, 32, "ECF_RelatorioTipo60Mestre") if iRetorno = 1 vRetorno = vpUserDir + '\sintegra\retorno.txt' Else PtAlertx('Algo está errado na geracao do Rel Tipo 60 Mestre') Endif Elseif vComando=='R10' //Comprovante_Recebimento Indice := Space(02) if Arg[1] = '10' iRetorno := DLLCall(abrelib, 32, "ECF_RetornaIndiceComprovanteNaoFiscal", "Recto Convenio", Indice) Elseif Arg[1] = '11' iRetorno := DLLCall(abrelib, 32, "ECF_RetornaIndiceComprovanteNaoFiscal", "Recto Credito", Indice) Endif Arg[1] := Iif(Indice<>Space(02), Indice, Arg[1]) if Arg[2] == "01" .or. Arg[1] == "02" Arg[2] := "Dinheiro" elseif Arg[2] == "03" Arg[2] := "Convenio" elseif Arg[2] == "04" Arg[2] := "Credito" elseif Arg[2] == "05" Arg[2] := "Cartao" elseif Arg[2] == "06" Arg[2] := "Cheque" elseif Arg[2] == "07" Arg[2] := "Trn-centre" elseif Arg[2] == "08" Arg[2] := "Subsidio" elseif Arg[2] == "09" Arg[2] := "FarmaciaPopular" elseif Arg[2] == "10" Arg[2] := "E-Pharma" elseif Arg[2] == "11" Arg[2] := "Vidalink" endif if left(Right(Arg[3],3),1) = '.' Arg[3] = Left(Arg[3],len(Arg[3])-3)+','+Right(Arg[3],2) Endif if left(Right(Arg[4],3),1) = '.' Arg[4] = Str(Val(Left(Arg[4],len(Arg[4])-3)))+','+Right(Arg[4],2) Endif iRetorno := DLLCall(abrelib, 32, "ECF_AbreRecebimentoNaoFiscalMFD", NrDocto, cNome, cEnder ) Arg[1] := '01' if iRetorno = 1 iRetorno := DLLCall(abrelib, 32, "ECF_EfetuaRecebimentoNaoFiscalMFD", Arg[01], Arg[3] ) if iRetorno = 1 iRetorno := DLLCall(abrelib, 32, "ECF_EfetuaFormaPagamentoDescricaoForma", Arg[2] , Arg[4], "..." ) //ECF_EfetuaFormaPagamentoNaoFiscal if iRetorno = 1 iRetorno := DLLCall(abrelib, 32, "ECF_FechaRecebimentoNaoFiscalMFD","...") if iRetorno <> 1 vRetorno := 'Problema Fechamento do comprovante' endif else vRetorno := 'Problema no Forma de Pagamento do comprovante' Endif Else vRetorno := 'Problema Efetuando Recebimento' Endif else vRetorno := 'Problema na abertura do comprovante' Endif Elseif vComando=='C03H' .or. vComando=='C03M' .or. vComando=='C03R' //ObterDataGravacao UltUsuario, Grav.SwBasico e MF Adicioanl DtUltUsuario := Space(19) DtSwBasico := Space(19) MfAdicional := Space(05) iRetorno := DLLCall(abrelib, 32, "ECF_DataHoraGravacaoUsuarioSWBasicoMFAdicional", DtUltUsuario, DtSwBasico, MfAdicional) if vComando = 'C03H' vRetorno := MfAdicional Elseif vComando = 'C03M' vRetorno := DtSwBasico Else vRetorno := DtUltUsuario Endif Elseif vComando=='C03I' .or. vComando=='C03J' .or. vComando=='C03K' //Obter Marca, Modelo e Tipo do ECF Marca := Space(15) Modelo := Space(20) Tipo := Space(07) iRetorno := DLLCall(abrelib, 32, "ECF_MarcaModeloTipoImpressoraMFD", Marca, Modelo, Tipo) if vComando = 'C03I' vRetorno := Tipo Elseif vComando = 'C03J' vRetorno := Marca Else vRetorno := Modelo Endif Elseif vComando=='C03L' //ObterVersaoSWBasico Str_Info := Space(06) iRetorno := DLLCall(abrelib, 32, "ECF_VersaoFirmwareMFD", Str_Info) vRetorno := Str_Info Elseif vComando=='C03N' //ObterNumeroCaixa Str_Info := Space(4) iRetorno := DLLCall(abrelib, 32, "ECF_NumeroCaixa", Str_Info) vRetorno := Str_Info Elseif vComando=='C03O' .or. vComando=='C03P' //Obter CNPJ e Inscr. Estadual vCnpj := Space(18) vInsc := Space(15) iRetorno := DLLCall(abrelib, 32, "ECF_CGC_IE", vCnpj, vInsc) if vComando = 'C03O' vRetorno := vCnpj Else vRetorno := vInsc Endif Elseif vComando=='C03Q' //Cliche Proprietario Str_Info := Space(420) iRetorno := DLLCall(abrelib, 32, "ECF_ClicheProprietario", Str_Info) vRetorno := Str_Info Elseif vComando=='C03S' //ObterNumeroUsuario Str_Info := Space(4) iRetorno := DLLCall(abrelib, 32, "ECF_NumeroSubstituicoesProprietario", Str_Info) vRetorno := Str_Info Elseif vComando=='C03T' //ObterGrandeTotal Str_Info := Space(18) iRetorno := DLLCall(abrelib, 32, "ECF_GrandeTotal", Str_Info) vRetorno := Str_Info Elseif vComando=='C03U' //ObterContadorCupomFiscal Str_Info := Space(6) iRetorno := DLLCall(abrelib, 32, "ECF_ContadorCupomFiscalMFD", Str_Info) vRetorno := Str_Info Elseif vComando=='C03V' //ObterContadorOperacaoNaoFiscal'; nao implementado no Integrador Str_Info := Space(6) iRetorno := DLLCall(abrelib, 32, "ECF_NumeroOperacoesNaoFiscais", Str_Info) vRetorno := Str_Info Elseif vComando=='C03X' //ObterContadorRelatorioGerencial Str_Info := Space(6) iRetorno := DLLCall(abrelib, 32, "ECF_ContadorRelatoriosGerenciaisMFD", Str_Info) vRetorno := Str_Info Elseif vComando=='C03W' //ObterContadorComprovanteCredito Str_Info := Space(4) iRetorno := DLLCall(abrelib, 32, "ECF_ContadorComprovantesCreditoMFD", Str_Info) vRetorno := Str_Info Elseif vComando=='C03Y' //ObterContadorReducaoZ Str_Info := Space(1278) iRetorno := DLLCall(abrelib, 32, "ECF_DadosUltimaReducaoMFD", Str_Info) vRetorno := substr(Str_Info,9,4) Elseif vComando=='C03Z' //ObterCROReducaoZ Str_Info := Space(1278) iRetorno := DLLCall(abrelib, 32, "ECF_DadosUltimaReducaoMFD", Str_Info) vRetorno := substr(Str_Info,4,4) Elseif vComando=='C04A' //ObterDataMovimentoReducaoZ Str_Info := Space(1278) iRetorno := DLLCall(abrelib, 32, "ECF_DadosUltimaReducaoMFD", Str_Info) vRetorno := Right(Str_Info,6) vRetorno := left(Str_Info,2)+'/'+substr(Str_Info,3,2)+'/20'+Substr(Str_Info,5,2) Elseif vComando=='C04B' //ObterDataEmissaoReducaoZ vD := Space(6) vH := Space(6) iRetorno := DLLCall(abrelib, 32, "ECF_DataHoraReducao", vD, vH) vRetorno := left(vD,2)+'/'+substr(vD,3,2)+'/20'+Substr(vD,5,2)+' '+left(vH,2)+':'+substr(vH,3,2)+':'+Substr(vH,5,2) Elseif vComando=='C04C' //ObterDataUltimoDocumento Str_Info := Space(12) iRetorno := DLLCall(abrelib, 32, "ECF_DataHoraUltimoDocumentoMFD", Str_Info) vRetorno := left(Str_Info,2)+'/'+substr(Str_Info,3,2)+'/20'+Substr(Str_Info,5,2)+' '+SubStr(Str_Info,7,2)+':'+substr(Str_Info,9,2)+':'+Substr(Str_Info,11,2) Elseif vComando=='C04D' //ObterReducaoZAutomatica ?'; Str_Info := Space(1278) iRetorno := DLLCall(abrelib, 32, "ECF_DadosUltimaReducaoMFD", Str_Info) VRetorno := Left(Str_Info,2) Elseif vComando=='C04E' .or. vComando = 'C04F' //ObterCOOInicialFinal vCooInicial := Space(06) vCooFinal := Space(06) iRetorno := DLLCall(abrelib, 32, "ECF_InicioFimCOOsMFD", vCooInicial, vCooFinal) if vComando = 'C04E' vRetorno := vCooInicial+vCooFinal Else vRetorno := vCooFinal Endif Elseif vComando=='C04G' //ObterVendaBruta Str_Info := Spac(18) iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_VendaBruta", Str_Info) vRetorno := Str_Info Elseif vComando=='C04H' //'ObterAliquotas'; Totalizadores parciais Str_Info := Spac(79) iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_RetornoAliquotas", Str_Info) vRetorno := Str_Info Elseif vComando=='C04I' //ObterCOOReducaoZ Str_Info := Spac(1278) iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_DadosUltimaReducaoMFD", Str_Info) vRetorno := SubStr(Str_Info,14,6) Elseif vComando=='C04J' //ObterDescontoIssqnHabilitado iRetorno := 1 vRetorno := '0' Elseif vComando=='C03G' //ArquivoFiscal_RealizarDownloadMFD - Espelho MFD _NomeOrigem := vpUserDir + '\sintegra\RETORNO.TXT' iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_DownloadMFD", _NomeOrigem, Arg[1], Arg[2], Arg[3], '0') Elseif vComando=='C04K' //Definir_ArquivoFiscal_FormatarDados ???? Arg[1] := vpUserDir + "\sintegra\"+Arg[1] Arg[2] := vpUserDir + "\sintegra\"+Arg[2] iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_FormatoDadosMFD", Arg[1], Arg[2], Arg[3], Arg[4], Arg[5], Arg[6], '0' ) Elseif vComando=='C04L' //Arquivo MFD // antes era gerado ArquivoFiscal_GerarRegistrosCAT52 vRetorno := vpUserDir + "\sintegra\"+Arg[1] iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_ReproduzirMemoriaFiscalMFD", '2', Arg[2], Arg[3], vRetorno, "") if iRetorno = -3 PtAlertx('Não há movimentos no dia.: '+Arg[2]+' a '+arg[3]) Endif Elseif vComando=='C04M' //ArquivoFiscal_GerarArquivoMFD _NomeOrigem := vpUserDir + '\sintegra\'+Arg[2] //RETORNO.TXT' iRetorno := DLLCall(abrelib, DC_CALL_STD, "ECF_DownloadMFD", _NomeOrigem, '2', Arg[6], Arg[7], '0') vRetorno := _NomeOrigem Elseif vComando=='C04N' //ObterDadosUltimaReducao'; Comparar com C04D Str_Info := Space(1278) iRetorno := DLLCall(abrelib, 32, "ECF_DadosUltimaReducaoMFD", Str_Info) vRetorno := Str_Info Elseif vComando =='R00' .or. vComando='R01' iRetorno := 1 Elseif vComando == "R05" DLLCall( abrelib, 32, "BlockInput", True ) Elseif vComando == "R06" DLLCall( abrelib, 32, "BlockInput", False ) Else vRetorno := 'Erro - Comando não reconhecido' iRetorno := -1 Endif If iRetorno <> 1 if iRetorno = 0 xRetorno := Erro_Ecf[24] Else xRetorno := ErroSweda( iRetorno ) Endif VRetorno := xRetorno+' - '+iif(vRetorno<>'',VRetorno,'')+' - '+Servico Else if len(vRetorno) <> 0 //POG Saber se vRetorno é vazio vRetorno := 'OK'+' - '+VRetorno+' - '+Servico Else vRetorno := 'OK' Endif Endif vRetorno := alltrim(strtran(strtran(strtran(strtran(strtran(strtran(vRetorno,"Ã","A"),"€","Ç"),"‡","ç"),"„","ã"),"¢","ó"),"”","õ")) vRetorno := StrTran(strtran(strtran(strtran(strtran(strtran(strtran(vRetorno,"ˆ","ê"),"£","ú"),"¡","í")," ","á"),"‚","é"),"“","o"),'Ç','C') vLogCom += 'Retorno...: '+vRetorno+Space(15)+'Finalizado em.: '+Time()+LF+LF fwrite( FLogEcf, vLogCom ) vLogCom := '' Return(vRetorno) ************************************************************************************************ Function VerificaEstadoSweda(RedZ) //Tentando Resolver tudo na chamada G00 ************************************************************************************************ //public vAck, vSt1, vSt2, vSt3 := 0 Local xEstado := '' memvar vAck, vSt1, vSt2, vSt3 xEstado := 'OK' xResp := DLLCall( abrelib, 32, "ECF_VerificaImpressoraLigada") if xResp <> 1 Return( Erro_Ecf[5] ) endif if RedZ Str_Info := Spac(01) xResp := DLLCall( abrelib, 32, "ECF_VerificaZPendente", Str_Info) if Str_Info = '1' .and. Redz = .t. Return(Erro_Ecf[25]) endif Endif vAck := Space(03) vSt1 := Space(03) vSt2 := Space(03) vSt3 := Space(03) xResp := DLLCall( abrelib, 32, "ECF_VerificaEstadoImpressoraStr", vAck, vSt1, vSt2, vSt3) if xResp <> 1 Return( Erro_Ecf[24] ) endif vAck := Val(vAck) vSt1 := Val(vSt1) vSt2 := Val(vSt2) vSt3 := Val(vSt3) if xResp = 1 if vAck = 21 PtAlertX('A Impressora retornou NAK. O programa será abortado!') Quit end if vAck = 6 if vSt1 >= 128 xEstado := Erro_Ecf[9] vSt1 -= 128 Elseif vSt1 >= 64 xEstado := Erro_Ecf[10] vSt1 -= 64 Elseif vSt1 >= 32 xEstado := Erro_Ecf[11] vSt1 -= 32 Elseif vSt1 >= 16 xEstado := Erro_Ecf[12] vSt1 -= 16 Elseif vSt1 >= 8 xEstado := Erro_Ecf[13] vSt1 -= 8 Elseif vSt1 >= 4 xEstado := Erro_Ecf[14] vSt1 -= 2 Elseif vSt1 >= 2 xEstado := Erro_Ecf[15] vSt1 -= 1 Elseif vSt1 >= 1 xEstado := Erro_Ecf[16] vSt1 -= 1 Endif if vSt2 >= 128 xEstado := Erro_Ecf[17] vSt2 -= 128 Elseif vSt2 >= 64 xEstado := Erro_Ecf[18] vSt2 -= 64 Elseif vSt2 >= 32 xEstado := Erro_Ecf[19] vSt2 -= 32 Elseif vSt2 >= 16 xEstado := Erro_Ecf[20] vSt2 -= 16 Elseif vSt2 >= 8 xEstado := Erro_Ecf[21] vSt2 -= 8 Elseif vSt2 >= 4 xEstado := Erro_Ecf[22] vSt2 -= 4 Elseif vSt2 >= 2 xEstado := Erro_Ecf[23] vSt2 -= 2 Elseif vSt2 >= 1 xEstado := Erro_Ecf[24] vSt2 -= 1 Endif Endif Endif Return(xEstado) ************************************************************************************************ Function ErroSweda(iRetorno) ************************************************************************************************ iAck := Space(02) iSt1 := Space(02) iSt2 := Space(02) iSt3 := Space(02) xEstado := 'ERRO' xResp := DLLCall( abrelib, 32, "ECF_RetornoImpressoraStr", iAck, iSt1, iSt2, iSt3) vAck := VAL(iAck) vSt1 := VAL(iSt1) vSt2 := VAL(iSt2) vSt3 := VAL(iSt3) vRetErro := Erro_Ecf[24] if vAck = 6 if vSt1 >= 128 xEstado := Erro_Ecf[9] vSt1 -= 128 Elseif vSt1 >= 64 xEstado := Erro_Ecf[10] vSt1 -= 64 Elseif vSt1 >= 32 xEstado := Erro_Ecf[11] vSt1 -= 32 Elseif vSt1 >= 16 xEstado := Erro_Ecf[12] vSt1 -= 16 Elseif vSt1 >= 8 xEstado := Erro_Ecf[13] vSt1 -= 8 Elseif vSt1 >= 4 xEstado := Erro_Ecf[14] vSt1 -= 2 Elseif vSt1 >= 2 xEstado := Erro_Ecf[15] vSt1 -= 1 Elseif vSt1 >= 1 xEstado := Erro_Ecf[16] vSt1 -= 1 Endif if vSt2 >= 128 xEstado := Erro_Ecf[17] vSt2 -= 128 Elseif vSt2 >= 64 xEstado := Erro_Ecf[18] vSt2 -= 64 Elseif vSt2 >= 32 xEstado := Erro_Ecf[19] vSt2 -= 32 Elseif vSt2 >= 16 xEstado := Erro_Ecf[20] vSt2 -= 16 Elseif vSt2 >= 8 xEstado := Erro_Ecf[21] vSt2 -= 8 Elseif vSt2 >= 4 xEstado := Erro_Ecf[22] vSt2 -= 4 Elseif vSt2 >= 2 xEstado := Erro_Ecf[23] vSt2 -= 2 Elseif vSt2 >= 1 xEstado := Erro_Ecf[24] vSt2 -= 1 Endif Endif Return(xEstado)