KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Where Does My Data Live?
PRODUCT: 4D | VERSION: 6.5 | PLATFORM: Mac & Win
Published On: July 20, 2001
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Some databases are set up for the same structure to use several different data files located in separate folders. For instance, an accounts data file could be created for each year and each data file located in folders "1998", "1999", "2000" and so on. Once the database has been launched, there is a way to determine where the data file is located to make sure the proper data file is being used. The command 'Data file' will return a string value that gives the long name of the data file (see the 4D Language Reference in the 4D Environment chapter). In other words, the path to the data file is included in the name string.

On Windows:

If, for example, you are working with the database MyDatabase located at \DOCS\MyDatabase1 on the volume G, a call to Data file returns G:\DOCS\MyDatabase1\MyDatabase.4DD.

On Mac OS:

If, for example, you are working with the database located in the folder Documents:MyDatabase1: on the disk Macintosh HD, a call to Data file returns Macintosh HD:Documents:MyDatabase1:MyDatabase.data.

The designer could put a button on a form with a method behind such as:

Case of
 :(Form event=on clicked)
  $path:=Data file
  ALERT("The path to the data file is "+$path)
End case

Clicking that button would then display an alert with the path to the data file.

WARNING: If you call this command while running 4D Client, only the name of the data file or the first data segment is returned, not the entire pathname. If the database is segmented, the command returns an empty string for the other data segments. If you need (for administrative purposes) to display on a 4D Client station a list of the data segments, use a Stored Procedure to build the data segment list and store it in a variable on the server machine, then get the contents of this variable using the GET PROCESS VARIABLE command. For additional information on how to use the Data file command, check the following location: http://www.4d.com/ACIDOC/CMU/CMU00490.HTM