Page 3 of 3 FirstFirst 123
Results 21 to 22 of 22

Thread: some arrays goodies

Share/Bookmark
  1. #21
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,718
    Blog Entries
    3
    Rep Power
    684
    Hi,

    primo basically nailed the stringBuilder usage, here a little example:
    Uses "console", "stringBuilder"
     
    ' this will store the numbers:
    Dim builder as new StringBuilder()
     
    ' access the numbers virtually:
    Dim myNumber() as Number At 0
     
    Dim i As Long ' just to list our arrays elements
     
    ' add a few elements, type Ext equals Number, that's why MKE$:
    builder.Add(MKE$(0.12345)) ' the first element be 0.12345
    ' just append a bunch of new elements:
    builder.Add(MKE$(1,2,3,4,5))
    ' and some more
    builder.Add(MKE$(6.666, 7.777))
     
    ' now let's read what we have:
    ' put the virtual array onto the string:
    string builderData = builder.ToString() 
    Redim myNumber(Strptrlen(Strptr(builderData))/SizeOf(Number)) At Strptr(builderData)
     
    ' list what we have
    For i = 1 to UBound(myNumber)
      PrintL i, myNumber(i)
    Next
     
    WaitKey
    
    I may add direct pointer to string in stringBuilder as functionality, if there is interest. That would skip the step with assignment to temporary string variable, making it even faster


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  2. #22
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,063
    Blog Entries
    2
    Rep Power
    10
    Quote Originally Posted by Petr Schreiber View Post
    I may add direct pointer to string in stringBuilder as functionality, if there is interest
    It would be great.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Page 3 of 3 FirstFirst 123

Similar Threads

  1. 3d arrays?
    By JosephE in forum thinDebug
    Replies: 2
    Last Post: 08-08-2010, 23:21
  2. Arrays
    By Charles Pegge in forum O2h Compiler
    Replies: 0
    Last Post: 17-03-2009, 16:09

Posting Permissions

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