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

Array out of bounds

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

    Array out of bounds

    Ok, I am just a dumb accountant, and I tried to take this example from Barry Rochford in his article "Hurray for an Array"

    This is what I got when I tried to run the form:
    Script:OnDepart line 10: welllisting=inputf.new_prprty array out of bounds

    I have no clue how to fix this to give me the UI box I want to select from the field net_prprty in my table called "mmsprp". Can you help from what I have here?

    ''XBasic
    dim welllisting(15) as c
    dim inputf as p
    dim name as c
    dim global wellname as c
    dim i as n
    inputf=table.open("mmsprp",file_ro_shared)
    i=1
    inputf.fetch_first()
    while .not. inputf.fetch_eof()
    welllisting(i)=inputf.new_prprty
    inputf.fetch_next()
    i=i+1
    end while
    name=ui_get_list_array("Select your well",1,"welllisting")
    namex=substr(name,1,25)
    namex.refresh()
    inputf.close()
    end

    #2
    RE: Array out of bounds

    The error indicates you are trying to populate the array with more values that you have in the definition.

    dim welllisting(15) as c

    Will allow only 15 entries and you probably have more. If you don't know many many results will be returned, just set the value to a much higher number.

    dim welllisting(1000) as c

    Or you can find the number of records in the table first and set the array value to that. Find the value first and then dim the array.

    recs = inputf.records_get()

    dim welllisting(recs) as c

    Jerry

    Comment


      #3
      RE: Array out of bounds

      Ok, thanks, that makes sense, because there are hundreds of possible records, so I can set it at 1000 for now.

      Thanks again.

      Comment


        #4
        RE: Array out of bounds

        Well, Jerry I still don't quite have it. Here is my revised script after your help last week.

        In this attempt, the result message is: "Script:On depart line:17 namex.refresh()argument is incorrect data type"
        Why is that the case, I declared my variable namex as a character in line 6 here.

        Thanks for your help.

        Bruce


        ''XBasic
        dim welllisting(1024) as c
        dim inputf as p
        dim name as c
        dim global wellname as c
        dim global namex as c
        dim i as n
        inputf=table.open("mmsprp",file_ro_shared)
        i=1
        inputf.fetch_first()
        while .not. inputf.fetch_eof()
        welllisting(i)=inputf.new_prprty
        inputf.fetch_next()
        i=i+1
        end while
        name=ui_get_list_array("Select your well",1,"welllisting")
        namex=substr(name,1,25)
        namex.refresh()
        inputf.close()
        end

        Comment


          #5
          RE: Array out of bounds


          Bruce, these two lines don't make sense to me:

          Code:
          namex=substr(name,1,25) 
          namex.refresh()
          The first assigns a char string to a char type
          variable. Ok so far.

          The next attempts to refresh an object on your
          form named 'namex'.

          The error message suggests to me that maybe there is no
          such object on your form.

          OR

          Perhaps you're referencing the object on your form incorrectly.

          The typical approach would be:

          :Yourformname:Yourfieldname.refresh()

          This also might explain your error message.

          -- tom

          Comment


            #6
            RE: Array out of bounds

            Well, all I can tell you at this point is that I began with the subject title on 11-1 of "Forms Help Please" if you want to look back at that.

            Someone replied and pointed me to an article online written by Barry Rochford that they thought would be an approach to use.

            Having never tried to really do any x-basic work, I basically printed out that example and began trying to adapt it to my situation. I thought I about had it since the dialog box now pops up with my list of wells.

            Unfortunately, I am stuck when I got the error message you read about in my previous posting.

            Thanks,


            Bruce

            Comment


              #7
              RE: Array out of bounds

              Well, all I can tell you at this point is that I began with the subject title on 11-1 of "Forms Help Please" if you want to look back at that.

              Someone replied and pointed me to an article online written by Barry Rochford that they thought would be an approach to use.

              Having never tried to really do any x-basic work, I basically printed out that example and began trying to adapt it to my situation. I thought I about had it since the dialog box now pops up with my list of wells.

              Unfortunately, I am stuck when I got the error message you read about in my previous posting.

              Thanks,


              Bruce

              Comment


                #8
                RE: Array out of bounds

                Bruce,

                As Tom's pints out, the question is what is namex? If it is an object on a form, then the syntax is incorrect on both lines. If it is a variable, then there is not need for the line namex.refresh() as the refresh() command only applies to form or browse objects. Try removing that line, the script should work.

                Jerry

                Comment


                  #9
                  RE: Array out of bounds

                  I guess that part was right. Again, I was only following examples that I didn't fully understand.

                  When I removed the namex.refresh(), then the script stopped bombing.

                  I'm still not sure the script actually populated the variable like I thought it would.

                  So, I'll go back to studying what happened and get back here again soon.

                  Thanks for your help.

                  Comment


                    #10
                    RE: Array out of bounds

                    Hot dog!!! That time I made some progress by getting the character value namex on my form.

                    Now, I'm trying to figure out how in that UI box to get the UI box to display my wells according to an index which would be in alphabetical order rather than by record number.

                    Again, my UI box is built with:

                    name=ui_get_list_array("Select your well",1,"welllisting")

                    Comment


                      #11
                      RE: Array out of bounds

                      Ui_get_list_array() displays the array in the natural order of the array elements. To change this, you have to populate the array in the desired sequence to begin with.

                      Instead of:

                      inputf=table.open("mmsprp",file_ro_shared)
                      i=1
                      inputf.fetch_first()


                      try:

                      inputf=table.open("mmsprp",file_ro_shared)
                      inputf.index_primary_put("Yourindextagnamegoeshere")
                      i=1
                      inputf.fetch_first()


                      (This assumes you have an index defined for the table
                      in the sequence you need for the array. If not
                      you need to build one, and then use it's name in the index_primary_put() statement.

                      -- tom

                      Comment


                        #12
                        RE: Array out of bounds

                        Bruce,

                        Copying someone else's script can be a great learning tool. It can also be very frustrating if you don't know what the script is doing. I recommend you step through the script one line at a time, with your Xbasic Reference Manual close at hand. Check the manual for each and every line. You'll begin to see how it all fits together.

                        It's the difference between being given a fish, and learning how to fish for yourself.

                        -- tom

                        Comment


                          #13
                          RE: Array out of bounds

                          I'm not sure how you go about "Stepping" through a script. Are you saying to click view debugger? I haven't probably figured out how to use it properly.

                          Comment


                            #14
                            RE: Array out of bounds

                            Bruce, sorry. I didn't mean to be obscure. When I step through an unfamiliar script I study each line, one line at a time. Until I understand what it's doing I don't go on to the next line in the script.

                            Incidentally, this board is a great place to get clarificatioin if a particular line remains confusing after consulting the docs.

                            -- tom

                            Comment


                              #15
                              RE: Array out of bounds

                              Thanks Tom, you can be assured I will be around for a while asking goofy elementary questions. I have used Alpha V even when it was the DOS version Alpha IV,but I have never tried to do much with Xbasic.

                              But with the help of the discussion board, I feel like I will be able to make regular progress in my understanding.

                              Thanks again,


                              Bruce

                              Comment

                              Working...
                              X