Results 1 to 7 of 7

Thread: Large arrays

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    11

    Question

    I have a large four-dimensional array in my game and I need the most efficient way of saving/loading it possible. I am currently using four For..Next loops but I'm sure there's a faster way. Anyone?

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Sure
    Code:
    Dim Array() as Whatever
    Dim Size as Long
    Dim FileNum as Integer
    
    Sub Form_Load()
       size = 100000
       Redim array(size)
    End Sub
    
    Save(FileName as string)
       Filenum=freefile
       Open filename for binary as filenum
          put filenum,,size
          put filenum,,array
       close filenum
    end sub
    
    Save(FileName as string)
       Filenum=freefile
       Open filename for binary as filenum
          get filenum,,size
          redim array(size)
          get filenum,,array
       close filenum
    end sub
    have fun

  3. #3
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Saving it to a file? Well just do this:

    Code:
    Open strFileName For Binary As #1
        Put #1, , ReallyBigArray
    Close #1
    You don't have to use loops, just stick the whole thing in like that.
    Harry.

    "From one thing, know ten thousand things."

  4. #4
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Wink

    I was faster

  5. #5
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    Talking

    *D'oh*

    Hehe
    Harry.

    "From one thing, know ten thousand things."

  6. #6
    Member
    Join Date
    Aug 2000
    Location
    USA
    Posts
    32

    Just wondering ...

    What exactly are you using this four-dimensional array for?
    -Koralt

  7. #7
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Originally posted by Fox
    Sure
    Code:
    Dim Array() as Whatever
    Dim Size as Long
    Dim FileNum as Integer
    
    Sub Form_Load()
       size = 100000
       Redim array(size)
    End Sub
    
    Save(FileName as string)
       Filenum=freefile
       Open filename for binary as filenum
          put filenum,,size
          put filenum,,array
       close filenum
    end sub
    
    Save(FileName as string)
       Filenum=freefile
       Open filename for binary as filenum
          get filenum,,size
          redim array(size)
          get filenum,,array
       close filenum
    end sub
    have fun
    You have 2 Save functions in your code. The 2nd one should be Open.
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width