Get 4D folder

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 2004.5 (Modified)


Get 4D folder {(folder)} String

ParameterTypeDescription
folderLongintFolder type (if omitted = active 4D folder)
Function resultStringPathname to 4D Folder

Description

The Get 4D folder command returns the pathname to the active 4D folder of the current application, or to the 4D environment folder specified by the folder parameter, if passed. This command allows you to get the actual pathname of the folders used by the 4D application. By using this command, you ensure that your code will work on any platform running any localized system.

In folder, you can pass one of the following constants, which are located in the "4D Environment" theme:

ConstantTypeValue
Active 4D FolderLongint0 (default)
Licenses FolderLongint1
Extras FolderLongint2
4D Client Database FolderLongint3
Database FolderLongint4
Database Folder Unix SyntaxLongint5

You will find below a description of each folder:

Preliminary notes about folder names:

{Disk} is the disk where the system is installed.

The word User represents the name of the user that opened the session.

Active 4D Folder

The 4D environment uses the 4D folder to store the following information:

User registration files

Preferences files used by the 4D environment applications, tools, and utility programs

TCP/IP Network protocol option file

Local database folders created by 4D Client for storing elements downloaded from 4D Server (resources, plug-ins, Extras folder, etc.).

The 4D folder is created by default at the following location:

On Windows: {Disk}:\Documents and Settings\All Users\Application Data\4D

On Mac OS: {Disk}:Library:Application Support:4D

With the 4D Client application or if the All Users folder is locked, the active 4D folder is created at the following location:

Under Windows: {Disk}:\Documents and Settings\User\Application Data\4D

Under Mac OS: {Disk}:Users:User:Library:Application Support:4D

Licenses Folder

Folder containing the Licenses files of the machine.

The Licenses folder is placed at the following location:

On Windows: {Disk}:\Documents and Settings\All Users\Application Data\

4D\Licenses

On Mac OS : {Disk}:Library:Application Support:4D:Licenses

Extras Folder

Folder with customized contents downloaded to each 4D Client machine.

You use this folder for transferring custom items from the server to the client machines (resources file, text documents, XML preferences files, etc.). The original hierarchy of the folder is reconstructed on each client machine.

4D Server automatically manages the modifications made to this folder and only transfers what is necessary. Moreover, the contents of the folder is compressed in order to optimize network copying time.

On the 4D Server or 4th Dimension single-user side, the original Extras folder should be placed next to the database structure file.

On the 4D Client side, the Extras folder is downloaded to the following location on each client machine, i.e.:

On Windows: {Disk}:\Documents and Settings\Current user\Application Data\4D\DatabaseName_Address\Extras

On Mac OS: {Disk}:Users:User:Library:Application Support:4D:DatabaseName_Address:Extras

4D Client Database Folder (Client machines)

4D database folder created on each 4D Client machine for storing files and folders related to the database (resources, plug-ins, Extras folder, etc.).

The 4D Client Database Folder is placed at the following location on each client machine:

On Windows: {Disk}:\Documents and Settings\Current user\Application Data\4D\DatabaseName_Address

On Mac OS: {Disk}:Users:User:Library:Application Support:4D:DatabaseName_Address:

Database Folder

Folder containing the database structure file. The pathname is expressed using the standard syntax of the current platform.

With the 4D Client application, this constant is strictly equivalent to the previous 4D Client Database Folder constant: the command returns the pathname of the folder created locally.

Database Folder Unix Syntax

Folder containing the database structure file. This constant designates the same folder as the previous one but the pathname returned is expressed using the Unix syntax (Posix), of the type /Users/... This syntax is mainly used when you use the LAUNCH EXTERNAL PROCESS command under Mac OS or the SET CGI EXECUTABLE command.

Examples

1. During the startup of a single-user database, you want to load (or create) your own settings in a file located in the 4D folder. To do so, in the On Startup Database Method, you can write code similar to this:

   MAP FILE TYPES("PREF";"PRF";"Preferences file")
      ` Map PREF Mac OS file type to .PRF Windows file extension
   $vsPrefDocName:=Get 4D folder+"MyPrefs"   ` Build pathname to the Preferences file
      ` Check if the file exists
   If (Test path name($vsPrefDocName+(".PRF"*Num(On Windows)))#Is a document) 
      $vtPrefDocRef:=Create document($vsPrefDocName;"PREF") ` If not, create it
   Else
      $vtPrefDocRef:=Open document($vsPrefDocName;"PREF") ` If so, open it
   End if
   If (OK=1)
         ` Process document contents
      CLOSE DOCUMENT($vtPrefDocRef)
   Else
         ` Handle error
   End if

2. This example illustrates the use of the Database Folder Unix Syntax constant under Mac OS to list the contents of the database folder:

   $posixpath:="\""+Get 4D folder(Database Folder Unix Syntax)+"\""
   $myfolder:="ls -l "+$posixpath
   $in:=""
   $out:=""
   $err:=""
   LAUNCH EXTERNAL PROCESS($myfolder;$in;$out;$err)

Note: Under Mac OS, it is necessary to put pathnames in quotes when they contain the names of files or folders with spaces in them. The escape sequence "\" can be used to insert the quotation mark character into the string. You can also use the statement Char(Double quote).


See Also

System folder, Temporary folder, Test path name.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next