Dang! One missing quote mark made a real mess of my first attempt to post this. Even killed the Reply button so I couldn't even post the fix in the same string. Let's hope I get it right this time.
One of my pet peeves is cleaning out old Saved Operations that have built up over the years and nobody knows what they do any more. This is especially true when it's someone else's app that I'm updating. So, I decided to spend a couple hours developing a routine that could save me 5-10 minutes next time I need to do a Saved Operation cleanup. I guess I'll chalk the negative efficiency up as 'training time' and post the results here for the benefit of others.
Since the script isn't particularly readable when put on this page, I've simply attached it in a 'special' text file. The attachment is the Xbasic Export file created by Alpha. To add the script to your own application, just save the attachment to your computer then open A5v5 and right click in the code tab to select the Import operation. From there it ought to be pretty self-explanatory. Of course, you can just open the text file and read it but it's much more readable once it's in the code editor. (If you use Xbasic at all and haven't used the code Export and Import features, you should try them. They're great for backing up scripts, copying them to other dbs, and temporarily removing scripts/functions which aren't wanted when creating .aex files.)
The script determines which operation Types (note types - not names yet) actually exist in the current db and shows a list of them. Once the operation Type is selected, a multi-select list of the specific operations is shown and all operations that you highlight will be deleted. Since A5's built-in delete operation is used for the actual deletion, you will be prompted prior to deleting each operation - but it's still much nicer than doing them one at a time from the Operations tab.
The xdialogs were originally created with the genie but got modified a bit as I progressed through my 'training' and added features and improved some of the processes. I also modified the OK/Cancel button area to get better vertical centering. I used extra semi-colons and removed the region around the buttons. However, this method may not work much longer as Selwyn has threatened to fix the bug that allows me to center the buttons by adding extra semi-colons. When that happens I'll have to switch to using {ysize=}. (Being an engineer by training, I like things nice an neat.)
Some of the features in this script include:
- the use of STRITRAN to get the plural of a Type based on two lists designed for that purpose. The plural is only used for some messages.
- the use of EVAL() in a couple places to run multiple Enum and Delete operations in a loop based on values in a crlf() delimited string. (The Eval function is a powerful feature but it takes awhile to get used to the idea of using it and to learn when to use it.)
- sorting a crlf() string with the SortSubStr() function. (This is really easy but I thought it was worth pointing out that the function exists.)
- a method I use to test the xdialog exit mode when checking for a double click in a regular list box. When exiting the xdialog based on a double click, the value of a_dlg_button is blank just the same as if the user clicked the 'x' in the upper right corner. Because of this, I had to find a way to determine whether the user had clicked the 'x' or double clicked a value in the list.
If anyone wants to have this as an addin, I'll probably put one on the Programs page of my website at www.aimsdc.net. This is one of the things I like about addins - I can add 'developer' features like this for immediate access on my own computer without cluttering up applications with them. If you want the addin, give me a couple days - it's already long past my bedtime.
One of my pet peeves is cleaning out old Saved Operations that have built up over the years and nobody knows what they do any more. This is especially true when it's someone else's app that I'm updating. So, I decided to spend a couple hours developing a routine that could save me 5-10 minutes next time I need to do a Saved Operation cleanup. I guess I'll chalk the negative efficiency up as 'training time' and post the results here for the benefit of others.
Since the script isn't particularly readable when put on this page, I've simply attached it in a 'special' text file. The attachment is the Xbasic Export file created by Alpha. To add the script to your own application, just save the attachment to your computer then open A5v5 and right click in the code tab to select the Import operation. From there it ought to be pretty self-explanatory. Of course, you can just open the text file and read it but it's much more readable once it's in the code editor. (If you use Xbasic at all and haven't used the code Export and Import features, you should try them. They're great for backing up scripts, copying them to other dbs, and temporarily removing scripts/functions which aren't wanted when creating .aex files.)
The script determines which operation Types (note types - not names yet) actually exist in the current db and shows a list of them. Once the operation Type is selected, a multi-select list of the specific operations is shown and all operations that you highlight will be deleted. Since A5's built-in delete operation is used for the actual deletion, you will be prompted prior to deleting each operation - but it's still much nicer than doing them one at a time from the Operations tab.
The xdialogs were originally created with the genie but got modified a bit as I progressed through my 'training' and added features and improved some of the processes. I also modified the OK/Cancel button area to get better vertical centering. I used extra semi-colons and removed the region around the buttons. However, this method may not work much longer as Selwyn has threatened to fix the bug that allows me to center the buttons by adding extra semi-colons. When that happens I'll have to switch to using {ysize=}. (Being an engineer by training, I like things nice an neat.)
Some of the features in this script include:
- the use of STRITRAN to get the plural of a Type based on two lists designed for that purpose. The plural is only used for some messages.
- the use of EVAL() in a couple places to run multiple Enum and Delete operations in a loop based on values in a crlf() delimited string. (The Eval function is a powerful feature but it takes awhile to get used to the idea of using it and to learn when to use it.)
- sorting a crlf() string with the SortSubStr() function. (This is really easy but I thought it was worth pointing out that the function exists.)
- a method I use to test the xdialog exit mode when checking for a double click in a regular list box. When exiting the xdialog based on a double click, the value of a_dlg_button is blank just the same as if the user clicked the 'x' in the upper right corner. Because of this, I had to find a way to determine whether the user had clicked the 'x' or double clicked a value in the list.
If anyone wants to have this as an addin, I'll probably put one on the Programs page of my website at www.aimsdc.net. This is one of the things I like about addins - I can add 'developer' features like this for immediate access on my own computer without cluttering up applications with them. If you want the addin, give me a couple days - it's already long past my bedtime.
Comment