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

Bug in Pointer Arrays?

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

    Bug in Pointer Arrays?

    Hi All,

    Is this a bug?

    I have an application for a motel reservation system. I am trying to build a matrix array of Units/Dates to be used for the purpose of a dyanmic list box showing what units have been booked. My problem is that after I have filled the Array the first element has the same value throughout. If you run the following code you will see what I mean

    ****** START *****

    trace.clear()
    sUnits = "Unit1,Unit2,Unit3,Unit4,Unit5,Unit6,Unit7,Unit8,Unit9,Unit10"
    sUnits=stritran(sUnits,",",crlf())
    dim aUnits[10] as C
    dim aMatrix[10,31] as P
    aUnits.initialize(sUnits)

    dDate = {01-07-2005}
    for i = 1 to 10
    for j = 1 to 31
    aMatrix[i,j].Date = dDate + j -1
    aMatrix[i,j].Unit = aUnits[i]
    next j
    next i

    for j = 1 to 30
    trace.writeln (cdate(aMatrix[1,j].date)+ "/" + aMatrix[1,j].Unit + " " + \
    cdate(aMatrix[2,j].date) + "/" + aMatrix[2,j].Unit)

    next j

    ***** END *****

    The results displayed in the trace window are as follows (first 8 days only)

    20050731/Unit1 20050701/Unit2
    20050731/Unit1 20050702/Unit2
    20050731/Unit1 20050703/Unit2
    20050731/Unit1 20050704/Unit2
    20050731/Unit1 20050705/Unit2
    20050731/Unit1 20050706/Unit2
    20050731/Unit1 20050707/Unit2
    20050731/Unit1 20050708/Unit2

    Notice how for Unit 1 the Dates are all the same

    Any Suggestions?
    Mike Thomson

    #2
    RE: Bug in Pointer Arrays?

    Assuming {01-07-2005} is July 1,2005 on your side of the pond I get the same results here.

    -- tom

    Comment


      #3
      RE: Bug in Pointer Arrays?

      Mike,

      I noticed that if I put a trace.writeln() statement inside the loop that populates the matrix the Unit1 date values appear correctly. ???

      -- tom

      Comment


        #4
        RE: Bug in Pointer Arrays?

        Mike:
        It's a bit subtle but easy to explain. It has nothing do do with your arry which is fine, but with the trace.writeln routine:
        The trace.writeln writes the first row from the arry, then increments j by one but does not increment i, and as such, you keep reading the same value on the first row in the left column, while in the second column and as j increments, you keep reading down the column.

        In summary, your array is compilled properly, but you are not reading it proprly.
        Gabe

        Comment


          #5
          RE: Bug in Pointer Arrays?

          gabe, this is admittedly slippery stuff for me, but I disagree with your analysis. Consider this example that illustrates the same issue:

          'Date Created: 23-Jul-2005 08:35:58 AM
          'Last Updated: 23-Jul-2005 08:35:58 AM
          'Created By : TEC
          'Updated By : TEC

          trace.clear()
          dDate = {01/01/2005}

          '-----------loop 1 (using date type vars) works fine -------------
          dim dArray[31] as D
          for i = 1 to 31
          dArray[i] = dDate + (i - 1)
          next i
          trace.writeln("Loop 1 begins")
          for i = 1 to 31
          trace.writeln(dtoc(dArray[i]))
          next i
          trace.writeln("Loop 1 ends")
          '----------- loop1 ends here -----------------------------


          '------------ loop 2 (using date type vars in a matrix array) works fine ------------
          dim aMatrix[1,31] as D
          for i = 1 to 31
          aMatrix[1,i] = dDate + (i -1)
          next i
          trace.writeln("Loop 2 begins")
          for i = 1 to 31
          trace.writeln(dtoc(aMatrix[1,i]))
          next i
          trace.writeln("Loop 2 ends")
          '------------ loop 2 ends ----------------------------------------------------------


          '------------ loop 3 begins here (uses pointer data type) -------------------------
          'In this loop the trace.writeln() statements immediately following the
          ' assignment statement are correctly processed.
          'HOWEVER, when the matrix is processed a second time, for the next
          ' trace.writeln() statements, the wrong values appear.
          dim pMatrix[1,31] as P
          trace.writeln("Loop 3 begins")
          for i = 1 to 31
          pMatrix[1,i].MyDate = dDate + (i - 1)
          trace.writeln(dtoc(pMatrix[1,i].MyDate) + " written as each pointer element is loaded")
          next i
          trace.writeln("-----------------------")
          for i = 1 to 31
          trace.writeln(dtoc(pMatrix[1,i].MyDate) + " written after all pointer elements were loaded")
          next i
          trace.writeln("Loop 3 ends")
          '-------------- loop 3 ends here -----------------------------
          trace.writeln("-----------------------")
          trace.writeln(dtoc(pMatrix[1,1].MyDate)) 'returns correct value, but
          trace.writeln(dtoc(pMatrix[1,7].MyDate)) 'returns wrong value
          trace.writeln(dtoc(pMatrix[1,14].MyDate)) 'returns wrong value
          trace.writeln(dtoc(pMatrix[1,21].MyDate)) 'returns wrong value
          end

          Comment


            #6
            RE: Bug in Pointer Arrays?

            Tom:
            My head is spinning from all these loops! Here is the routine after I modified it and the result:

            trace.clear()
            for j = 1 to 5
            sUnits = "Unit1,Unit2,Unit3,Unit4,Unit5,Unit6,Unit7,Unit8,Unit9,Unit10"
            sUnits=stritran(sUnits,",",crlf())
            dim aUnits[10] as C
            dim aMatrix[10,31] as P
            aUnits.initialize(sUnits)

            dDate = {07-01-2005}
            for i = 1 to 10
            aMatrix[i,j].Date = dDate + j -1
            aMatrix[i,j].Unit = aUnits[i]
            next i

            trace.writeln (cdate(aMatrix[1,j].date)+ "/" + aMatrix[1,j].Unit + " " + \
            cdate(aMatrix[2,j].date) + "/" + aMatrix[2,j].Unit)
            next j

            20050701/Unit1 20050701/Unit2
            20050702/Unit1 20050702/Unit2
            20050703/Unit1 20050703/Unit2
            20050704/Unit1 20050704/Unit2
            20050705/Unit1 20050705/Unit2

            Gabe

            Comment


              #7
              RE: Bug in Pointer Arrays?

              Gabe,

              I'm getting a bit dizzy, also. "grin"

              Your script stops short of the problem area. The array elements appear to be populated correctly, but if you then extend the script to re-display the exact same elements you will encounter the problem under discussion.

              e.g.

              'Date Created: 23-Jul-2005 02:17:57 PM
              'Last Updated: 23-Jul-2005 02:17:57 PM
              'Created By : gabe
              'Updated By : tom
              trace.clear()
              for j = 1 to 5
              sUnits = "Unit1,Unit2,Unit3,Unit4,Unit5,Unit6,Unit7,Unit8,Unit9,Unit10"
              sUnits=stritran(sUnits,",",crlf())
              dim aUnits[10] as C
              dim aMatrix[10,31] as P
              aUnits.initialize(sUnits)

              dDate = {07-01-2005}
              for i = 1 to 10
              aMatrix[i,j].Date = dDate + j -1
              aMatrix[i,j].Unit = aUnits[i]
              next i

              trace.writeln (cdate(aMatrix[1,j].date)+ "/" + aMatrix[1,j].Unit + " " + \
              cdate(aMatrix[2,j].date) + "/" + aMatrix[2,j].Unit)
              next j

              'Now that the array is populated, attempt to display the same elements
              'as were just written to the trace window (using the same code to do so)
              trace.writeln("-------------------")
              for j = 1 to 5
              trace.writeln (cdate(aMatrix[1,j].date)+ "/" + aMatrix[1,j].Unit + " " + \
              cdate(aMatrix[2,j].date) + "/" + aMatrix[2,j].Unit)
              next j

              Comment


                #8
                RE: Bug in Pointer Arrays?

                I tried reading the Array outside the trace.writeln script and I get still get the wrong values.

                So I guess at this stage we probably agree thats theres a problem

                How do these things normally get reported to Alpha Software for review?
                Mike Thomson

                Comment


                  #9
                  RE: Bug in Pointer Arrays?

                  The Help menu w/in Alpha Five itself has a "Send bug report" option. I submitted a report this afternoon.

                  -- tom

                  Comment


                    #10
                    RE: Bug in Pointer Arrays?

                    Great,

                    While I am an experienced Database developer - I am still only evaluating Alpha 5 for my next commercial project. In doing so I am tending to start at the more complex things and work backwards.

                    Despite its present client server limitations I am veryimpressed.

                    It is refreshing to see how well this forum is supported.

                    Many Thanks
                    Mike Thomson
                    Mike Thomson

                    Comment


                      #11
                      RE: Bug in Pointer Arrays?

                      Mike,

                      You're welcome.

                      To round out your "sampling" experience, be sure to visit and browse:

                      1) Newsletter archives online
                      2) Code Archive forum in this message board
                      3) Articles collection at www.learn alpha.com
                      4) The tutorials and other resources at Alpha's online Learning Center (link found on Alpha Software's home page)

                      -- tom

                      Comment


                        #12
                        RE: Bug in Pointer Arrays?

                        Mike:
                        have youtried the script as I modified it? it seems to bring the desired results.
                        Gabe

                        Comment


                          #13
                          RE: Bug in Pointer Arrays?

                          We discovered a problem with multidimensional arrays where the [1,x] entry doesn't work as expected (as evidenced by your example), but anything [2,x] or greater does. Here is a simple example that shows the issue:

                          delete p
                          dim p[5,5] as p
                          p[1,1].name = "aaron"
                          p[1,2].name = "selwyn"
                          p[2,1].name = "cian"
                          p[2,2].name = "eavan"
                          p[3,1].name = "brett"
                          p[3,2].name = "adi"

                          ? p[1,1].name
                          = "selwyn"

                          ? p[1,2].name
                          = "selwyn"

                          ? p[2,1].name
                          = "cian"

                          ? p[2,2].name
                          = "eavan"

                          ? p[3,1].name
                          = "brett"

                          ? p[3,2].name
                          = "adi"


                          I will add this to the list of bugs to be fixed, but in the meantime, could you please elaborate on what you are trying to accomplish and perhaps we can come up with a better solution or a workaround.

                          One option would to be to use a property array with a month value and date value, or a faked multidimensional array ala

                          dim row[12] as p
                          dim row[1..12].col[31] as d

                          row[3].col[21] = date()

                          etc
                          Aaron Brown
                          Alpha Software Development Team

                          Comment


                            #14
                            RE: Bug in Pointer Arrays?

                            Thanks Aaron,

                            The reason I was using a multi dimendional arrays was to hold data for for a dyanmic grid which related to a grid of buttons , each button being colour coded to show the availability of the room. The reason I have used buttons is that they allow me to provide a graphical presentation.

                            Please note the thread - which has an example of grid , and I have reported problem relating to time it takes to update controls.
                            http://msgboard.alphasoftware.com/alphaphorum/read.php3?num=15&id=22035&loc=0&offset=0&sortby=lastreply&direction=desc&thread=22035

                            The X a-axis for the Grid is a range of dates (14 at a time) and a range of units (a total of 22). I was using the Array to hold varios data associated with each cell , such as date, status, customer etc.

                            At the end of the day I ended up doing the same as you have suggested and it worked OK. - But the speed of updating controls is still an issue.

                            Mike
                            Mike Thomson

                            Comment

                            Working...
                            X