This section includes instructions and listings of some useful macros you may want to either add to your installation or for occasional use to run once in a while you can just copy them into a file (anywhere you want. WinPTE installation directory is a good place) and run them when you need them.
I have started detailing the WinPTE macro language with lots of apologies for some of its cryptic nature and limitations. But in the end until it is replaced with something else (most likely python 2.4), WinPTE macros are about the only way to add functionality to WinPTE. Perl is also available and fully functional. I started documenting the interface with WinPTE but since perl is not everyone's cup of tea, WinPTE macros are still the way to go for most people.
FYI: if you add any commands or macro definitions to the custom.pte file (In the WinPTE installation directory, you will need to create a new file since it is not part of the installation) then these commands and macros will be part of WinPTE's startup initialization. So add the text for any macros you find here to your custom.pte to make them part of your standard configuration.
| Macro | Programming Language |
Description | Included in Build # |
Last Updated |
|---|---|---|---|---|
ALL |
Adds incremental search capability to WinPTE. Typed characters are accumulated as the search pattern and the cursor moves to the next/previous occurrence of the found pattern in the file. (Enhanced version part of Release 3.00.445) | 3.00.445 |
March 6, 2005 |
|
ALL |
Adds a user defined command called 'run' that lets you run a script or a console application and captures its output to a text file. | - |
March 10, 2005 |
|
ALL |
Adds a user defined command called 'timeit' that executes an arbitrary WinPTE command and shows elapsed execution time in ms. Combined with the Run command will let you do rough timing and capture of output of scripts (not necessarily WinPTE scripts but any that you can run from the command processor). | - |
March 10, 2005 |
|
ProvideX |
Finds missing closing brace in files given in a list. Creates a list of files that are missing a closing brace } and the location of the opening brace that has no matching close brace. Use this check your existing source files for the missing brace error. | - |
March 7, 2005 |
Quick Review:
- To switch to the WinPTE command line use the ESCAPE key which toggles between text and command line. Most key shortcuts perform the same action in the command line as they do in the file. Where it makes sense to do so.
- To execute a command means to type the command text on the command line (copy/paste will work too) and hit ENTER.
- To run or load or execute a WinPTE macro file you need to activate the file (Open it or make it the current file if already open in WinPTE) and execute the:
macro
command. - You can also run, load or execute a macro file by executing the same macro command but passing the file path as an argument (optionally enclosed in double quotes, and not optional if the path has spaces) then the file does not need to be loaded into WinPTE.
- The macro command will search the current directory and the WinPTE installation directory for the file so if it is in the installation directory or the current working directory you can leave out the path altogether.
- There is no difference between run, load and execute. I use any of these terms to refer to the same operation. The macro command will execute all lines in the file as if they were WinPTE commands, sequentially from top to bottom until all are done or an error occurs. def and begindef/enddef are commands that define macros. So if the file contains nothing but macro definitions it will "load" them, all commands have immediate effect. Some drastic, scratch that. I am just kidding, except for the del command which takes a file argument and deletes that file from disk without any questions. So don't try it. For your safety del command does not accept wild-card characters so you can only blow away one file at a time.
- WinPTE defines most printable key combinations for Ctrl, Ctrl+Shift, Alt+, Shift+Alt+ keys. Specifically, the alphanumeric keys are so defined:
- Ctrl uses the c- prefix with the letter of the alpha key: i.e. c-a is Ctrl+A, c-z is Ctrl+Z
- Ctrl+Shift uses the cs- prefix, cs-a, cs-8
- Alt+ uses the a- prefix, a-q is Alt+Q
- Shift+Alt+ uses the sa- prefix, sa-s
- Non-printable keys such as the arrow keys are also defined and usually the key name matches the english name printed on the keyboard: up, a-up is Alt+Up, insert is the insert key, c-insert, etc.
- Some keys are printable but in WinPTE key names have to be valid identifiers and contain only alpha-numeric, underscores and - so a-back-quote is the WinPTE key name for the Alt+` key combination.
Displaying the WinPTE key name for any key that is definable in WinPTE
Until the GUI version of key assignments is complete you can use the following to quickly tell what the WinPTE name of the key with the alt, ctrl and shift decorations:
- Hit Shift+Alt+F10 (record a macro)
- Hit the key combination for which you want to see the name.
- The status bar will display: Recording keyName key. Hit keyName to stop or Shift+Alt+F10 to Cancel.
- Memorize the key name and hit Shift+Alt+F10 to cancel recording. You can also hit a few keys and then the same combination and the keys and you would have recorded a temporary macro. It will be gone when you restart WinPTE.
A much better alternative for getting the key name is to place the cursor where you want the key name inserted in the file and execute the following command on the command line:
ex [key name][clear next key]
You will be prompted to 'Type a character', the WinPTE name of the key you hit (with all the Alt, Ctrl and Shift modifiers) will be inserted at the current cursor location in the file. If you hit a key combination and the message is still displayed and nothing happens then this key combination is not definable in WinPTE (it does not see it). You can always interrupt the macro by hitting Ctrl+Break. At most one more function will be executed before the break request is honored.
The above is assigned to the Alt+0 key and you can simply hit Alt+0 and the next key will be inserted at the cursor position.
If you want to know:
- The [key name] function returns the character of the printable key or the WinPTE name if it is not a printable key combination.
- The [clear next key] function is needed otherwise the name of the key you hit will be inserted but the key will also be executed right after the command line macro is finished, since it is still in the execution queue until cleared or executed.
- The [key name] function will keep returning the same key name without prompting until the key is cleared from the queue or executed.
- If there is already a key in the type-ahead buffer no prompt will be displayed and that key will be used.