{filepath$} population

I created a button to run the following command:

 "C:\Program Files (x86)\Misc\DisplayProgramUsage.exe" -Path={filepath$}

but it only runs if I have selected something. There are times when I want to run it regardless of whether I've made a selection. It appears that the command won't run unless {filepath$} is populated. I'm sure there is a work around for
this, hopefully without writing a script since I'm not very good at that.

Bob Gregory

The $ at the end of {filepath$} changes it from "want filepath" to "need filepath". (See Codes for passing filenames.)

Remove the $ to make it optional:

"C:\Program Files (x86)\Misc\DisplayProgramUsage.exe" -Path={filepath}

However, if no file is selected, that will run this:

"C:\Program Files (x86)\Misc\DisplayProgramUsage.exe" -Path=

I doubt that is what you want.

You could have two buttons next to each other, one for each case, where only one or the other will be visible depending on whether anything is selected:

@hidenosel:! "C:\Program Files (x86)\Misc\DisplayProgramUsage.exe"

@hidenosel "C:\Program Files (x86)\Misc\DisplayProgramUsage.exe" -Path={filepath}

Or you could have a single button that runs a script:


[code]function OnClick(clickData)
var cmd = clickData.func.command;

if (clickData.func.sourcetab.selected.count == 0)
	cmd.RunCommand("\"C:\\Program Files (x86)\\Misc\\DisplayProgramUsage.exe\"");
	cmd.RunCommand("\"C:\\Program Files (x86)\\Misc\\DisplayProgramUsage.exe\" -Path={filepath}");


Thank you very much Leo. Actually I do want "C:\Program Files (x86)\Misc\DisplayProgramUsage.exe" -Path={filepath}"
because the program that receives this ignores the statement if -Path= is not populated. I did remove the $ and it works
as expected. Again thank you and I will keep your other suggestions just in case.

Bob Gregory