Alpha Video Training
Results 1 to 7 of 7

Thread: Delete multiple Saved Operations at once (#2)

  1. #1
    "Certified" Alphaholic
    Real Name
    Cal Locklin
    Join Date
    Mar 2000
    Location
    S.E. Michigan
    Posts
    5,763

    Default Delete multiple Saved Operations at once (#2)

    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.

  2. #2
    Former Alpha Employee JerryBrightbill's Avatar
    Real Name
    Jerry Brightbill
    Join Date
    Apr 2000
    Posts
    5,172

    Default RE: Delete multiple Saved Operations at once (#2)

    Cal

    You need to trap a blank selection from the first dialog, or you get an error if the user clicks the OK button.

    if op_type = ""
    end
    end if

    Jerry

  3. #3
    "Certified" Alphaholic
    Real Name
    Cal Locklin
    Join Date
    Mar 2000
    Location
    S.E. Michigan
    Posts
    5,763

    Default RE: Delete multiple Saved Operations at once (#2)

    Thanks Jerry.

    But I thought users are supposed to know better than to make mistakes like that!

    For those people who do make mistakes, I added the check to the end of the rest of the 'exit traps' at the end of the xdialog:

    IF varC_result="Cancel" .or. (varC_result="" .and. not_dbc ) .or. Op_type=""

    The new script is attached.

    As promised, I've also loaded the .aex file on my website at www.aimsdc.net/Programs.htm

  4. #4
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default RE: Delete multiple Saved Operations at once (#2)

    Cal,

    In your code you had the following;

    eval(Op_type+".Delete('" + to_b_deleted +"')")

    'FYI: The following also works: (why?)
    'eval(Op_type+".Delete(to_b_deleted)")


    Suppose to_b_deleted contains the value "CalsOperation" and Op_type contains "Append"

    In the 1st case, it converts to a line looking like
    eval("Append.Delete('CalsOperation')")
    which executes like the line
    Append.Delete('CalsOperation')

    In the 2nd case, it converts to a line looking like
    eval("Append.Delete(to_b_deleted)")
    which executes like the line
    Append.Delete(to_b_deleted)

    since to_b_deleted is a variable that is defined in the session where the eval() is executed, the to_b_deleted is available as the argument to Append.Delete instead of the constant (that was derived from the variable) that you imbedded for the 1st case.

    The reason you would normally imbed the constant as in the 1st case, is that the session where the code will be excuted (e.g. another form) would not have the variable available to it. This might be setting a filter or similar.

    Regards,

    Ira

  5. #5
    "Certified" Alphaholic
    Real Name
    Cal Locklin
    Join Date
    Mar 2000
    Location
    S.E. Michigan
    Posts
    5,763

    Default RE: Delete multiple Saved Operations at once (#2)

    Thanks Ira,

    I had forgotten about that note. I had left it as a reminder for me to go back and look at it more carefully but then forgot about it.

  6. #6
    Member
    Real Name
    Brian Kelley
    Join Date
    Dec 2005
    Posts
    33

    Default

    Hi Cal, this program is no longer possible to download; can you send it in again? thanks. Brian

  7. #7
    "Certified" Alphaholic
    Real Name
    Cal Locklin
    Join Date
    Mar 2000
    Location
    S.E. Michigan
    Posts
    5,763

    Default

    I don't see where the download problem is. The text links on this thread seem to be working and the addin file on my page also seems to be working. Maybe my site was down for a short time earlier??

Similar Threads

  1. Using Saved Operations on Multiple Tables
    By Barry Melamed in forum Archived Wishlist
    Replies: 3
    Last Post: 12-19-2004, 06:08 AM
  2. Deletion of saved mark and unmark operations.
    By henry russell in forum Alpha Five Version 5
    Replies: 0
    Last Post: 08-06-2003, 12:53 PM
  3. Weirdness with saved query in Operations
    By Tom Mills in forum Alpha Five Version 5
    Replies: 1
    Last Post: 02-20-2003, 09:05 AM
  4. xBasic vs Saved Operations
    By Rhett Scott in forum Alpha Five Version 4
    Replies: 11
    Last Post: 07-28-2001, 01:59 PM
  5. Retaining 'saved' Operations
    By Michael Lanzieri in forum Alpha Five Version 4
    Replies: 4
    Last Post: 07-19-2000, 05:33 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •