elchs / LetoDBf

LetoDB fork - database server with RDD for Harbour client
18 stars 12 forks source link

SET DEFAULT TO don´t work with Letodbf? #30

Open Numerabilis opened 1 year ago

Numerabilis commented 1 year ago

Hi, Elchs

I use SET DEFAULT TO point my databases so instead I set to localhost but the command USE is not working. Example:

xPath := "//127.0.0.1:2812/"
SET DEFAULT TO (xPATH)
leto_Connect( xPath, , , 6000, 100)
USE CADASTRO ALIAS CAD SHARED New
SET INDEX TO ("CADASTRO"+INDEXEXT())

This should work but in the example above Leto can´t find the database. So I made this test below that works:

xPath := "//127.0.0.1:2812/"
SET DEFAULT TO (xPATH)
leto_Connect( xPath, , , 6000, 100)
USE (xPATH+"CADASTRO") ALIAS CAD SHARED New
SET INDEX TO (xPATH+"CADASTRO"+INDEXEXT())

The problem is SET DEFAULT TO is not working as expected and I would have to change several lines of my program to work out the problem. Why SET DEFAULT TO is not working with Leto? Am I missing something? Is there something that could be done?

Numerabilis commented 1 year ago

I found out there is a function to work around SET DEFAULT TO: LETO_SETPATH(xPATH) Now it´s working! Working example:

xPath := "//127.0.0.1:2812/"
SET DEFAULT TO (xPATH)
LETO_SETPATH(xPATH)
leto_Connect( xPath, , , 6000, 100)
USE CADASTRO ALIAS CAD SHARED New
SET INDEX TO ("CADASTRO"+INDEXEXT())
Numerabilis commented 1 year ago

Problem solved with function LETO_SETPATH()

elchs commented 1 year ago

Hi Numerabilis,

Working example: NO!

xPath := "//127.0.0.1:2812/" LETO_IP_ADDRESS = "//127.0.0.1:2812/"

SET DEFAULT TO SubDir This should be set, if anyway needed !, beforehand the Leto_Connect()

LETO_SETPATH( "OneDir;TwoDir;" ) This can be applied also afterwards a Leto_Connect()

Check Clpper/Harbour documentation about SET PATH TO // SET DEFAULT TO The root directory at server is detemined with the server config file "letodb.ini": DataPath and above settings are then relative to that root directory. IF 'DataPath' in letodb.ini is "D:\MyData", then after your settings the files would be searched in directory*: D:\MyData\127.0.0.1...." I'm sure this directory does not exist ;-) After all is correct set up, you do NOT need to add any path for your dbf / index files:

leto_Connect( LETO_IP_ADDRESS ) USE CADASTRO ALIAS CAD SHARED New SET INDEX TO ("CADASTRO"+INDEXEXT())

Numerabilis commented 1 year ago

letodb.ini:

Port = 2812
DataPath = C:\DATABASE\

The databases of my aplication is at C:\DATABASE\CONTROLI In my aplication:

    // servidor LETODBf
    #include "rddleto.ch"  // defines do RDD
    #include "dbinfo.ch"   // Header file for the RDD API Index OrderInfo and DBInfo support
    #include "leto_std.ch" // traduz os comandos para o LETO
    #define __LETO_TRANSLATE_FILE_ALL // traduz todas as funções para o LETO
    #include "letofile.ch" // traduz as funções para o LETO
    REQUEST LETO
    REQUEST RDDLETO
    REQUEST RDDInfo

        LETO_IP_ADDRESS := "//127.0.0.1:2812/"
        cDATABASE := "CONTROLI/"
    SET DEFAULT TO (cDATABASE)

    IF leto_Connect( LETO_IP_ADDRESS ) == -1
        ALERT("Nenhum LetoDBF Server encontrado - Erro: " + leto_Connect_Err( .T. ) )
        QUIT
    ENDIF
        LETO_SETPATH(cDATABASE) // actually no effect

        ? FILE("UNIDADE.DBF") // RETURNs .F.
        ? FILE("CONTROLI/UNIDADE.DBF") // RETURNs .T.

SET DEFAULT is not working nether LETO_SETPATH(). It only finds databases if in letodb.ini I put DATAPATH = C:\DATABASE\CONTROLI This way it would run only one aplication because if I have more aplications it would have to share the same folder... what a mess!