KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility method that returns the path to the data (.4DD) file
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: February 24, 2012

When the data file is kept separate from the structure file is located, there is no 4D Contant analogous to the constant Database Folder for the 4D command Get 4D folder that will return the pathname to where the <DatabaseName>.4DD file is located, that being the absolute path minus file name.

The utility method listed below will return the file path to the .4DD file analogous to the path returned from the Get 4D folder (Database Folder).

If (True)
    If (False)
      Begin SQL
        /*
          Get_4DD_Folder

          Purpose: Return the path to folder containing the .4DD file

          $0 - Text string
        */

      End SQL
   End if
   C_TEXT($MethodName_T)
   $MethodName_T:=Current method name
     //=========== Declare Variables ===========
     //local_variable_declarations

   C_LONGINT($Ndx)
   C_TEXT($4DDPath_T)
End if
  //=========== Initialize and Setup ===========

$0:=""

  // There's no constant for command "Get 4D folder" that
  // returns the path to the data file
  // (
$4DDPath_T:=Data file
$Ndx:=Length($4DDPath_T)

  //=========== Method Actions ===========

  // Make sure there won't be a range check issue
  // (
If (($Ndx>0) & (Position(Folder separator;$4DDPath_T)>0))
     // )

     // Find the position of the last folder separator
     // (
   While ($4DDPath_T$Ndx≥#Folder separator)
      $Ndx:=$Ndx-1
   End while
     // )
End if
  // )

  //=========== Clean up and Exit ===========

If ($Ndx>0)
     // Strip off the name of the .4DD file leaving the folder path
     // (
   $0:=Substring($4DDPath_T;1;$Ndx)
     // )
End if