Announcement

Collapse
No announcement yet.

Array (Insert,Delete)

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

    Array (Insert,Delete)

    Hello Everyone,

    Can somebody explain to me some of the pitfalls in using ARRAY INSERT and DELETE with UDTs. I also would like to know why ARRAY INSERT and DELETE do not resize the array.

    ------------------
    Cheers!

    #2
    simply put you can't use udt's
    see http://www.powerbasic.com/support/pb...ad.php?t=18113

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

    Comment


      #3
      originally posted by john petty:
      simply put you can't use udt's
      yes you can john.
      mark, check out this post: http://www.powerbasic.com/support/pb...ad.php?t=18125
      kind regards
      eddy



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

      Comment


        #4
        Eddy, that is not quite the same discussion...

        In a nutshell, you can use the ARRAY statement on arrays in a UDT as long as you use DIM..AT to create a normal array at the same location of memory as the UDT member array. The 1st reply points to an example of this.


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

        Comment


          #5
          Hey Guys,

          Thanks for the reply's but this is what I'm really after. Is the following "legal" are there any know bug's in this method?


          Code:
          type RECORD_STRUCT
              lPointer as long
              wUpdated as word
              wDeleted as word
          end type
           
          
          global Record() as RECORD_STRUCT
           
          
          function DeleteRecord(byval lRow as long) as long
              local lCount as long
           
          
              lCount = ubound(Record)
              decr lCount
           
          
              array delete Record(lRow)  rem Will this work?
              redim preserve Record(lCount)
              function = min(lRow,lCount)
          end function
           
          
          function pbmain as long
              local lRow as long
           
          
              redim Record(100)
           
          
              lRow = DeleteRecord(20)
          end function
          I know there is a problem with ARRAY INSERT when used with UDT arrays so does the same apply for ARRAY DELETE ?

          ------------------
          Cheers!



          [This message has been edited by mark smit (edited April 25, 2001).]

          Comment


            #6
            ARRAY DELETE is 100% fine - there have been ZERO problem reports!

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

            Comment

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎