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

Thread: Array Left$

  1. #21
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    i think it's ok to have the result in a common dynamic string-array- mostly local within a function anyway.

    It's up to the user now to pass the whole array to another function or to store it @heap if needed
    Last edited by ReneMiner; 01-11-2015 at 00:28.
    I think there are missing some Forum-sections as beta-testing and support

  2. #22
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Added PTR version of ARRAY EXTRACT in public 1.9.16.x

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #23
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171

    Into

    regarding new Keyword Into:

    i like how it reads... and it's very clear what it does.

    In a certain sense it's the reverse operation to variadic function-parameters...


    Can we have Into useable for tB-script-functions too
    Byref passed array-variable that can be dimensioned locally on the fly ?

    Example
    (tType be any Type of variable or udt)

    '... "Into" could work like "ByRef" here,
    ' but signals an array-variable [with certain dimensions] will follow:
    
    Function putStuff( Into X(~[dim1[, dim2[, dim3]]]~) As tType[, more parameters....]) As Long
    
    ' x be the array-varriable
    
    ' ~[dim1[, dim2[, dim3]]]~ not supposed to be written by the user as in line further above
    '                   = dimensions bounds, 
    
    ' "Into x() As tType" (empty parenthesis, no bounds) will serve,
    ' since Ubound(x, 2) = 0 if x has no 2nd dimension...
    
    ' if passed dim1[, dim2[, dim3]] on the call : (see below)
    '    fixed array size 
    '    or 1-dimensional dynamic, contains already dim1 elements 
    ' else 
    '   x  will be dynamic and contains 0 elements
    ' Endif
    End Function
    
    ' equals:
    Function putStuff( ByRef X() As tType[, more parameters....]) As Long
    
    ' no change necessary, only allow Alias ByRef As Into for this 
    End Function  
    
    ' call :
    
    Long l = putStuff( [Into|Preserve] myData[([dim1[, dim2[, dim3]]])[ As tType]][, more parameters...] )
     ' enable instant (re-)dimensioning and passing ByRef within function-call,
    
    
    ' If <"Into" present> Then
    '   ~~~ make a new, empty barrel for stuff to put into
    '   If variable_exists(myData) Then
    '     Redim myData([dim1[, dim2[, dim3]]])
    '   Else
    '     Dim myData([dim1[, dim2[, dim3]]]) [As tType]
    '   Endif
    
    ' ElseIf Variable_Exists(myData) Then
    '   ~~~ check for valid bounds 
    '    If  Not <"dim3" present> Then
    '      If Ubound(myData, 3) > 0 Then
    '        Long dim3 = Ubound(myData, 3)    ~~~ assume we check for existance later
    '      EndIf
    '      If Not <"dim2" present> Then
    '        If Ubound(myData, 2) > 0 Then
    '          Long dim2 = Ubound(myData, 2)
    '        EndIf
    '        If Not <"dim1" present> Then
    '          If Ubound(myData, 1) > 0 Then
    '            Long dim1 = Ubound(myData, 1)
    '          Endif
    '       EndIf
    '     EndIf
    '   EndIf
    
    '   If <"Preserve" present> Then 
    '    ~~~ obvious  
    '     Redim Preserve myData([dim1[, dim2[, dim3]]])
    '   EndIf
    ' EndIf
    
    ' pass BYREF myData[(dim1[, dim2[, dim3]])][, more parameters...]> to function putStuff(...)
    
    ' finally real code reads as:
    Local numBugs As Long = CollectBugs( Into myBuglist() As String )
    ' now i have a dimensioned - and hopefully empty - local array myBuglist
    
    [post moved over here to keep other thread on topic]
    Last edited by ReneMiner; 11-11-2015 at 18:48.
    I think there are missing some Forum-sections as beta-testing and support

Page 3 of 3 FirstFirst 123

Similar Threads

  1. Idea for LEFT$/RIGHT$ variable that work in reverse
    By Robert Hodge in forum Suggestions/Ideas discussions
    Replies: 6
    Last Post: 30-06-2013, 10:26
  2. TBGL_GetWindowKeyState - left Alt-key sucks
    By ReneMiner in forum TBGL module by Petr Schreiber
    Replies: 1
    Last Post: 23-02-2013, 21:10
  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. Be left in awe :)
    By kryton9 in forum General
    Replies: 8
    Last Post: 19-05-2008, 21:49
  5. Usage of the LEFT$ MID$ RIGHT$ Keywords
    By Michael Clease in forum Samples for help file
    Replies: 1
    Last Post: 28-05-2007, 11:45

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
  •