Command File
NOTEFILE comes with a default Command File (NOTEFILE.CMD) containing sample code for commands to be executed by the Tools menu commands. This file must be present in the same directory as the NOTEFILE executable; otherwise it will not be invoked. A practical way to disable Command File usage is to remove the NOTEFILE.CMD file from the NOTEFILE directory. Please note that in Linux the file name is expected to be in lowercase.
The provided sample NOTEFILE.CMD file is a batch file for Windows and a Bash shell script for Linux. The sample file is for illustration purposes, and you can replace it with a script or program written in other languages, including C, Pascal, Go, Windows Script Host, PowerShell, Perl, Python, Ruby, Rexx, Node.js, PHP, or shells provided by Cygwin, as long as the executable file name remains unchanged and its behavior conforms to the specification below.
Functionality of the NOTEFILE.CMD executable
The NOTEFILE.CMD executable is invoked by NOTEFILE in two cases:
- During program startup or later when the
Reload Commands List command is selected, the
NOTEFILE.CMD executable will be called with no parameters. In this
case, it is expected to output lines in the format
num string. Here,numshould be an integer in the range 1 to 200 andstringshould be a non-emptycommand title
that will be added as a menu item to the Tools menu (only the first 50 characters of thestringwill be used). Only the first 25 lines matching the format described above will be processed and the Tools menu will be populated with them; the rest will be ignored. - When a
command from the Tools menu is executed,
the NOTEFILE.CMD executable will be called with the corresponding parameter
(the
numvalue obtained in the above step). If the value ofnumis greater than 100, NOTEFILE will also prompt the user for additional parameters and these will be passed as a second parameter. For such a call to occur, a card from the current file should be selected and displayed in thenotes information area
(see General Help On Personal Notes File). During the call, any selected text from the card will be sent to the executable via its standard input. After execution, anything written to standard output by the executable will be inserted at the insertion point or will replace any selected text.
Notes:
- It is better to test your modified NOTEFILE.CMD file from the command line before using it from NOTEFILE.
- During any call, NOTEFILE allows at most 4 seconds for the NOTEFILE.CMD executable to complete its execution. If your executable runs longer, output may be truncated. Also, if your executable does not read from standard input, you should not select any text in NOTEFILE before running the relevant command; in such cases, NOTEFILE may hang because the executable does not consume the input. You will have to locate and terminate the running NOTEFILE.CMD process or any of its child processes, so that NOTEFILE will resume.
- Please take care not to overwrite your customized
NOTEFILE.CMD file by the sample version included in the
.7zpackage of a new version of NOTEFILE during an upgrade process.