Announcement

Collapse
No announcement yet.

$HUGE arrays

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

  • $HUGE arrays

    i'm having some trouble with $huge.

    does it work with global udt arrays?
    does it work pb/dll 2.00 (01-jul-99)?

    according to what i've found in the docs, this shouldn't be a problem.

    if i call DimTest%(64) from vb, i'll get the first msgbox. after that, gpf.
    if i call DimTest% with anything less than 64 - no problems.

    fyi - i have to keep this 16bit...vb3 handles the forms.
    any help would be greatly appreciated. below is a sample fragment.

    thanks
    george


    '///////////////////////////////////////////////////
    $COMPILE DLL "c:\windows\system\test2.dll"
    $HUGE

    Type TestDataType
    A_Str As String * 1024
    B_Int As Integer
    C_Lng As Long
    D_Sgl As Single
    E_Dbl As Double
    End Type
    GLOBAL TestData() As TestDataType
    GLOBAL nRadLines%

    '''''''''''''''''''''''''''''''''''''''
    FUNCTION DimTest(BYVAL Elements%) EXPORT AS INTEGER
    nRadLines% = Elements%

    IF nRadLines% > 0 THEN
    DIM TestData(1 to nRadLines%) AS GLOBAL TestDataType
    tmpstr$ = Format$(UBound(TestData))
    MsgBox tmpstr$

    ARRAY SORT TestData(), ASCEND
    MsgBox "Sorted?"
    END IF

    FUNCTION = nRadLines%
    END FUNCTION


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

  • #2
    Change DIM TestData to REDIM TestData in the Function, and change
    ARRAY SORT TestData() to ARRAY SORT TestData(1). Should work.

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

    Comment


    • #3
      Borje Hagsten:

      i tried your suggestion...unfortunately it did not work.
      the results were the same: 1st msgbox, then gpf

      thanks
      george


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

      Comment


      • #4
        George,

        If the Global TestData() has been initialized with data from
        elsewhere in your program, you are losing that data with DIM
        or REDIM. With DIM AND REDIM alone there will be no data to sort.

        Since you have made TestData() Global, you need to do one of
        two things, Either REDIM PRESERVE TestDATA(x) as xxxxxxx
        or pass Testdata() to the function.

        Phil




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


        [This message has been edited by Phil Tippit (edited July 29, 2000).]
        E-Mail:
        pt AT pursuersoft DOT com

        Comment


        • #5
          Phil:

          the data does get initialized elsewhere
          (it's just stripped out right now).

          regardless of whether the array contains any 'data',
          i don't think that the gpfs should occur.

          anyhow, i modified the function to create test data before the sort.
          net result: gpf on the sort

          george



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

          Comment


          • #6
            George

            I often use ARRAY SORT for all sorts of exotic things and I've
            never yet had it GPF on me.

            While everything's possible please post a compilable sample
            which produces the GPF - without a compilable snippet demonstrating
            the problem we're just fumbling in the dark

            Cheers

            Florent

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

            Comment


            • #7
              At a more careful look, I see the total size of your declared
              TYPE is 1042 bytes. 64 x 1042 = 66688, which seems to be more
              than ARRAY SORT can handle in the 16-bit environment.

              A fix that seems to work is to lift out the string member and
              declare and sort it separately, as a dynamic array, like:
              Code:
              GLOBAL A_Str() As String
              
                IF nRadLines% > 0 THEN
                  REDIM TestData(1 to nRadLines%) AS GLOBAL TestDataType
                  REDIM A_Str(1 to nRadLines%) AS GLOBAL String
                  
                  tmpstr$ = Format$(UBound(TestData))
                  MsgBox tmpstr$ 
              
                  ARRAY SORT A_Str(1), ASCEND, TAGARRAY TestData()
              
                  MsgBox "Sorted?" 
                END IF
              I tested this with 16384 items and it worked fine (16384 is
              the max number of items ARRAY SORT can handle in Win 3.x)


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


              [This message has been edited by Borje Hagsten (edited July 29, 2000).]

              Comment


              • #8
                I've always gotten gpf's when I tried using arrays in global
                udt's. They seem to happen at random intervals and for no reason.
                The gpf's usually are regarding stack errors.

                I tried explaining it to support back in version 5.0,
                but I couldn't adequately describe the problem, and my app was
                far too large to expect them to debug.

                I have seen other members describe problems with global udt's.
                I hope PowerBasic finds a fix, but in the mean time, I recommend
                avoiding their use.

                ------------------
                Thanks,

                John Kovacich
                Ivory Tower Software

                Comment


                • #9
                  John, to be clear, I'm sorry to say that you are not comparing apples with apples here... this thread is discussing the 16-bit compiler, and the discussions you refer to affect the 32-bit compiler in certain circumstances.

                  And JFYI, the problem with arrays in global UDT arrays *will* be fixed in the next update to the compiler.

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

                  Comment


                  • #10
                    lance:

                    any idea when an updated compiler (16bit) can be expected?

                    thanks
                    george


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

                    Comment

                    Working...
                    X