Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: unlimited function-parameters?

  1. #11
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,544
    Rep Power
    172
    incredibile!

    Why not "Array" instead of "Any" - it's one...
    I think there are missing some Forum-sections as beta-testing and support

  2. #12
    Without a formal UBOUND, The easiest way for Oxygen to emulate this mode of param passing would be:

    function fun(double*d, sys n)
    sys i

    for i=1 to n
    ' d[i] ...
    next
    end function


    double d={1,2,3,4,5,.6,.7,.8}
    fun d, countof d

  3. #13
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,544
    Rep Power
    172
    i'm trying but trying to call a type-function always Errors, unbalanced parentheses, my test won't run
    Uses "Console"
     
    Type t_Test
      X   As Long
      fun As Function
    
    End Type
    
    Function t_Test.fun(ByVal l(Any) As Long) 
    
    End Function
    
    Dim x As t_test
    
    x.fun((1,2,3))
     
     
    WaitKey
    
    I think there are missing some Forum-sections as beta-testing and support

  4. #14
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,793
    Rep Power
    10
    Sorry Rene but so far it is only for standard functions.
    Give me few days and I will extend much more.
    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

  5. #15
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,793
    Rep Power
    10
    Sorry again Rene, it was just a matter of ... minutes
    Attached a new thinCore.dll

    Here a working example:
    Uses "Console"
    
    
    Function Variadic1(FirstVariadicParam(Any) As Ext, sBuffer As String) As Long
      PrintL "From inside " & Function_Name
      PrintL "Variadic parameter 'FirstVariadicParam' number of elements:", UBound(FirstVariadicParam)
      PrintL "----------------------------------------------------------------------------"
    
    
      PrintL "Listing all values:"
      For lCount As Long = 1 To UBound(FirstVariadicParam)
        PrintL " - Element", lCount, "has value of", FirstVariadicParam(lCount)
      Next 
      PrintL
      
      Function = UBound(FirstVariadicParam)
    
    
    End Function
    
    
    Type t_Test
      X   As Long
      fun As Function
    End Type
     
    Function t_Test.fun(ByVal l(Any) As Long) 
      PrintL "From inside " & Function_Name
      PrintL "Variadic parameter 'FirstVariadicParam' number of elements:", UBound(l)
      PrintL "----------------------------------------------------------------------------"
    
    
      PrintL "Listing all values:"
      For lCount As Long = 1 To UBound(l)
        PrintL " - Element", lCount, "has value of", l(lCount)
      Next 
      PrintL
      
      Function = UBound(l)
     
    End Function
     
    Dim x As t_test
     
    x.fun((1,2,3))
    
    
    
    Randomize Timer
    '---Because first parameter is variadic, pass any number of numeric expressions in surrounding round brackets
    PrintL "Function exit value", Variadic1((123, 456, 789, Sin(Rnd), Cos(Rnd)), "ABCDE")
    
    
    WaitKey
    
    I'm going to bed now: today I just did 14 working hours, I'm really tired
    Attached Files Attached Files
    Last edited by ErosOlmi; 22-10-2014 at 23:47.
    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

  6. #16
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,544
    Rep Power
    172
    OK, thanks once more. Sleep well.


    Perhaps you can look over the array-scan - theres still some problem with continous scan- returns wrong numbers

    http://www.thinbasic.com/community/showthread.php?12459-ARRAY-ideas&p=91572#post91572

    and have a look into support-section too please.


    Now this my unlimited multidimensional layover-example upon some array at heap (fits the tB-structure up to 3 dimensions if 1-based), needs the units below and the thincore from above.
    Uses "console"
    ' needs 1.9.14 + latest thincore.dll
     
    #INCLUDE "Heap_Array.tBasicU"
     
    
    Function TBMain()
      
      
      Local harry As Heap_Array
      
      Local Bounds(3) As Dimensions  
      
      ' want 3 dimensional grid of pointers, 1-based
      
      Bounds(1).LoBound = 1 : Bounds(1).HiBound =  2
      Bounds(2).LoBound = 1 : Bounds(2).HiBound =  4
      Bounds(3).LoBound = 1 : Bounds(3).HiBound =  6
      
      ' call to allocate and set up the dimensions at once
      harry.PtrsAlloc( harry.BoundsBe( Memory_Get(VarPtr(Bounds(1)), SizeOf(Bounds)) ))
      
      ' place a 
      Local lPtr As DWord At harry.ElementPtr(( 1,2,3 )) 
      
     ' load the lPtr with data
      lPtr = HEAP_AllocByStr("i test 1,2,3")
      
      SetAt( lPtr, harry.ElementPtr(( 2,1,5 )) )
      lPtr = HEAP_AllocByStr("i test 2,1,5")
                                   
      SetAt( lPtr, harry.ElementPtr(( 2,4,6 )) )
      lPtr = HEAP_AllocByStr("i test 2,4,6")
                                   
      ' now place standarc-tb-array upon
       
      Local test(2,4,6) Like harry.Layover() At harry.DataPtr
       
      PrintL HEAP_Get(test(1,2,3))
      PrintL HEAP_Get(test(2,1,5))
      PrintL HEAP_Get(test(2,4,6))
      
      PrintL $CRLF & "-----------------------key to end"
      WaitKey
      
    End Function
    
    Attached Files Attached Files
    Last edited by ReneMiner; 23-10-2014 at 00:12.
    I think there are missing some Forum-sections as beta-testing and support

  7. #17
    Member
    Join Date
    Nov 2012
    Location
    Missouri, USA
    Posts
    113
    Rep Power
    29
    Eros,

    The new thinCore.dll you posted, is it to replace the one
    that is in the root of the thinAir sub-directory? I one
    there is 1,293,824 bytes. Your new one is only 171,008
    bytes.

    The reason I ask, is that thinBasic did not install a
    thinCore.dll in my thinBasic's root directory as you indicate
    on Page-1.

    Help,

    Bill
    Last edited by Billbo; 23-10-2014 at 01:30.

  8. #18
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,793
    Rep Power
    10
    Hi Bill,

    inside \thinBasic\ThinAir\ directory there is a special version of thinCore.dll specifically designed to be used only by thinAir.
    Do not touch content of that directory.

    To test thinCore.dll attached into this post, replace the one you have into \thinBasic\ directory.

    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

  9. #19
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,544
    Rep Power
    172
    Just once more i want to say this is a great feature - really happy that you made this possible Eros.

    Still thinking about some similar reverse-operation so a function can pass a variadic result back.

    Currently it works alike this
    (use is mostly for creating a list of items that meet certain conditions which is just needed once - else i store the list at heap and return the pointer)

    Type t_Item
      isVisible As Boolean
    End Type
    
    Function ListVisibleItems( Byval ItemID(Any) As Long ) As String
    
    Local i As Long
    Local sResult As String
    
    For i = 1 to Ubound(ItemID)
      If myItem(ItemID(i)).isVisible Then
        sResult += MKL$(ItemID(i))
      Endif
    Next
    Function = sResult
    
    End Function
    
    Dim myItem(100) As t_Item
    '...assume a few items set visible, a few are not
    
    String sVisible = ListVisibleItems((1,2,3,4,5,6,9,14,22,23,24,31,16))
    
    Local lVisible(StrPtrLen(StrPtr(sVisible))/SizeOf(Long)) As Long At StrPtr(sVisible)
    
    ' now lVisible() contains all visible items of the list i passed.
    

    how would that work?
    Dim lVisible(Any) As Long = ListVisibleItems((1,2,3,4,7,8,43,55))
    
    ReDim lVisible(Any) = ListVisibleItems((5,6,7,8,22,33,43,44,45,57,58))
    ' ???
    Redim lVisible(Any) = "" ' sets Ubound(0) - would be essential - complicated? :(
    
    Dim myPlaylist(Any) As mp3FileInfo = File_Load("c:\myPlaylist.dat")
    
    i think it's complicated ...

    but perhaps we can live with the current available methods for the meantime and focus on something else then.
    Last edited by ReneMiner; 23-10-2014 at 15:37.
    I think there are missing some Forum-sections as beta-testing and support

  10. #20
    Member
    Join Date
    Nov 2012
    Location
    Missouri, USA
    Posts
    113
    Rep Power
    29
    Eros,

    Thank you for the clarification. But, you did not
    address the thinCore.dll not installing on my
    computer. So;

    I renamed my thinBasic directory and re-installed
    1.9.14.0. This time it installed. Not only that, but
    two other files installed in the thinBasic root
    directory: thinBasic.exe and thinBasicc.exe. They
    were not in my previous directory(??). How has
    my thinBasic been running without them. And,
    if it has been running okay, why are they needed?

    I hope I am not asking stupid questions. I am 68
    and I feel that if I don't ask questions and learn
    something everyday, the day is wasted.

    Thanks, Again,

    Bill

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Multidimensional indexing in unlimited dimensions
    By ReneMiner in forum General purpose scripts
    Replies: 1
    Last Post: 01-12-2015, 21:52
  2. Sub/Function-Optional-parameters
    By ReneMiner in forum Fixed or cleared errors in help material
    Replies: 6
    Last Post: 16-06-2013, 11:28
  3. Do you know: Passing UDT parameters
    By dcromley in forum Do you know ...
    Replies: 1
    Last Post: 28-04-2009, 22:09
  4. Default values for function parameters
    By ErosOlmi in forum thinBasic vaporware
    Replies: 2
    Last Post: 19-06-2007, 10:20

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
  •