Results 1 to 6 of 6

Thread: Easier way to populate arrays!

  1. #1

    Thread Starter
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243

    Unhappy

    Hi,
    I have a multi-dimensional array (3,24,37) that needs to be populated. Is there an easier way to do it than by doing it one at a time ie. a(1,1,1) = 25, a(1,1,2) = 36 etc... I dont want to use a database or anything external because I want the dll to be selfcontained.

    Is there a way to use the Array function or does this only work with a single dimension array??

    Thanks in advance

    Shaun

  2. #2
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    Are you using a FOR/NEXT loop?

    Or is that a stupid Question?

    DocZaf
    {;->

  3. #3
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    Wink

    yeah, populate it at runtime, use loops.

  4. #4

    Thread Starter
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Sorry but I cant do that that. What it is going to be is a Function that takes a couple of parameters and then returns a number that is looked up in the array. This is then going to be compiled into a DLL as it needs to be included in a couple of programs. What I was looking for (if anybody knows how to do it) is a sort of 'READ' function where it reads data values and populates arrays in one go like there used to be in old BASIC ie:

    Code:
    For i = 1 to 10 then
       read iData
       myArray(i) = iData
    Next i
    
    Data 5,8,12,56,34,23,54,66,33,5
    as this would be far easier than going:
    Code:
    MyArray(1,1,1) = 23
    .....
    MyArray(3,26,37) = 800
    Any comments would be appreciated (even if it is to tell me that it can't be done a quick way!!)

    Cheers, Shaun

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I think you could have your data stored in a file, binary. You could write an app so that you can populate the array or you could do it directly in immediate window.
    Code:
    Dim ff as integer
    ff=freefile
    'To write
    Open Filename for binary as ff
     put #ff,, myarray
    close ff
    
    'To read
    Open Filename for binary as ff
     get #ff,, myarray
    close ff
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6

    Thread Starter
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Cheers,
    I have already done it now (all 2886 values!!!!). I will look into different ways of doing it though.

    Thanks,
    Shaun.

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