Results 1 to 10 of 52

Thread: ARRAY-ideas

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #16
    thinBasic MVPs ReneMiner's Avatar
    Join Date
    Oct 2012
    Location
    Germany
    Age
    55
    Posts
    1,560
    Rep Power
    175
    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
    
    Last edited by ReneMiner; 13-10-2014 at 10:06.
    I think there are missing some Forum-sections as beta-testing and support

Similar Threads

  1. OOP ideas
    By ErosOlmi in forum Suggestions/Ideas discussions
    Replies: 13
    Last Post: 26-08-2013, 20:26
  2. Ideas for dynamic Array-constructor on the fly
    By ReneMiner in forum Suggestions/Ideas discussions
    Replies: 0
    Last Post: 16-07-2013, 08:53
  3. copy array of UDT to another array in one step?
    By ReneMiner in forum thinBasic General
    Replies: 3
    Last Post: 02-11-2012, 01:15
  4. More Ideas
    By peter in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 3
    Last Post: 27-10-2012, 14:47

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •