Results 1 to 10 of 67

Thread: Release the beast: Get$/Set$/GetPtr

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    55
    Posts
    1,554
    Rep Power
    174
    I see.

    I had to remove the older version since I discovered that ByRef passed UDT-subsets seem not to work, so there are some new functions and also some new syntax to some existing functions. Now these functions await an address where to find/store the pointer - these functions names end with "At" now.
    StrLen-Function still inside - attention that works only on String/String-Array but not on strings which are subsets of an UDT.

    Also Set$ I changed to SetStr since it does not return a string. Same applies to SetUdtStr. Mainly the functions work still the same way as described above, a few have been exchanged:

    Some demonstration code that shows usage of heap as dynamic UDT-subsets
    Heap_SetAt
    Heap_AppendAt

    Uses "Console"
    #INCLUDE "lazyFun.tBasicU"
     
    Type t_type
      S1 As DWord
      S2 As DWord
    End Type
    
    Type t_Subtype
      A As Long
      B As Byte
      C As Double
    End Type
    
    Dim foo(3) As t_type  
    Dim dummy As t_Subtype
    Dim i As Long
    
    For i = 1 To 3
     ' now tell foo(2).S1 to hold something:
    
      dummy.A += 12
      dummy.B += 3
      dummy.C += 4.5
      Heap_AppendAt(VarPtr(foo(2).S1), Memory_Get(VarPtr(dummy), SizeOf(t_Subtype)) )
      
    Next i
    ' retrieve data:
    Dim dArray(HEAP_Size(foo(2).S1)\SizeOf(t_SubType)) As t_SubType At foo(2).S1
    
    For i = 1 To UBound(dArray) 
     ' PrintL "element" + Str$(i)
      PrintL "A:" + dArray(i).A
      PrintL "B:" + dArray(i).B
      PrintL "C:" + dArray(i).C
      PrintL
    Next 
    
    PrintL $CRLF + "key to continue" + $CRLF
    WaitKey
    
    dummy.A = 77
    dummy.B = 77
    dummy.C = 77
    
    PrintL $CRLF + "now insert new element 2"
    
    Heap_ElementInsertAt(VarPtr(foo(2).S1), 2, Memory_Get(VarPtr(dummy), SizeOf(t_Subtype)) ) 
    
    ReDim dArray(HEAP_Size(foo(2).S1)\SizeOf(t_SubType)) As t_SubType At foo(2).S1
    
    For i = 1 To UBound(dArray) 
     ' PrintL "element" + Str$(i)
      PrintL "A:" + dArray(i).A
      PrintL "B:" + dArray(i).B
      PrintL "C:" + dArray(i).C
      PrintL
    Next 
     
    PrintL $CRLF + "key to continue" + $CRLF
    WaitKey
     
    PrintL "new use of Heap_SetAt"
    
    Heap_SetAt VarPtr(foo(3).S2), "this is important"
    PrintL Heap_Get$(foo(3).S2)
    ' - - - - - - 
    String fish
    PrintL $CRLF + "new : SetStr (replaces Set$ since does not return string)"
    SetStr "fish", "apple juice"
    PrintL Get$("fish")
    PrintL 
    Dword myPtr = GetPtr "fish"
    PrintL StrAtPtr$ myPtr
    PrintL
    PrintL fish
      
    PrintL $CRLF + "key to end" + $CRLF
    WaitKey
    
    EDIT:
    Functions-Overview version 0.42 - find a link to the latest version there

    This attachements is an older version to run the posted examples before 12-08-2013.
    MinVersion 1.9.7.0
    Functions-Overview version 0.35
    FileVersion 0.35, 07-08-2013
    Attached Files Attached Files
    Last edited by ReneMiner; 13-08-2013 at 16:05.
    I think there are missing some Forum-sections as beta-testing and support

Similar Threads

  1. Release of Aung San Suu Kyi
    By Charles Pegge in forum Shout Box Area
    Replies: 0
    Last Post: 13-11-2010, 14:23
  2. TAB Alpha Release 35
    By catventure in forum T.A.B. (ThinBasic Adventure Builder)
    Replies: 4
    Last Post: 08-07-2008, 18:34
  3. TAB Alpha Release 24
    By catventure in forum T.A.B. (ThinBasic Adventure Builder)
    Replies: 2
    Last Post: 22-03-2007, 00:37
  4. TAB Alpha Release 23
    By catventure in forum T.A.B. (ThinBasic Adventure Builder)
    Replies: 46
    Last Post: 21-03-2007, 19:02
  5. TAB Alpha Release 22
    By catventure in forum T.A.B. (ThinBasic Adventure Builder)
    Replies: 24
    Last Post: 08-03-2007, 13:58

Members who have read this thread: 0

There are no members to list at the moment.

Tags for this Thread

Posting Permissions

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