I just saw this on the docs “This item has been deprecated since version 2019r2 and should no longer be used.
Please use MemoryBlock as a replacement.” while the description is simple, could we have please some examples on how translate that using MemoryBlock , I guess the docs are incomplete in many places I see deprecations but as example old code, it’s little hard for new people to learn this new API thing.
In 2019r1.1, with a string known to be ASCII, I was doing such as:
Dim linlen, dec as integer, line, lines(), c as string
line = lines(i)
linlen = line.LenB
for j = 1 to linlen
c = line.MidB (j, 1) // Get a char
dec = c.AscB () // Get its decimal value
...
Next
In 2019r2 that got changed to:
Var linlen, dec as integer, lines(), c as string, line as memoryblock
line = lines(i)
linlen = line.Size - 1
for j = 0 to linlen
dec = line.Byte (j) // Get the decimal value of a byte
c = Encodings.ASCII.Chr (dec) // See what char that is
...
Next
The rest of the code in the “for j” loop was untouched.
The binary versions InstrB() etc are also great to work with UTF-8 text, becuase in UTF8 you are guaranteed that all characters from 0-127 are the same as in ASCII. Using the binary versions can be much faster.
[quote=461716:@Tim Streater]In 2019r1.1, with a string known to be ASCII, I was doing such as:
Dim linlen, dec as integer, line, lines(), c as string
line = lines(i)
linlen = line.LenB
for j = 1 to linlen
c = line.MidB (j, 1) // Get a char
dec = c.AscB () // Get its decimal value
...
Next
In 2019r2 that got changed to:
Var linlen, dec as integer, lines(), c as string, line as memoryblock
line = lines(i)
linlen = line.Size - 1
for j = 0 to linlen
dec = line.Byte (j) // Get the decimal value of a byte
c = Encodings.ASCII.Chr (dec) // See what char that is
...
Next
The rest of the code in the “for j” loop was untouched.[/quote]
Or
Var Characters() As String = Lines(I).Split("")
For Each C As String In Characters
// All set
Next