paiva_dbdc,
Foi justamente o que eu fiz: No meu arquivo de configuração (.ini) eu seto se vou usar o leto ou nao. Não quero usar o leto nesse cliente? simples, seto a chave para "0" e pronto. Vou usar? seto para "1".
Os bug's conhecidos, pelo menos por mim, não mim impedem de usar o leto.
# include "rddleto.ch"
CriaArquivoIni()
aIni := HB_ReadIni('c:\JanioSys\JanioSys.ini')
aSecaoIni := aIni['Config']
Leto := aSecaoIni['Leto']
Servidor := aSecaoIni['Servidor']
Porta := aSecaoIni['Porta']
PathServ := "//" + Servidor + ":" + Porta + "/"
cDrive := If( Leto = "1", "LETO", "DBFCDX" )
*
If Leto != "1" .and. Leto != "0"
MSG("HA UM ERRO DE CONFIGURACAO NO ARQUIVO DE INICIALIZACAO - COMPONENTE letoDB")
Quit
Endif
Leto := IIf( Leto = "1", .t., .f. )
*
If Leto
leto_Disconnect()
nConect := leto_Connect( PathServ )
If nConect == -1
nRes := leto_Connect_Err()
If nRes == LETO_ERR_LOGIN
alert( "Falha ao Logar" )
ElseIf nRes == LETO_ERR_RECV
alert( "Error ao conectar" )
ElseIf nRes == LETO_ERR_SEND
alert( "Erro de envio" )
Else
alert( "Não connectado ao servidor: " + PathServ )
Endif
Quit
Endif
REQUEST LETO
RDDSETDEFAULT( "LETO" )
Else
REQUEST DBFCDX
RDDSETDEFAULT("DBFCDX")
Endif
*
// saber se tabela/ou arquivo existe (no servidor)
If MyFile("CFSCLI.DBF")
....
Endif
// abrir tabela
AbreDb( [A17EMP],[EMPRESA] )
// criar tabela
If !MyFile("A10GRP.dbf")
aCampos := {}
aAdd( aCampos , { "CODIGO" , "N" , 3 , 0 } )
aAdd( aCampos , { "DESCRI" , "C" , 30, 0 } )
aAdd( aCampos , { "SLDATU" , "N" , 15, 2 } )
aAdd( aCampos , { "FLGTIP" , "C" , 1 , 0 } )
MydbCreate( "A10GRP.DBF" , aCampos )
Endif
// apagar tabela
MyFERASE("A00PTO.DBF")
////
////
////
////
// funcoes
Function MyFErase( cArquivo )
Local lRet := .t.
If Leto
Leto_fErase( PathServ + cArquivo )
Else
fErase( cArquivo )
EndIf
Return lRet
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
Function MyFile( fArquivo )
Local lRet := .t.
If Leto
If Leto_File( PathServ + fArquivo )
Else
lRet := .f.
EndIf
Else
If hb_FileExists( fArquivo )
Else
lRet := .f.
EndIf
EndIf
Return lRet
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
Function MyDbCreate( oArquivo, Campos )
If Leto
dbCreate( PathServ + oArquivo, Campos, cDrive )
Else
dbCreate( oArquivo, Campos, cDrive )
EndIf
Return .t.
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
Function AbreDB( cArquivo, cAlias, lModo )
Local lRet := .t.
Local xArq := cArquivo
Local aTenta
lModo := IIf( lModo == nil , .t. , .f. )
cArquivo := IIf( At( ".", xArq ) > 0 , cArquivo, cArquivo + ".dbf" )
If Leto
If Leto_File( PathServ + cArquivo )
DbUseArea(.t.,'LETO', PathServ + cArquivo,cAlias,lModo )
Else
MSG( 'LetoDB Nao Foi Localizado: ' + PathServ + cArquivo )
lRet := .f.
EndIf
Else
DbUseArea(.t.,'DBFCDX',cArquivo,cAlias,lModo )
EndIf
If Neterr()
aTela := savescreen(9,5,15,75)
ALERTA('Tentando acessar arquivo ' + cArquivo + '! Aguarde...', 12)
aTenta = 5
Do While aTenta > 0
If Leto
DbUseArea(.t.,'LETO', PathServ + cArquivo,cAlias,lModo )
Else
DbUseArea(.t.,'DBFCDX',cArquivo,cAlias,lModo )
EndIf
If Neterr() = .f.
restscreen(9,5,15,75,aTela)
Return .t.
Endif
aTenta--
Inkey(1)
Enddo
restscreen(9,5,15,75,aTela)
MSG( "NAO FOI POSSIVEL ABRIR O ARQUIVO " + cArquivo )
lRet := .f.
Endif
Return lRet