Announcement

Collapse
No announcement yet.

Reset UDT in an array?

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

  • Reset UDT in an array?

    Hello All...

    I just tried the following line and found that it didn't work, Would anybody also like to see this added to the next release?

    Code:
    type USERDATA
      dataname as asciiz * 257
      datasize as long
    end type
    
    dim user(%MAXUSERS) as USERDATA
    
    reset user(0) <- This does not seem to work...?
    This would be a great feature to have because it would allow a programmer to clear a UDT array element with one line rather than having to clear all the members one at a time. According to the help file you can clear a UDT though!


    -------------
    Cheers

  • #2
    LSET UDT(0) = STRING$(LEN(UDT(0)), 0)

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

    Comment


    • #3
      Thanks Lance!

      I figured that much out but i still think it would be nice to have this feature in PBDLL/PBCC.



      ------------------
      Cheers

      Comment


      • #4
        RESET is likely to be made to work with scalar variables in a future version of the compiler, but not individual array subscripts.

        However, I'll suggest this idea to R&D. Thanks!



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

        Comment


        • #5
          What about API ZeroMemory ?

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

          Comment


          • #6
            There are quite a few ways available to the programmer to clear a UDT or other block of memory:

            LSET, ZeroMemory(), POKE$, use of pointers, DIM...AT, etc.

            However, the request was for a single native BASIC statement to do the job.

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

            Comment


            • #7
              Lance --
              I am about perfomance.
              Somebody tried to compare (depends of size)?

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

              Comment

              Working...
              X