Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Numerabilis opened this issue Jun 11, 2023 · 4 comments
Open

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

Numerabilis opened this issue Jun 11, 2023 · 4 comments

Comments

@Numerabilis
Copy link

Numerabilis commented Jun 11, 2023

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
Copy link
Author

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
Copy link
Author

Problem solved with function LETO_SETPATH()

@elchs
Copy link
Owner

elchs commented Jun 13, 2023

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 Cl*pper/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
Copy link
Author

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!

@Numerabilis Numerabilis reopened this Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants