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

Invalid Key Length

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

    Invalid Key Length

    tbl = table.open("hours")
    indx = tbl.index_get("rchk1")
    tbl.index_primary_put(indx)
    tbl.fetch_last()
    fld = tbl.field_get("rchk")
    var->LastCheck = fld.value_get()
    indx = tbl.index_get("rchk0")
    tbl.index_primary_put(indx)
    rec_count = indx.records_get()
    fld = table.field_get("rchk")
    tbl.fetch_first()
    tbl.change_begin()
    for x = 1 to rec_count
    fld.value_put(var->LastCheck + x)
    tbl.change_end()
    tbl.fetch_next()
    tbl.change_begin()
    Next
    tbl.change_end()
    tbl.close()I am trying to assign check numbers to records that do not have numbers assigned. The "hours" table has a field "rchk" that holds the check numbers, numeric 5/0.
    I have indexed this field using rchk1 and rchk0. I can step through the attached script and do not get an index error but when I run it, I get "invalid key length". The first part of the script puts the records in check number order so that I may retrieve the last check number using tbl.fetch_last(), then assign this number to a variable. The next section, using the index rchk0 finds only the records that have no check number and do have netpay >0. This is set up in the index definition. When I look at the results in the expression builder (for index) it shows me a four digit check number followed by a decimal point and six zeros. I don't understand why the decimal and zeros and if this is the cause of the key length error. I barely know how to write xbasic and this has me baffled (as usual).

    #2
    RE: Invalid Key Length

    Howard,
    I think part of the problem is that you are changing the field that
    is indexed while you are fetching with that index. I'm not
    sure if Alpha knows how to fetch_next after you change
    the indexed field.

    I would rewrite your code this way:

    dim lastcheck as n
    tbl = table.open("hours")
    tbl.index_primary_put("rchk1")
    tbl.fetch_last()
    LastCheck = tbl.rchk
    query.filter="isblank('rchk') .and. netpay>0"
    query.order=""
    query.options="M"
    ix=tbl.query_create()
    tbl.fetch_first()
    x=0
    while .not. tbl.fetch_eof()
    x=x+1
    tbl.change_begin()
    tbl.rchk=lastcheck+x
    tbl.change_end(.t.)
    tbl.fetch_next()
    end while
    ix.drop()
    tbl.close()

    I think you will find this script will work.
    indx = tbl.index_get("rchk0")
    tbl.index_primary_put(indx)
    rec_count = indx.records_get()
    fld = table.field_get("rchk")
    tbl.fetch_first()
    tbl.change_begin()
    for x = 1 to rec_count
    fld.value_put(var->LastCheck + x)
    tbl.change_end()
    tbl.fetch_next()
    tbl.change_begin()
    Next
    tbl.change_end()
    tbl.close()

    Comment


      #3
      RE: Invalid Key Length

      oops - i left part of your script at the end of my message - ignore the part
      after "this will work"

      Comment


        #4
        RE: Invalid Key Length

        A great big thanks for responding to my call for help. A couple of comments:
        1 - query.options("M"). The "M" is not one of the options shown in my xbasic manual. What is the meaning?
        2 - In my text I mentioned "netpay". Actually it's "RegNetPay", so I got an error "field not found" but that wasn't too hard to find.
        3 - The code you sent works perfectly if I step through it, bypassing the "While" and "End While" ....but...if I run it normally, I get an error and can't figure out why. Error is: ERROR: mismatched end of loop or if block. I checked the syntax in my manual and everything looks OK. Any ideas?
        I am struggling to learn more about xbasic but I have a long way to go.
        Howard

        Comment


          #5
          RE: Invalid Key Length

          Howard,

          I had trouble with this one before, myself. It's a good idea to print out the Readme files that come with each version.

          New Options for .Query_Create Method
          Alpha Five now has two new option flags for the .query_create() method. These options are set with
          the query.options variable. The options are:
          query.options = "M"
          If this option is specified, Alpha Five will build a new query list even though a) an existing query list exists,
          and b) an existing Index exists (both of which, Alpha Five could have used rather than running a new
          query).
          query.options = "X"
          If this option is specified, Alpha Five will use an index even if an existing query exists (which Alpha Five
          would otherwise have used in preference to the index)
          If no options are specified, then when you run a query, Alpha Five does the following:
          a) if the same query has been previously run, use that query list.
          b) if not, but if an index that satisfies the query criteria exists, use the index.
          c) if a previously run query does not exist, and if no index exists, run a new query.
          Previously, Alpha Five only offered one option, �N�, which caused Alpha Five to run a query, rather than
          selecting an index, if an index would have satisfied the query criteria.
          If you want to trade off speed for certainty that your applications will run correctly, you should consider
          using the �M� option in your Xbasic code. (In most applications the speed difference will probably not even
          be noticeable.) This ensures that whenever you use the query_create() method, Alpha Five is creating a new
          query from scratch, and not relying on a previously run query, or an index, that could be corrupt.
          There can be only one.

          Comment


            #6
            RE: Invalid Key Length

            Thanks, Stan. My manual shows an "N" for the option you specify as "M".

            Comment


              #7
              RE: Invalid Key Length

              I found my "bug" in the while/end while. I neglected to put a space between the while and the .not. Guess these old eyes need some refurbishing. Now...I am back to the same problem I reported first...Invalid key length. Even though the program seems to work when I use interactive mode and step through it. Could this problem be somewhere else and not with this particular code? This is the only code attached to the "Print Checks" button at this point.

              Comment


                #8
                RE: Invalid Key Length

                Howard,
                Is your highest check number going to be greater than 99999 using the old or new program?? Did you rebuild your indexes before testing the new code??
                John

                Comment


                  #9
                  RE: Invalid Key Length

                  John, Check numbers are currently 4 digits. I have space for 5.
                  Yes, I have rebuilt indexes until I am blue in the face....
                  I don't know what I did but now the procedure works fine without errors. Murphy's law says, "If you fool around with something long enough you will break it". I guess there is an opposite law, too: "Be careful, you may even fix it".
                  Thanks, John

                  Comment

                  Working...
                  X