Arrays of any size

Discussion in 'Code Samples & Tips' started by Gale Johnson, Aug 15, 2007.

  1. Gale Johnson

    Gale Johnson Member Licensed User

    Perhaps this is elementary, but I needed very large arrays of information for my program. I put all the information in a single-dimension array and then strip the parts out when needed.
    Example: ser="12b*3a4*5n6*78y*9ab2nm*"

    dim a(5)
    For x=1 to 5:g1=Strindexof(ser,"*",h1)
    h1=g1+1:next x
  2. moharj

    moharj Member Licensed User

    indexes start from 0 , try
  3. Rioven

    Rioven Active Member Licensed User

    yes, a(x-1) works for Dim a(5)

    for me as an alternative approach, If it is large or varying handling data memory assignments, maybe I'll try the method that the code will create file as data memory which it could arrange and simplify informations, then access and manipulate by read and write in this file. Not sure if applicable to your program.
  4. Erel

    Erel Administrator Staff Member Licensed User

    Creating a long string takes (almost) as much memory as creating an array of substrings.
    The overhead of this approach could be pretty large.
  5. Rioven

    Rioven Active Member Licensed User

    Thanks Erel, bit :sign0006:but if I wan't to store large random data, Is it efficient using binary files? or what is the right method?
  6. Erel

    Erel Administrator Staff Member Licensed User

    It depends on the type of the data.
    If you save only numbers then random files are the best solution.
    That is because you can easily calculate the position of each value (NumberOfBytes * Index).
    However strings do not have a fixed size so it is much more complicated to find the position of each value, making it less useful in that case.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice