PHPBB_IMPORT_WARNING CODE_NEAR_LI
Okay, I wrote a script inside of an Opus button that meets 100% of OpelOpus's wishes (plus some of my own). I have tried to make the script more general in nature, so other users can modify it for use with different text editors (or for that matter any program that can either open or create a new file with the same set of parameters).
DISCLAIMER: If you are going to give my button a try, please test it first in a test folder and with files that you have backed up, before using it in a production area. I cannot possibly test with all possible programs, so your mileage may vary. You assume all risk for anything that happens. Post any issues to this thread for now.
Here are the current rules for the script inside the button:[ol][li] It will only work for the first selected file.
[/li]
[li] It will ignore selected folders.
[/li]
[li] I believe that if you click the button and an Opus lister is not open to a real file system folder, then any newly created file will end up in %Temp%.
[/li]
[li] When you select a file and click the button, the specified program will attempt to open the selected file, using the specified parameter string—you will not be prompted for anything.
The specified program path is currently:
D:\Appz\Notepad2\Notepad2.exe
The program path can easily be changed, but do not add any quotes (even if your path contains spaces) over what the script already has (and leave the existing quotes in-place).
The specified program parameter string is currently:
/q ''%%FilePath%%''
The program parameter string can easily be changed in the script, but you must always specify the file path as shown above—the word "FilePath" surrounded by two percent characters at each end, and usually surrounded by quotes to handle paths and names containing spaces (see note).
NOTE: Due to limitations in the script technology I used, you cannot use the double quote character in your parameter string, so use two single quote characters instead. The script will replace the two single quote characters shown above at each end of %%FilePath%% with one double quote character during execution.
[/li]
[li] When you do not select a file and click the button, you will be prompted for a new file name and these rules will then also apply:[ul][li] The input box will display a default base name (i.e. no file path and no file extension), which you may accept as-is by pressing enter or clicking OK.
[/li]
[li] You may also optionally include any of the following information in the inputbox:[ul][li] A fully-qualified file path. If you do not include a fully-qualified path, the Opus source folder is used.[/li]
[li] A File Extension. If you do not include a file extension, the script default file extension is used (currently .txt but easily modified).[/li]
[li] A Base Name. If you do not include a base name at all, or you click Cancel on the Input dialog, nothing should happen—you have canceled the function.[/li][/ul][/li][li] The script will assemble a fully qualified path for the file to be created and pass it to the specified program via the program parameter string.[/li][/ul][/li]
[li] And as a bonus feature, I ensure the specified program always opens with system focus (i.e. on top of Opus).[/li][/ol]
I do have future plans for this project, but I want to ensure there are no serious issues with what I have first. Plus, I need time to work on it more. The future plans include:[ol][li] Convert this into a User Command that: has a template, accepts parameters, and gets listed in the Opus command list in the Advanced Command Editor command list. It is almost there as it is, but I try to test my user command more.
[/li]
[li] Allow you to specify different program parameters for opening a selected file versus creating a new file (since many programs will most likely use different parameters for each action).
[/li]
[li] Allow you to open several selected files at once. However, you will still only be able to create one file if no files are selected.
[/li]
[li] Allow the command to work when no lister is open (possible defaulting new file creation in your Documents folder, or in folder specified by passed parameter.) This is to facilitate hotkey usage.
[/li]
[li] Allow the command to work correctly when Opus is running from USB.[/li][/ol]
Notepad2.dcf (10.9 KB)