Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Help with automating saved queries...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Re: Help with automating saved queries...

    Tom, Stan, Al;

    To all that read and made suggestions, thanx !!! In the spirit of showing what I learned the final solution and an example of the output is below.

    What I learned is:...
    1 You can get a list of Saved Operations (Queries) for a table.
    2 You can extract the FILTER parameter from those queries.
    3 You can capture the sums easily by using TABLESUM().
    4 This allows for easy self maintenancing by simply adding/removing Saved Operation Queries and upon the next script run it will used whatever exists which is very much what I wanted... too not be modifying this script going forward just because new items were added to the list of things to process or deleted for that matter.
    5 This demonstrates Add A New Table, with fields and Adding to the database.
    6 Capturing results from the TABLESUM() and updating the newly created table.
    7 Warning upon an Overwrite situation.
    8 Use of the PleaseWait() function to keep user informed of script progress.

    Solution Code:
    'Date Created: 04-Nov-2015 10:18:16 PM
    'Last Updated: 05-Nov-2015 11:02:36 PM
    'Created By : KeithW
    'Updated By : KeithW
    dim start As C
    dim finish as C
    dim cnt as N
    dim item as C
    dim list as C
    dim filter as C
    dim tbl as P
    dim query_balance as N

    ' Generate a list of all Saved Operations Queries for this table...
    list = a5_get_operations("query", "summ_by_customer")
    msgbox("List Of Operations",list) ' show list to user...

    'In case the destination table name is stored as a relative file name, or uses an alias
    'in the drive/path specification, use the filename_decode() function to convert the
    'filename to an absolute filename.
    destination_table = filename_decode("[PathAlias.ADB_Path]\Specific_Obligors.dbf")

    if file.exists(table.filename_get(destination_table)) then
    overwrite_result = ui_msg_box("Warning","'"+destination_table+"' already exists." + crlf(2) + "Would you like to overwrite it?",UI_INFORMATION_SYMBOL+UI_YES_NO)
    if overwrite_result <> UI_YES_SELECTED then
    END
    end if
    end if

    ' Create new table for Query Results...
    fields = <<%a%
    Key_Code,C,32,0
    Amount,N,15,2
    %a%
    create_table("[PathAlias.ADB_Path]\Specific_Obligors.dbf", fields)

    ' Add the destination table to the database....
    file_add_to_db(table.filename_get(destination_table))

    ' Open destination table for processing...
    tbl = table.open(destination_table)

    ' Begin processing Obligors...
    start = Time("0h:0m:0s")

    for each item in list ' only process Queries starting with a "z"
    if left(item.value,1) = "z" then

    ' Get FILTER parameter from existing Saved Operation (Query)...
    filter = query_filter_get(item)

    ' Display PleaseWait dialog to inform user of processing status...
    PleaseWait(.T., item + " ... ")

    ' Apply FILTER to table and sum the Total_Balance field...
    query_balance = 0
    query_balance = tablesum("summ_by_customer",filter,"total_balance")

    ' Enter mode to add new record to result table...
    tbl.enter_begin(.T.)
    tbl.Key_Code = item
    tbl.Amount = query_balance
    tbl.enter_end(.T.)

    ' Take down PleaseWait dialog box...
    PleaseWait(.F.)

    ' Keep track of the quantity of FILTERED/TABLESUM()s are run...
    cnt = cnt +1
    End If
    next
    finish = Time("0h:0m:0s")
    msgbox("Query Processing","Completed !!" +crlf()+str(cnt,2,0)+" items"+crlf()+start+" - "+finish)

    END

    '- - - - - - - - - - - - - - - - - - - - - - - -
    FUNCTION PleaseWait AS C (Show = .F.,what = "" )
    'DESCRIPTION: This function displays a 'Please Wait' dialog for use while processing.
    'What is an optional parameter that will be displayed along with the words "Please Wait"
    PleaseWait = ""
    if show = .F.
    if ui_modeless_dlg_exist("Processing")
    ui_modeless_dlg_close("Processing")
    end if
    exit function
    end if
    text1 = what+" Please Wait"
    len = len(text1)*2
    textbox="{text="+alltrim(str(len))+"text1}"
    box_code = <<%dlg%
    {background=Pale Yellow}
    {font=arial,14,bi}
    {include=textbox}
    %dlg%
    box_event = <<%code%
    1=1
    'sleep(5)
    %code%
    ui_modeless_dlg_box("Processing",box_code,box_event)
    ui_modeless_dlg_setfocus("Processing")
    ui_modeless_dlg_refresh("Processing")
    END FUNCTION
    ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


    First 5 Lines of Output Generated in Specified_Obligors file...
    Key_Code Amount

    z01_Fort Bragg 95,933.91
    z02_Invista 910,248.67
    z03_Wake County Board 1,524,354.34
    z04_NC State Univ 197,530.93
    z05_City Of Raleigh Park 429,200.77
    ...

    This file can then be exported to Excel which is where I need the data.
    I realize I can write directly to an Excel file and that is an exercise for another day.

    This shaved an hour of sitting and doing each step manually to 7 minutes with no intervention !
    Not a huge savings, but nice to not to have to be a slave to the original process no more.

    Regards,
    Keith
    Keith Weatherhead
    Discus Data, Ltd
    kweatherhead@gmail.com

    Comment


    • #17
      Re: Help with automating saved queries...

      Why not put those 45 filter definitions into a table. Embed your browse in a form with your calc total fields and use a lookup to apply the filter you want. Then you can print the data or copy the result to another table, or export to Excel, using a button.
      Robin

      Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

      Comment

      Working...
      X