Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Huge array of variable length strings
#8
As a test, I created the following which works
(Of course _ReadFile$() only works for files up to 2GB, but I already have a filereader function with no limit, so for testing it's okay)

Code: (Select All)
Type fType
  fname As String
  fpath As String
End Type
ReDim Shared f(1 To 1000) As fType
ReDim Shared m(1 To 1000) As _MEM

nfiles& = getFiles("E:\TEMP\test\")
Print nfiles&
End

Function getFiles& (path$)
  n& = 0
  fname$ = _Files$(path$ + "*.*")
  Do While fname$ <> ""
    If Right$(fname$, 1) <> "\" Then
      Print path$ + fname$;
      c$ = _ReadFile$(path$ + fname$)
      Print Len(c$)
      If n& = UBound(f) Then
        ReDim _Preserve f(1 To n& + 1000) As fType
        ReDim _Preserve m(1 To n& + 1000) As _MEM
      End If
      n& = n& + 1
      f(n&).fpath = path$
      f(n&).fname = fname$
      m(n&) = _MemNew(Len(c$))
      _MemPut m(n&), m(n&).OFFSET, c$
    End If
    fname$ = _Files$
  Loop
  ReDim _Preserve f(1 To n&) As fType
  ReDim _Preserve m(1 To n&) As _MEM
  getFiles& = n&
End Function


What would now be the fastest way to textsearch _Mem? There's no _MemSearch or something ....
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Reply


Messages In This Thread
RE: Huge array of variable length strings - by mdijkens - 10-17-2024, 12:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Strings - Numbers Kernelpanic 0 114 01-20-2026, 10:29 PM
Last Post: Kernelpanic
  Array out of passing arrays... Pete 2 407 09-22-2025, 08:53 PM
Last Post: ahenry3068
  Variable length type declarations dano 5 688 08-06-2025, 09:53 PM
Last Post: dano
  Determining if variable or static string is passed to a Sub dano 9 1,222 06-20-2025, 06:31 PM
Last Post: CookieOscar
  Most efficient way to build a big variable length string? mdijkens 9 1,883 01-17-2025, 11:36 PM
Last Post: ahenry3068

Forum Jump:


Users browsing this thread: 1 Guest(s)