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



Users browsing this thread: 1 Guest(s)