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.records_get()

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

    index.records_get()

    When I try to count the number of records, I get 0 the first time and then using a second time the code I get the correct number of records.
    Why is this occurring? (same in A5V11 As in A5V12)

    The code:

    DIM counter as N
    DIM counter1 as N

    '' returns the <Index> object pointer that references the primary index
    indx2=pointer2.index_primary_get()

    '' retrieves the Number_of_Records selected by the specified index tag
    '' first time in var counter1
    counter1=indx2.records_get()
    '' second time in var counter
    counter =indx2.records_get()

    '' result
    ui_msg_box("values for var <counter>","counter1= "+counter1+" counter= "+counter,UI_OK)

    alpha5V12_rec_count.jpg

    #2
    Re: index.records_get()

    Originally posted by Tassos View Post
    When I try to count the number of records, I get 0 the first time and then using a second time the code I get the correct number of records.
    Why is this occurring? (same in A5V11 As in A5V12)

    The code:

    DIM counter as N
    DIM counter1 as N

    '' returns the <Index> object pointer that references the primary index
    indx2=pointer2.index_primary_get()

    '' retrieves the Number_of_Records selected by the specified index tag
    '' first time in var counter1
    counter1=indx2.records_get()
    '' second time in var counter
    counter =indx2.records_get()

    '' result
    ui_msg_box("values for var <counter>","counter1= "+counter1+" counter= "+counter,UI_OK)

    [ATTACH=CONFIG]38123[/ATTACH]
    There is more code involved. You haven't connected to a table.

    Please show that additional code.

    I just tried the code with a table.open to a dbf and it worked as expected in v11 runtime.
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.
    "Make it as simple as possible, but not simpler."
    Albert Einstein

    http://www.iadn.com/images/media/iadn_member.png

    Comment


      #3
      Re: index.records_get()

      Here is the code before the above lines (with explanations):

      (using Alpha5V12 build 1856)

      DIM counter as N
      DIM counter1 as N
      DIM anc_val as N
      dim selindex as C
      DIM sum_mean_hrs as N

      '' pointer represents set "runhrs.set" composed of main table "grpname.dbf" (pointer1)
      '' and table (one to multiple) "runhrs.dbf" (pointer2)
      ''Table grpname has folllowing fields
      '' vesnr N3
      ''Vesname C30
      '' Grpcode N5
      ''Grpname C50
      ''Hrsenable L1
      ''Grphrsno N2
      ''Lasthrsdays N5 2
      ''Grpincharge N2
      ''Inchargename C20
      "Upd D8
      "user C10


      '' table runhrs has following fields
      '' vesnr N3
      ''Vesname C30
      '' Groupcode N5
      " Runhrs N7
      "Upd D8
      "user C10


      dim pointer as P
      dim pointer1 as P
      dim pointer2 as P

      '' SET.CURRENT() method returns a pointer to the current set.
      pointer = set.current()
      pointer1=pointer.grpname
      pointer2=pointer.runhrs

      ''' defines the number of the group that i'm interested in
      code_group=pointer1.grpcode.value_get()
      code_group_str=ltrim(str(code_group))

      ' index name
      ' var->vesnrselect is a global var containing a number (string)
      selindex= "group"+code_group_str+var->vesnrselect

      'index of table runhrs created if it does not exist, otherwise use the existing one

      ' filter
      filtreA= "VESNR="+ltrim(str(var->vesnrselect))
      filtre1="GROUPCODE="+code_group_str+".AND."+filtreA

      ' creation/use of index
      index_p=pointer2.Index_Tag_Add(selindex,"INVERT(RUNHRS)",filtre1,"A")

      '' using this index as primary index (created or existing index : selindex)
      indx=pointer2.index_primary_put(selindex)

      ''index that is currently controlling the order of the records in the table
      indx2=pointer2.index_primary_get()

      counter1=indx2.records_get()
      counter =indx2.records_get()

      ...etc (here then, the code of the previous post)

      and a snapshot of the form with the button:

      alpha5V12_rec_count3.jpg


      Thanks for trying

      Comment


        #4
        Re: index.records_get()

        There is more going on than what you originally presented.

        Given the situation, I'd take out the manipulation(filters and anything else other than opening) of the table prior to testing the count and then add back in one at a time to show what code has an effect on the count.
        Al Buchholz
        Bookwood Systems, LTD
        Weekly QReportBuilder Webinars Thursday 1 pm CST

        Occam's Razor - KISS
        Normalize till it hurts - De-normalize till it works.
        Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
        When we triage a problem it is much easier to read sample systems than to read a mind.
        "Make it as simple as possible, but not simpler."
        Albert Einstein

        http://www.iadn.com/images/media/iadn_member.png

        Comment


          #5
          Re: index.records_get()

          I created a new button to test this particular piece of code as you sugested.
          I don't test that the index exists ( in this case it is OK, the indexes I use, already exists)
          and also I don't use: indx2=pointer2.index_primary_get() as indx2=pointer2.index_primary_put(selindex) should be sufficient.

          I have still the same results as before.
          I don't know if I mentioned it, but this happens only the first time I click on the button on every change of index. If I stay on the same page (that means I have the same Index) then the first value (counter1) is also correct.

          =======code ==============
          DIM counter as N
          DIM counter1 as N
          DIM anc_val as N
          dim selindex as C
          dim pointer as P
          dim pointer1 as P
          dim pointer2 as P
          dim indx2 as P
          pointer = set.current()
          pointer1=pointer.grpname
          pointer2=pointer.runhrs

          code_group=pointer1.grpcode.value_get()
          code_group_str=ltrim(str(code_group))

          selindex= "group"+code_group_str+var->vesnrselect
          indx2=pointer2.index_primary_put(selindex)

          counter1=indx2.records_get()
          counter =indx2.records_get()
          ui_msg_box("values for var <counter>","counter1= "+counter1+" counter= "+counter,UI_OK)
          end
          ''**** End

          ========== code end ==========


          rec_count_firsttime.jpg

          rec_count_secondtime.jpg

          The best way I found to overcome this problem, is, to repeat the records_get() command two times

          Comment


            #6
            Re: index.records_get()

            I'm unclear on the context in which this script is running.

            If the set is supporting a form, I don't think it's a good idea to change the primary index controlling the linked child table while the set is open.

            Have you considered using either TableCount() or DbCount() functions ? Both of these will return the count you are looking for, but each will open a new instance of the table to do so.

            Comment


              #7
              Re: index.records_get()

              From the help file:

              A5_GET_RECORDS_IN_QUERY()

              Syntax

              Record_Count as N = A5_GET_RECORDS_IN_QUERY( Table_or_Set_Name as C, Filter_Expn as C [, Session_Handle as N [, Count_Child_Records as L ]] )

              Argument
              Description

              Table_or_Set_Name
              The name of the table or set. Include the ".set" suffix when working with a set.

              Filter_Expn
              A character filter expression that evaluates to a logical value. Selects records.

              Session_Handle
              Optional. Default = -1 (current session).

              Count_Child_Records
              Optional. Default = .T.

              .T. = Count child records.

              .F. = Count only parent records.


              Description

              The A5_GET_RECORDS_IN_QUERY() function returns the number of records in the specified table or set that satisfy a query expression.

              Supported By

              Alpha Five Version 5 and Above

              Example

              ? a5_get_records_in_query("customer", "lastname > " + s_quote("M"))

              = 27.000000

              ? a5_get_records_in_query("inventory.set", "cost > 2")

              = 105


              This is a good way to test if a table is empty. Assuming the table's name is customer :

              if (a5_get_records_in_query("customer", .t.) = 0) then


              This expression returns the number of records in the current query.

              a5_get_records_in_query(current_filter_expn() )
              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


                #8
                Re: index.records_get()

                I think it's time for an simple example database to see what else is going on.
                Al Buchholz
                Bookwood Systems, LTD
                Weekly QReportBuilder Webinars Thursday 1 pm CST

                Occam's Razor - KISS
                Normalize till it hurts - De-normalize till it works.
                Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                When we triage a problem it is much easier to read sample systems than to read a mind.
                "Make it as simple as possible, but not simpler."
                Albert Einstein

                http://www.iadn.com/images/media/iadn_member.png

                Comment


                  #9
                  Re: index.records_get()

                  A5_GET_RECORDS_IN_QUERY() seems to work, thanks.


                  I have attached an example of the problem.
                  Go to the form. There is a button called "Test"
                  Pressing the button first time you get 0 and the correct number
                  Pressing the button a second time you get the correct number 2 times (as it should be)

                  Tassos
                  Attached Files

                  Comment

                  Working...
                  X