Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

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

Index Dictionary for Alpha5 DBF files

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

    Index Dictionary for Alpha5 DBF files

    Index Dictionary for Alpha5

    Alpha5 DBF database structures are known to loose indexes from time to time. The reasons this happens is not always clear but it does cause issues for Alpha5 applications that make use of and expect certain index files to be present.

    This package provides a Index dictionary for your application. It allows the end user to rebuild missing indexes and allows your application to intelligently deal with index that may be missing, giving the end user the opportunity to rebuild them without your intervention.

    This package also assist the developer in keeping track of indexes required and the frequency of their use. The package will even scan your code to verify index usage.

    Installation
    ------------

    The ZIP consists of 6 files idx.txt file contains 5 functions and 1 class.

    The functions are listed below, the class provides a progress indicator used when reindexing.

    Right Click on empty area of the Code Tab to deselect any selected script and select Import from the pop up menu.
    Import the *.txt file.

    Copy the IDX.DBF file to the folder used by your database.
    From the Table Tab of the AlphaFive Control Panel Right click in an empty area and select Add Table/Set from the pop up menu.
    Select IDX.DBF from the Table/Set Names listed and select Add > this will build the support files required so the forms can be added for the table.

    The two forms are provided IDX and IDXqry they are located in the files IDX_form.a5pkg and IDXqry_Form.a5pkg respectively.
    Right Click on empty area of the Form Tab and selecting import from the pop up menu.
    When the first form is imported you will need to Select a table to unpack it to.
    Select the IDX table you just added to the database.
    You will not need to select the Table when you import the second form.

    Now open the IDX form to access the Index Dictionary. This form is intended for use by the Alpha Five devolper, I would not recommend you give the end user access to this form.

    The first action is to populate the dictionary using the <Build Dictionary> button.
    After initially building the dictionary use the <Update Dictionary> so you do not remove any index's from the dictionary that may have gone missing since the last rebuild.

    FUNCTIONS
    ---------

    IDX() is a single function that provides all the code run from the buttons on the IDX form.

    IDXPUT() is a function that should be used when selecting a index in your code, it works with the Index Dictionary (IDX.DBF) to accomplish the following;
    - Selects the index using full name specified unlike to equivalent A5 methods for index selection
    - If the index is missing, build a temporary sort order if possible and return pointer to it
    - Flag tables that require index rebuild if a index is missing, these tables are pre-selected when the IDXREBUILD() function is used.
    - Gather statistics on the Index's usage.

    See the comments in the IDXPUT() function for details on it's use.

    IDXREBUILD() will rebuild indexes it can be called from your application and used by the end user. See the comments at the start of this function for details on it's use.

    IDXSET() is a function used to set the primary index for a table or browse. It in turn uses IDXPUT() and will display any error messages.

    US2IDRangeChk() is a sample of a function used to check a value instead using a field rule.

    A5 Index Issues
    ---------------

    The introduction indicates that Alpha5 can loose indexes all on it's own. One cause of this is; indexing expressions that cannot be evaluated. When Alpha5 saves a change to a record it next has to update indexs for that table. If an index expression cannot be evaluated Alpha5 is unable to back out of the save operation (it doesn't have the ability to do Atomic transactions) and the index is no longer valid so it is dropped. The index MAY reappear on subsequent opening of the table if the expression is once again valid.

    This is easily demonstrated by defining a global variable with a value and using it in a indexing expression. Update some record that use the index. Next delete the Global variable and update a record in the table and you will see the index be deleted.

    Alpha Five will build many index's on it's own. Some of these are easily recognized by thier names, these are not added to the Index Dictionary. Look at the first of the IDX() function to see a list on Indexs that are excluded from the Index Dictionary.
    Other Index's Built by Alpha Five are required for linking tables in sets, these will have unique names based on the fields involved these will be included in the index dictionary.

    Alpha Five will at times build indexs that contain comma's in the Index Name. The Alpha Five routines used by this package to build the index's do not support the use of commas in the index names.

    Before building an index for it's own internal use Alpha5 will see if an index with the correct defination exist. If one does it will be used. So if a index that would contain commas in the name is built under a different name the issue of index names with commas is avoided.

    Alpha5 will build indexes for use by field rules, for example unique checks. These indexes will always be built with name selected internally by Alpha5. This can be seen by creating a unqiue check field rule. Going to the index definition for this table and deleting all indexes. Close index editor and then reopen it. The Index required by the Alpha5 field rule will have been recreated.

    Because the IDXrebuild() function does much the same thing, it deletes all indexes for a table and then rebuilds them. Any index used in field rules will always have the name generated by Alpha5 regardless of the name placed in the IDX table. This is because Alph5 builds the index before the IDXrebuild() function has a chance to.

    A solution to this problem is to move the unique check to Field Event in the field rules;

    Field Event -> Record Events -> CanSaveRecord

    Code:
    IF .NOT. US2idrangechk(a_users_idrange->CODE,a_users_idrange->low,a_users_idrange->high)
    cancel()
    end if

    It is best that the event code calls a function so the index used can be determined by the IDX scan function.
    A sample Function is provide in the idx*.txt file with the name US2IDRangeChk()
    Attached Files

    #2
    Re: Index Dictionary for Alpha5 DBF files

    tried but got error - function zDbgSet not recognized - line 81 script idx()

    Comment


      #3
      Re: Index Dictionary for Alpha5 DBF files

      just comment out all references to zDbgSet its not required

      Comment


        #4
        Hi! I picked up this script to help keep my messy old POS db (so old it started life as alpha4) from coughing up a lung, but I'm having trouble getting it to run. Besides the zdbg error, I also get zGetTblName. Is there a library missing? ZGetTblName doesn't appear to be defined as a function anywhere in the script but is called multiple times and appears to be very much needed to operate. If so, Could we get a copy of that library?

        I'm currently using 10.5

        Comment


          #5
          I just found this message. I downloaded the zip file and installed the files in a test app. What I have seen is brilliant.

          I am getting an error when trying to run the function IDXRebuild(). It appears that the function zGetTblName() is missing.

          Code:
          Tbl = table.open(zGetTblName("idx"))
          Is it possible to post the code to this function? Thank you very much for sharing this with the community.
          Alpha 5 Version 11
          AA Build 2999, Build 4269, Current Build
          DBF's and MySql
          Desktop, Web on the Desktop and WEB

          Ron Anusiewicz

          Comment


            #6
            Please refer to the newer version of this code posted on 2023-12-28. The title is ​This version addresses the issues raised in the postings here.

            Comment

            Working...
            X