First and foremost, you must have a version of Toolbox at or above 9.0.0.5 to be able to run the action documented below.
This is because it relies on an internal variable that didn't previously exist, a new comparison operator and also a bugfix for user-created variables.
This is a long post. There's a lot of stuff that gets explained here: user-defined variables, decision making, looping through an indefinite number of files, swapping data into and out of variables with specific uses... I've tried to explain everything fairly clearly but if you're new to scripting, there's a lot to take in here.
The intention is to make a cheat sheet for actions that have been created but you might need reminding of, and to do it in such a way that you don't have to remember to update a separate cheat sheet -- because that's what I did, until recently, and kept forgetting to add new actions to the list.
So you need to make an actions group containing all the actions you want to be reminded of. The script assumes you've called this "My Useful Stuff" and that you've moved all the actions you want reminders for the triggers of into it. We're also assuming here that no actions in this group are missing a trigger.
A quick aside: In the Automation tab, you have a list of actions in the left pane, headed by a dropdown list of groups that have been set up as part of the original installation and possibly added to by you. In case you've never touched what's there, you're probably looking at (All) in the dropdown. If you right-click the dropdown, click on "+New..." you can create a new group. If you want to follow this tutorial without having to modify anything else, call it "My Useful Stuff".
You can move actions between groups by right-clicking the action's name, clicking Move and choosing the group you want to move the action to. For the purposes of this, you should move anything with a defined trigger you struggle to remember to the "My Useful Stuff" group or, if you prefer a different group name, modify the relevant line in the below script. I'll mention this again later.
One key bit of this arose from a discussion elsewhere, where our brilliant developer pointed out that the actions are held in individual files and that the first line of each file is its defined trigger. There are actions that are text expansions (where you type something that Toolbox reacts to -- I call these hotstrings) and actions that respond to keypresses, like control-F1, which I call hotkeys. Recognising hotstrings is easy: the first four characters of that first line are always "Text".
Hotkeys are harder, and only really possible if we can assume that if an action isn't a hotstring, it MUST be a hotkey. Which is why everything in the group we're looking at must have a trigger, because otherwise actions with no trigger will also be reported as a hotkey. (It's possible to code round that, but I've chosen to deal
with that by ensuring we populate the group carefully in the first place, for simplicity.)
So what we want to do is look at each file in turn and make two lists, one of hotkeys and the other of hotstrings, then list both groups separately once the two lists are complete.
Most of the commands we'll need to use to achieve this can only be performed on the string$ and data$ variables. So we'll need some extra variables to hold important contents of the string$ and data$ variables in order not to lose what we've done as we go through the files.
We can create variables named more or less as we like but watch for a trap: a variable called mydata$ would be treated as the characters "my" followed by the data$ variable so create names carefully and avoid collisions with existing variables. I've tried to make variable names that are reasonably readable without colliding with internal variables, and they're all declared in the first few lines, via String: Assign to variable commands.
0001 String: Clear ""
0002 String: Assign to variable "tph$"
0003 String: Assign to variable "tpt$"
0004 String: Assign to variable "header$"
I don't think it's stated anywhere explicitly, by the way, but if you don't declare the variables you're going to use in this way, the action will fail.
tph$ and tpt$ will be the lists: tpt$ will hold the lines starting "Text", and tph$ everything else, being the hotstrings.
0005 Folder: Assign "tooldata$\Actions\My Useful Stuff"
Tooldata$ is an internal variable that points at Toolbox's Data folder. The Actions subfolder contains the names of the action groups as subfolders, and "My Useful Stuff" is where all the actions we want to be reminded of have been put. If your action group is named differently, this is the only step you need to modify to match. The Folder: Assign command is a statement to Toolbox that this is the place we're going to be looking at the files contained within.
0006 Folder: Start of file processing ""
We have a process that will be applied to each of the files in the assigned folder, and this line is where the code will loop back to while there's still an unprocessed file to examine. That loop back happens at line 0024 below. From this point on, we're dealing with a single file and we have to ensure the process will be able to applied to anything we find.
0007 File: Assign "folder$name$"
0008 String: Assign from line number in file "1"
I'm going to quote the Help for line 0007:
QuoteAssigns the file to be used by all 'File' steps. The assigned file is stored in its entirety in the file$ variable; plus its filename alone in filename$, its extension in fileext$, and its folder in filefolder$. The size of the file, in bytes, is stored in filesize$ and will be -1 if the file doesn't exist (because files can actually be 0 bytes in size).
Line 0008 reads the first line of the active file and assigns it to the string$ variable. We're going to need string$ for other stuff later so
0009 String: Assign to variable "header$"
puts the string$ variable into our header$ variable we created in line 0004 as we'll need it for whichever of our lists it'll be put into later.
0010 String: Clear ""
0011 Data: Clear ""
Ensure string$ and data$ are both empty.
0012 Action: Do this block if "header$[Type"
The header$ variable contains the first line of the file we're looking at. The [ comparison operator here means "starts with" so what we're saying here is, if the file we're looking at is a text expansion, the next few lines (until the Action: End of block command) should be processed, but otherwise the block should be skipped.
So lines 0013 to 0016 are processed only because we now know that we're dealing with a text expansion.
0013 Data: Assign "tpt$"
0014 Data: Add "name$ = header$~"
0015 String: Assign "data$"
0016 String: Assign to variable "tpt$"
0017 Action: End of block ""
Line 0013 puts the current content of our list of text expansions into the data$ variable, line 0014 adds the filename, an equals sign surrounded by spaces, the first line of the file and a linefeed (the ~ symbol) to the data$ variable, line 0015 assigns the content of the data$ variable to string$ and line 0016 puts the updated version into tpt$. Line 0017 finishes the block, which you'll remember we've only processed because we know we're dealing with a text expansion.
So now we need a similar block for our hotkeys. This time, we're going to use a new comparison operator:
0018 Action: Do this block if "header$[!Type"
So this time, the comparison operator is [! -- which means "does NOT start with." You'll remember that we can only recognise a hotkey because it doesn't match the definition of a hotstring? So if the first line of the file is NOT the word "Text" we're dealing with a hotkey.
The block is then a near copy of the block above, but using the hotkey variable instead of the hotstring variable:
0019 Data: Assign "tph$"
0020 Data: Add "name$ = header$~"
0021 String: Assign "data$"
0022 String: Assign to variable "tph$"
0023 Action: End of block ""
So we've done all we need, so we can get the next file and loop back to line 0006:
0024 Folder: End of file processing ""
Once all the files have been processed, we now have two complete lists: tph$ is our list of hotkeys, tpt$ is the list of text expansions. All that remains now is to display them.
My preference is to show them in separate message windows, hotkeys first then text expansions.
0025 Alert: Show a message "Hotkeys are:~~tph$"
0026 Alert: Show a message "Text expansions are:~~tpt$"
However, if you'd rather have hotstrings first, just switch those two lines round. And if you'd rather do everything in one message, you could do something like
0025 Alert: Show a message "Hotkeys are:~~tph$~~Text expansions are~~tpt$"
And the entire action, without my blathering between chunks, is
(Start)
HOW TO USE: Copy from Start to End, and then paste into an action.
REFERENCE : See an example of pasting at alomware.com/paste.png
0001 String: Clear ""
0002 String: Assign to variable "tph$"
0003 String: Assign to variable "tpt$"
0004 String: Assign to variable "header$"
0005 Folder: Assign "tooldata$\Actions\My Useful Stuff"
0006 Folder: Start of file processing ""
0007 File: Assign "folder$name$"
0008 String: Assign from line number in file "1"
0009 String: Assign to variable "header$"
0010 String: Clear ""
0011 Data: Clear ""
0012 Action: Do this block if "header$[Type"
0013 Data: Assign "tpt$"
0014 Data: Add "name$ = header$~"
0015 String: Assign "data$"
0016 String: Assign to variable "tpt$"
0017 Action: End of block ""
0018 Action: Do this block if "header$[!Type"
0019 Data: Assign "tph$"
0020 Data: Add "name$ = header$~"
0021 String: Assign "data$"
0022 String: Assign to variable "tph$"
0023 Action: End of block ""
0024 Folder: End of file processing ""
0025 Alert: Show a message "Hotkeys are:~~tph$"
0026 Alert: Show a message "Text expansions are:~~tpt$"
(End)
Now you've got this, assign it a memorable trigger (I use ctrl-F1) and any time you make a new action that you want to be able to be reminded of the trigger for, all you need to do is put it in your "My Useful Stuff" group.