Chuck
December 7, 2025, 2:51pm
1
I have a button that displays the path name of the given tab.
@label:=" " + (Count(source)>2 ? Root(source) + "\..\" + FilePart(source) : source)
When running a search, the collection path created is a string like below
How might one change this to another name so that when a search is run, the resulting path name (alias maybe?) is something more useful like YYYY-MM-DD-HH-MM-SS_SearchCriteria
For example: 2025-12-07-08-30-21_Automobile
Jon
December 7, 2025, 7:40pm
2
Try using the DisplayName() function, it should return a nicer string than the underlying path.
Chuck
December 7, 2025, 10:27pm
3
The difficulty for me is maintaining my chosen format if it's NOT a search result (i.e., "C:\...\Documents"
I've tried several combinations with no success. Here's an example:
@ifpath:InStr(sourcepath, "coll",0)
@label:=DisplayName(source,"r")
@ifpath:else
@label:=" " + (Count(source)>2 ? Root(source) + "\..\" + FilePart(source) : source)
What am I missing?
Jon
December 7, 2025, 10:29pm
4
You need to put the logic in the @label line, @ifpath won't work for that.
Something like:
@label:=InStr(sourcepath,"coll",0)?DisplayName(source,"r"):(" " + (Count(source)>2 ? Root(source) + "\..\" + FilePart(source) : source))
Chuck
December 7, 2025, 11:07pm
5
The button label no longer changes based on the path, it simply states "Path", the default label.
I have simplified this as much as possible to just test if it detects "coll" in the sourcepath:
@label:=InStr(sourcepath, "coll",0) ? DisplayName(source,"r")
Script log:
Error at line 1, position 7 [Button:Path - @label]
Unknown value (6): sourcepath
Jon
December 7, 2025, 11:10pm
6
It should be source not sourcepath I think.
Chuck
December 7, 2025, 11:20pm
7
@label:=InStr(source, "coll",0) ? DisplayName(source,"r")
Name for search does NOT change; keeps prior path name.
Script log:
Error at line 1, position 49 [Button: Path - @label]
Syntax error (5): )
InStr(source, "coll",0) ? DisplayName(source,"r")
Jon
December 7, 2025, 11:34pm
8
You've simplified it to the point of error. The syntax must be a ? b : c, a ? b is wrong.
Jon
December 7, 2025, 11:37pm
9
It might also be better to use PathType() instead of InStr() to detect a collection.
Try something like:
PathType(source) == "coll" ? DisplayName(source, "r") : (" " + (Count(source)>2 ? Root(source) + "\..\" + FilePart(source) : source))
1 Like