GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Pathpart and filepart


#1

The following test code produces unexpected results in some circumstances.

function OnClick(clickData)
{
	var srcpath = clickData.func.sourcetab.path;
	DOpus.output("Path = "+String(srcpath));
	DOpus.output("Path Part = "+srcpath.pathpart);
	DOpus.output("File Part = "+srcpath.filepart);
}

If the source tab is C:\test then output is as expected.

Path = C:\test
Path Part = C:\
File Part = test

If the source tab is C:\ then output is not as expected (by me).

Path = C:\
Path Part = C:\
File Part = C:\

If the source tab is coll://Find Results then output is as expected.

Path = coll://Find Results
Path Part = coll://
File Part = Find Results

If the source tab is coll:// then output is not as expected.

Path = Coll://
Path Part = Coll://
File Part = /

Path!.dcf (685 Bytes)


#2

Path.filepart isn't meaningful for a root path; you can use Path.test_root to test for a root.


#3

Yes, Path.test_root is certainly a fail safe up front test, but returning an empty string for Path.filepart would be more intuitive and consistent, in my opinion, than returning C:\ for a drive root or \ for a coll:\\ root.


#5
function IntuitiveFilePart(path)
{
	return (!path.test_root) ? path.filepart : "";
}

:slight_smile:


#6

12.12.1 beta changes how FilePart behaves with root paths.

(Jon made the change, I'm just updating the thread.)