Announcement

Collapse
No announcement yet.

LARGEST UDT ARRAY

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

  • LARGEST UDT ARRAY

    Sorry, I posted this the first time as a reply and not a
    new topic.

    Help with maximum size of UDT array

    I'm trying to create a database that has 215264 records and will
    grow to about 250000.

    I have a UDT type which has 16 internal fields which are all
    strings, the length of the UDT is 128 bytes.

    My program is reading in then string A$ from the clients
    original file of 215264 records.

    Each A$ is then converted into the different fields of the
    UDT as follows:
    global array is rec() as poledata

    Code:
    x&=0
    DO
      line input #1,a$
      if len(a$) > 35 then
      incr x&:redim preserve rec(1 to x&)
      'build rec(x&).
      rec(x&).record=
      rec(x&).etc
      rec(x&).etc
      end if
    loop while not eof(1)
    
    using the udt() array error out on the 46015 records with
    error 7
    x&=0
    DO
      line input #1,a$
      if len(a$) > 35 then
      incr x&:redim preserve rec(1 to x&)
      'build wrec(x&).etc
      ' wrec(x&).record=whatever
      ' wrec(x&).etc=whatever 
      end if
    loop while not eof(1)
    
    using wrec$() array will load all 215264 records
    x&=0
    DO
      line input #1,a$
      if len(a$) > 35 then
      incr x&:redim preserve wrec$(1 to x&)
      'build wrec$(x&)
      'wrec$(x&) is created as 128 byte string
      end if
    loop while not eof(1)
    ------------------


    ------------------
    E-Mail: [email protected]
    E-Mail:
    pt AT pursuersoft DOT com

  • #2
    If you are running on Win9x, you are running into the "out of memory" error mentioned in several other posts.

    When you REDIM preserve, you are allocating the memory each time through.

    There's no need to REDIM PRESERVE on each record. You can get the number of records before you load the data:

    Code:
    ' load whole file into A$..
    Numrecs = TALLY(a$, CHR$(13))  ' each record in input is terminated by CRLF if a text file
    REDIM rec(1 to numrecs) AS recType
    
      ' Load one by one or whatever
    It's even easier if your input file consists of fixed-length records:
    Code:
    Numrecs = LOF(#1) \ %INPUT_FILE_RECORD_LENGTH
    MCM


    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    mmatt[email protected]
    http://www.talsystems.com

    Comment

    Working...
    X