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

Iterate Index Keys ?

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

  • Iterate Index Keys ?

    Is there a way to fetch through the index keys? I'm finding that <index>.find_next() always returns a pointer to the index key that's "next" in relation to the tables record pointer. Can't use it to step through the keys in the index (without also stepping through the records in the table). Am I missing something here?

    Any suggestions on how to "find" a key, and then step forward through the index list from that point on?

    Thanks.

    -- tom

  • #2
    Re: Iterate Index Keys ?

    Tom, as for actual indexes for the table (not temporary ones) you could use the script Selwyn gave us to save the indexes for all tables to a text file - I save the indexes to a table instead of a text file, with the tablename as the first field, and the indexes in a memo - so I can fetch a specific table and get the indexes from the memo - although a bit of a kludge, it will work
    Cole Custom Programming - Terrell, Texas
    972 524 8714
    martin_w_cole@msn.com

    ____________________
    "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: Iterate Index Keys ?

      Thanks, Martin.

      I'm not trying to enumerate the index tag specifications.

      I'm trying to "fetch" through the keys for a specific index without fetching records in the related table. i.e find_first(), then find_next() over and and over until there are no more keys in the specific index list.

      Comment


      • #4
        Re: Iterate Index Keys ?

        Tom;

        Did you try some "sort" of application of <tbl>.cursor_get()
        Since when you move the pointer in a cursor you do not change the record that the base table (open) pointer is pointing to. ?

        Comment


        • #5
          Re: Iterate Index Keys ?

          James, no, haven't considered that.

          a) I don't understand the cursor_get() method and can't find it's documentation; and

          b) I am trying not to fetch records from the table as I step through the index.

          My goal is to be able to jump to an index key in a specific index, and then build a list of the next 100 index keys from there as fast as possible. I'd like to avoid clogging the network with fetches to the table itself.

          Comment


          • #6
            Re: Iterate Index Keys ?

            Tom

            Look here


            http://support.alphasoftware.com/alp...RSOR_GET().htm

            Tom B.

            Comment


            • #7
              Re: Iterate Index Keys ?

              I think James meant <tbl>.get_cursor()

              This is another item that has not yet made it into the regular help file.

              Its usage is outlined in the release notes for the patches.
              Build 1471-3180 9-May-2008
              Tim Kiebert
              Eagle Creek Citrus
              A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

              Comment


              • #8
                Re: Iterate Index Keys ?

                Sorry about that;

                I did mean <tb>.get_cursor(). Was just going by memory, should have check first.

                Comment


                • #9
                  Re: Iterate Index Keys ?

                  Thanks for the link to the release notes. I'm not sure this new table method will avoid the network traffic that will otherwise occur if one steps through all the records in a large table using the cursor. Hard to imagine that it might.

                  -- tom

                  Comment


                  • #10
                    Re: Iterate Index Keys ?

                    Tom, it sounds almost like you want to open the "cdx" file for a table and read the entries that way. Short of getting someone like Selwyn to write a script with commands that they have available we don't have or don't know about, you might want to consider a query - since the query is saved locally, containing the keys, and you could thus fetch through the query without network traffic. The data has to either be local or in a memory buffer - how else could you do it?
                    Cole Custom Programming - Terrell, Texas
                    972 524 8714
                    martin_w_cole@msn.com

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

                    Comment


                    • #11
                      Re: Iterate Index Keys ?

                      Originally posted by Tom Cone Jr View Post
                      I'm finding that <index>.find_next() always returns a pointer to the index key that's "next" in relation to the tables record pointer. Can't use it to step through the keys in the index (without also stepping through the records in the table).-- tom
                      Tom,

                      I'm failing to see why the find_next() cannot be used. I ran the code below and it went through every key of the index "Dept" without loading table records.

                      Code:
                      dim pFirst as P
                      dim pLast as P
                      dim pKey as P
                      
                      tbl = table.open("codes")
                      ndx = tbl.index_primary_put("Depts")
                      
                      pLast = ndx.find_last()
                      pFirst = ndx.find_first()
                      
                      pKey = ndx.key_get()
                      ui_msg_box("Started",str(pKey.Record))
                      
                      while pKey.Record <> pLast.Record
                      	pKey = ndx.find_next(pKey)
                      	ui_msg_box("Next",str(pKey.Record))
                      wend	
                      
                      tbl.close()
                      Am I misunderstood in what you are trying to achieve?

                      Steve

                      Comment


                      • #12
                        Re: Iterate Index Keys ?

                        Tom, the following code runs in Alphasports. It should show that the index gets looped through without moving the record pointer of the table.

                        Code:
                        dim tbl as P
                        tbl = table.open("customer")
                        
                        indx = tbl.index_primary_put("Lastname1")
                        
                        lst = indx.find_last()
                        b= indx.find("Smith")
                        
                        msgbox("Find 'Smith' in Index, Table pointer not moved",b.key  + b.record + crlf(2)+ tbl.Lastname +tbl.recno())
                        
                        tbl.fetch_first()
                        
                        msgbox("Find 'Smith' in Index, Table pointer moved to first record","In this case the first record is according to the index used." + crlf(2) +\
                                b.key  + b.record + crlf(2)+ tbl.Lastname +tbl.recno())
                        For i = 1 to 10
                            if b.record =lst.record then
                                exit for
                            end if
                            b=indx.find_next(b)
                            msgbox("Find next key in Index, Table pointer stays on the first record","Loop number " + i+crlf(2)+ \
                                    b.key  + b.record + crlf(2)+ tbl.Lastname +tbl.recno())
                        Next
                        
                        tbl.close()
                        I see Steve beat me to it. Must have been those extra message boxes I threw in there. :)
                        Last edited by Tim Kiebert; 07-13-2009, 11:57 AM.
                        Tim Kiebert
                        Eagle Creek Citrus
                        A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                        Comment


                        • #13
                          Re: Iterate Index Keys ?

                          In light of Martin's comments, I think even my previous post won't eliminate network traffic as I think each read of the index would still mean a trip to the server. Albeit with a lot less data to transmit. You could bring all the keys over in one trip using the <INDEX>.KEY_LIST_GET() method. With something like the following which would result in a variable holding all the keys. Then you would need to use character functions to do teh remainder of the processing. Maybe even populate an array.
                          Code:
                          dim tbl as P
                          dim indx as P
                          dim keylist as C
                          tbl = table.open("customer")
                          
                          indx = tbl.index_primary_put("Lastname1")
                          keyList = indx.key_list_get(indx.records_get(),1,"K"+crlf())
                          msgbox(keylist)
                          
                          tbl.close()
                          Tim Kiebert
                          Eagle Creek Citrus
                          A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                          Comment


                          • #14
                            Re: Iterate Index Keys ?

                            Thanks, guys. It turns out I was using the find_next() method incorrectly. I was passing an index pointer to the method, instead of a pointer to the key. I appreciate the help. This will get me where I need to go (barring other excursions into the land of badly written code!).

                            Tim, I am not trying to eliminate network traffic, just minimize it, cause I am trying to populate a listview control as fast as possible. I'm thinking that if the index key is all that needs to be stuffed into the control, then it's faster to pull it directly from the index, than from the table, especially in cases where the record structure in the table is pretty big and the record count is high.

                            -- tom

                            Comment


                            • #15
                              Re: Iterate Index Keys ?

                              Originally posted by Tom Cone Jr View Post
                              Tim, I am not trying to eliminate network traffic, just minimize it, cause I am trying to populate a listview control as fast as possible. I'm thinking that if the index key is all that needs to be stuffed into the control, then it's faster to pull it directly from the index, than from the table, especially in cases where the record structure in the table is pretty big and the record count is high.

                              -- tom
                              I kind of thought as much but figured I would throw the idea into the mix.

                              Cheers
                              Tim Kiebert
                              Eagle Creek Citrus
                              A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                              Comment

                              Working...
                              X