KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: A Utility method that returns the server folder paths from the client
PRODUCT: 4D | VERSION: 12.3 | PLATFORM: Mac & Win
Published On: February 8, 2012

The Server's folder path information may be useful when building complex routines that depend on paths that accurately represent the location of files relative to the server. Here is a utility method that can be used from a 4D Client (remote) for obtaining the different folder paths of the 4D Server:

C_TEXT($0)
C_TEXT($1;$type)
C_LONGINT($2;$folder)

If (Count parameters=2)
 $type:=$1
 $folder:=$2
 Case of
 :($type="4D")
  $0:=Get 4D folder($folder)
 Else
  $0:=System folder($folder)
 End case
End if


The command accepts two parameters;
  • $1 := 'System' or '4D' (C_TEXT)
    This parameter corresponds to either the 'Get 4D Folder' or 'System Folder' commands. The method defaults to System if 4D is not specified.

  • $2 := Folder constant (C_LONGINT)
    This is the parameter that would be passed to the command executed on the server.

The project method is executed on the Server via the 'Execute on Server' method property (see image below) and the result is returned to the client in $0 (C_TEXT).





Here is an example of calling the method for a 4D Folder:

C_TEXT($test)
$test:=UTIL_getServerFolder ("4D";Current Resources folder)

The above snippet would set the $test variable on the client to the return value of the Get 4D Folder command with the 'Current Resources Folder' from the Server.



Here is an example of calling the method for a System Folder:

C_TEXT($test)
$test:=UTIL_getServerFolder ("System";Desktop)

The above snippet would set the $test variable on the client to the return value of the System Folder command with the 'Desktop' from the Server.