Mid$ is extremely slow with larger strings (a lot of memcopy is going on)
Instr is extremely efficient in finding next hit in memory
Strings have a limit of 2GB max and since Instr only works on strings, the startpos and returnval are Long (-2G to +2G)
_Mem can handle size of your PC's RAM
Instr is extremely efficient in finding next hit in memory
Strings have a limit of 2GB max and since Instr only works on strings, the startpos and returnval are Long (-2G to +2G)
_Mem can handle size of your PC's RAM
Code: (Select All)
Const MAXSIZE = 2 ^ 31 - 1 '2GB
Dim a As String: a = String$(MAXSIZE, 0)
Asc(a, MAXSIZE) = 42
aa& = InStr(a, Chr$(42))
Print Len(a), InStr(a, Chr$(42)), aa&
Dim b As String * MAXSIZE
Asc(b, MAXSIZE) = 42
bb& = InStr(b, Chr$(42))
Print Len(b), InStr(b, Chr$(42)), bb&
Const MSIZE = MAXSIZE * 5 '10GB
Dim m As _MEM: m = _MemNew(MSIZE) '10GB
Dim c As String * 1: c = Chr$(42)
_MemPut m, m.OFFSET + MSIZE - 1, c
Print m.SIZE,
Dim block As String * MAXSIZE
For p&& = 0 To m.SIZE \ MAXSIZE
b = _MemGet(m, m.OFFSET + p&& * MAXSIZE, String * MAXSIZE)
mm& = InStr(b, c)
If mm& Then Exit For
Next p&&
Print m.SIZE, p&& * MAXSIZE + mm&
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience

