what am i doing wrong here on Array Scan ?
Uses "console"
' try both, the normal way...
String test1 = MKDWD$(123)
String test2 = MKDWD$(321)
DWord hPtr = HEAP_AllocByStr( test1 & test2 & test1 & test2 & test1 & test2 & test1 & test2)
Dim vPtr(8) As DWord At hPtr
DWord toFind = 123
Long lPos, Index
PrintL "normal scan..."
Do
lPos = Array Scan vPtr(Index+1), Byte(1,4), = toFind
If lPos Then
Index += lPos
PrintL "found", index
EndIf
Loop While lPos
' output i await is found 1, found 3, found 5, found 7...
PrintL "key to continue"
WaitKey
HEAP_Free(hPtr)
' some data to scan for:
'test1 = MKDWD$(123,321)
'test2 = MKDWD$(321,123)
' arrange it in an array
hPtr = HEAP_AllocByStr( MKDWD$( HEAP_AllocByStr(test1), _
HEAP_AllocByStr(test2), _
HEAP_AllocByStr(test1), _
HEAP_AllocByStr(test2), _
HEAP_AllocByStr(test1), _
HEAP_AllocByStr(test2), _
HEAP_AllocByStr(test1), _
HEAP_AllocByStr(test2) _
) )
index = 0
ReDim vPtr(8) At hPtr
PrintL $CRLF & "ptr scan"
Do
lPos = Array Scan vPtr(Index+1) Ptr, Byte(1,4), = MkDwd$(toFind)
If lPos Then
Index += lPos
PrintL "found", index
EndIf
Loop While lPos
' output i await is found 1, found 3, found 5, found 7...
PrintL "key to end"
WaitKey
Bookmarks