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

Quicker Drop Down List Box

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

    Quicker Drop Down List Box

    I have a listbox that is populated by a table with 4174 records in it. It takes about 20 seconds for the listbox to be populated. The listbox is a variable and needs to remain that way. The only other idea is to make a custom lookup form that diplays the data, but I would like to pursue this avenue first.

    My code:

    dim mac as p
    dim idx as p
    dim count as n
    dim i as n

    mac=table.open("roy_device_type")
    idx=mac.index_tag_add("Device_Name","device_type_name")
    count=idx.records_get()+1
    device_type.choice.list.redim(count)
    mac.fetch_first()
    device_type.choice.list[1].text=""
    for i=2 to count
    device_type.choice.list[i].text=mac.device_type_name
    device_type.choice.list[i].value=mac.device_type_name
    mac.fetch_next()
    next
    mac.close()

    Thanks
    Jamin

    #2
    RE: Quicker Drop Down List Box

    with that many items, I would make a dialog form with an embedded browse, and use Dr. Wayne's script to isolate records as the user enter characters on the keyboard.
    Cole Custom Programming - Terrell, Texas
    972 524 8714
    [email protected]

    ____________________
    "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

    Comment


      #3
      RE: Quicker Drop Down List Box

      Also - I would not use the word "count" as a variable - it is a reserved word, and using reserved words as variables will often create problems - also, if you only want to populate the embedded browse with "some" of the records from the table - you can create a query.
      Cole Custom Programming - Terrell, Texas
      972 524 8714
      [email protected]

      ____________________
      "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

      Comment


        #4
        RE: Quicker Drop Down List Box

        I didnt want to do that. It looks better the other way but it looks like I will have to give in.

        Thanks
        Jamin

        Comment


          #5
          RE: Quicker Drop Down List Box

          Jamin,

          I don't disagree with Martin's idea, however two other thoughts occur to me:

          1) you might want to use table.batch_begin() and batch_end() to see how that affects the speed at which you fetch through the table.

          2) you might want to preload the array while the user is waiting for some other process to be finished... for example, it is theoretically possible to declare the array as global and populate it while the app is first opening. The user might tolerate a single delay better than having to wait each time they branch to this particular module.

          3) why do you use tbl.index_tag_add() instead of tbl.index_primary_put() ? I should think 'adding' a new index tag to your existing index file is going to be pretty slow (relatively speaking).

          -- tom

          Comment


            #6
            RE: Quicker Drop Down List Box

            Thanks for the reply tom

            1) I thought batch_begin and batch_end were only for entering and changing records. I will give it a try.

            2)That is basically what this does

            3)Why I like tbl.index_tag_add() by Jamin Dunivan
            It will not add a new index every time. It only adds it if it does not exist.

            from the manual on index_tag_add():

            "Add a new index tag, or finds an existing index tag, in the production index file
            for the table referenced by the object pointer, . When called, this function
            first searches the index file to see if this index already exists. If an index with
            identical specifications (i.e., the same Order Expression, Filter Expression, and
            Index Type) is found, .index_tag_add() returns an object pointer
            () to this index."

            Comment


              #7
              RE: Quicker Drop Down List Box

              2 second difference using batch. from 36 to 34

              Comment


                #8
                RE: Quicker Drop Down List Box

                I think Tom is correct ( what a surprise ). If you know the way you are going to access the table and it appears you do, just open the table with that index and do your thing.

                Easy to test: In define indexes create an index tag named "typename" indexed on device_type_name.
                Instead of:
                idx=mac.index_tag_add("Device_Name","device_type_name")
                Use:
                idx = mac.index_primary_put("typname")
                Then see if it speeds up the process.
                JOhn

                Comment


                  #9
                  RE: Quicker Drop Down List Box

                  Hi John

                  Went from 34 seconds to 35 seconds. I like index_tag_add() because it finds the index first if it exists like index_primary_put(). If there is no match it adds the index. I use this for a safety feature. If for some reason an index is involuntarily dropped. This will recreate it if it has to.

                  thanks
                  Jamin

                  Comment


                    #10
                    RE: Quicker Drop Down List Box

                    Jamin,

                    I didn't see that the index_tag_add looked for that tag in the production index first before adding. I'm curious what happens if it doen't find the tag and tries to add it in a multi-user environment with others using the table.

                    Just a thought here. If you run and time just the following, is it a signifigant amount of time:

                    mac=table.open("roy_device_type")
                    idx=mac.index_tag_add("Device_Name","device_type_name")
                    'rem start the timing
                    count=idx.records_get()+1
                    'rem end the timing

                    If it is significant, is the file extremely volatile? Could you get the file size in a global variable upon starting the app, add a number to it, and redim the variable to that?
                    Then in the code do a while .not. mac.fetch_eof() to populate the variable.

                    John

                    Comment


                      #11
                      RE: Quicker Drop Down List Box

                      John

                      I believe the indexes are used locally in your shadow table and not at the main app.

                      I tried your suggestion and reached 34 seconds. I think I am just going to have to make a custom lookup form.

                      Thanks for trying.
                      Jamin

                      Comment

                      Working...
                      X