Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.0   6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3    Statistic  

Path.AddPathComponent

Adds a new path component.

Component: Path
Version: 6.0
Mac OS X: Yes
Windows: Yes
Server: Yes
FileMaker Cloud: Yes

MBS( "Path.AddPathComponent"; Path; Component )

Parameters

Parameter Description Example value
Path The native file path. "/Users/cs/Desktop"
Component The new path component. "Hello"

Result

Returns path or error.

Description

Adds a new path component.
The path provided as parameter does not need to end with a slash or backslash.

This function requires a native path. Use Path.FileMakerPathToNativePath to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use FileDialog functions.
For Server be aware that server has limited permissions and may not be able to access all files on a computer.

Examples

Adds a path component to a path:

MBS( "Path.AddPathComponent"; "/Users/cs/Desktop"; "Hello" )

Adds a file name:

MBS( "Path.AddPathComponent"; "/Users/cs/Desktop/"; "test.txt" )

Adds a file path on Windows:

MBS( "Path.AddPathComponent"; "c:\\Test"; "test.txt" )

Get file name from container and add to folder path:

Set Variable [$name; Value:GetAsText ( Container Batch Export::Test1 )]
Set Variable [$name; Value:GetValue($name; 1)]
Set Variable [$name; Value:MBS( "Path.LastPathComponent"; $name )]
Set Variable [$dpath; Value:MBS( "Path.AddPathComponent"; $FolderPath; $name )]

Create folder on Desktop:

Set Variable [$folder; Value:MBS( "Folders.UserDesktop" )]
If [IsEmpty(Container Export::Name)]
    Set Field [Container Export::Name; "Record " & Get(RecordID)]
End If
Set Variable [$path; Value:MBS( "Path.AddPathComponent"; $folder; Container Export::Name )]
Set Variable [$r; Value:MBS("Files.CreateDirectory"; $path)]

Write container to temp file and launch:

# get temp folder
Set Variable [$TempFolder; Value:MBS( "Folders.SystemTemporary" )]
# and file name from container
Set Variable [$name; Value:MBS( "Path.LastPathComponent"; test::myContainer )]
# add name to folder path
Set Variable [$TempPath; Value:MBS( "Path.AddPathComponent"; $TempFolder; $name )]
# now write temp file
Set Variable [$r; Value:MBS( "Files.WriteFile"; test::myContainer; $TempPath)]
# and launch file
Set Variable [$r; Value:MBS( "Files.LaunchFile"; $TempPath)]

See also

Example Databases


PKey.Type   -   Path.FileMakerPathToNativePath

Feedback: Report problem or ask question.




Links
MBS Xojo blog