version 6.0
Data file {(segment)} String
Parameter | Type | Description | |
segment | Number | Segment number | |
Function result | String | Long name of the data file for the database |
Description
The Data file command returns the long name of the data file or one data segment for the database with which you are currently working.
If you do not pass the segment parameter, it returns the long name of the data file or the first segment (if the database is segmented). If you pass the segment parameter, it returns the long name of the corresponding data segment. If you pass a segment number greater than the number of data segments, it returns an empty string.
On Windows
If, for example, you are working with the database MyCDs located at \DOCS\MyCDs on the volume G, a call to Data file returns G:\DOCS\MyCDs\MyCDs.4DD (provided that you accepted the default location and name proposed by 4D when you created the database).
On Macintosh
If, for example, you are working with the database located in the folder Documents:MyCDs: on the disk Macintosh HD, a call to Data file returns Macintosh HD:Documents:MyCDs:MyCDs.data (provided that you accepted the default location and name proposed by 4D when you created the database).
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 long name. In addition, even though the database is segmented, the command returns an empty string for the other data segments. If you need (for adminstrative purposes) to display a list of the data segments on a 4D Client station, 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.
Example
The following code goes through the data segments of a database.
If (Application type#4D Client) $vlDataSegNum:=0 Repeat $vlDataSegNum:=$vlDataSegNum+1 $vsDataSegName:=Data file($vlDataSegNum) If ($vsDataSegName#"") ALERT ("Data segment "+String($vlDataSegNum)+":"+Char(34)+ $vsDataSegName+Char(34)+".") End if Until ($vsDataSegName="") ALERT("There is/are "+String($vlDataSegNum-1)+"data segment(s).") End if
See Also
Application file, DATA SEGMENT LIST, Structure file.