Announcement

Collapse
No announcement yet.

HELP!

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

  • HELP!

    Hi all,

    I am working on a large project. And now I got a strange problem.
    The following line have been in my code for weeks, and worked fine:

    Code:
    ch.graph(1).lpDataY         = varptr(expage(0,%W))
    This morning it started to GPF!
    expage(...) is a global array. ch is static.
    If I add a msgbox everything is fine (the msgbox returns the correct value,
    and there is no GPF):

    Code:
    msgbox format$(expage(0,%W))
    ch.graph(1).lpDataY         = varptr(expage(0,%W))
    Can anybody explain the fact that adding a msgbox solves the problem?
    The project is very large. Have I hit some limit for global memory?
    HELP!

    If I change ch to local, there is no GPF.

    Regards
    Peter


    ------------------




    [This message has been edited by Peter P Stephensen (edited April 18, 2001).]
    [email protected]
    www.dreammodel.dk

  • #2
    Peter,

    this is a problem I've already found, but I forgot to post to this forum - may be it is a known problem...

    As I've understood it, UDTs CAN'T contain arrays. In your code graph is an UDT, and ch contains an array of graphs. I encountered problems also with simple LONG arrays inside an UDT... I hope one of the PowerBasic support guys tell something. At the moment I removed all the arrays form the UDTs; whenever I put arrays, I have random GPFs.

    When you add the message box you change che compile code. As I stated above, GPFs are not always generated - they are random.

    Aldo

    ------------------


    [This message has been edited by Aldo Cavini (edited April 18, 2001).]
    Rgds, Aldo

    Comment


    • #3
      It does sound like you have encountered a known issue - arrays within a GLOBAL UDT can cause a GPF in obscure circumstances.

      R&D have identified the problem and the next update to the compiler will include a fix for this problem.

      Thanks!


      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Lance
      mailto:[email protected]

      Comment


      • #4
        Lance,

        My UDT is not global. It is static (and it have to be static).

        Any solutions? This is very problematic for me! I have made a
        chart-control that is used very extensively in my current project.
        The chart is defined by the UDT:
        Code:
        TYPE CHART
            ...
            Graph(%MAX_GRAPHS-1) AS GRAPH
            ...
        END TYPE
        I could change it to:
        Code:
        TYPE CHART
            ...
            Graph1 AS GRAPH
            Graph2 AS GRAPH
            Graph3 AS GRAPH
            Graph4 AS GRAPH
            Graph5 AS GRAPH
            Graph6 AS GRAPH
            Graph7 AS GRAPH
            Graph8 AS GRAPH
            Graph9 AS GRAPH
            ...
        END TYPE
        but that would imply a lot of re-coding (and would be very ugly)
        Any suggestions?

        Regards
        Peter

        ------------------
        [email protected]
        www.dreammodel.dk

        Comment


        • #5
          Peter,

          You can't insert arrays into UDTs, but you can use arrays of UDTs. Divide your UDT in two parts, one if which is a simple array of GRAPH.

          ------------------
          Rgds, Aldo

          Comment


          • #6
            I've been troubled by the same bug, but managed to turn all UDTs to LOCALs.

            Just an idea, could you try this:

            LOCAL lptr AS LONG PTR

            lptr = VARPTR(ch.graph(1).lpDataY)
            @lptr = VARPTR(expage(0, %W))


            Peter.


            ------------------
            [email protected]
            [email protected]

            Comment


            • #7
              The way I get around it is to initialize storage for arrays
              within UDTs outside of the UDT and then use DIM AT UDT.<address>
              for convenience or address the mem address directly. If you did
              it that way you might not have to restructure the code you're
              using at present.

              Cheers

              Florent

              ------------------

              Comment

              Working...
              X