Results 1 to 6 of 6

Thread: disturbs me for a long time already...

Threaded View

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

    disturbs me for a long time already...

    it's the impossibility to pass udt-elements ByRef, thinBasic will not accept these,
    see here:

    Uses "console"
    
    Function f_byref(ByRef lLong As Long) As Long
    
      Function = lLong                           
                               
    End Function
     
     
    Dim bac As Long = 12345  ' normal variable no problemo
    
    PrintL Str$( f_ByRef( bac ) )
     
    WaitKey
     
    Type t_Test     
      abc As Long
      
    End Type
    
    Dim foo As t_Test
    foo.abc = 123  ' but udt-element gets refused as parameter
    
    PrintL Str$( f_ByRef( foo.abc ) )
                               
    WaitKey
    
    ByRef is of no use for udt-elements, it's not possible to pass them as function-parameters by reference directly
    one always has to do something like this to pass them byRef:

    Uses "console"
    ' either pass a pointer and create a layover in the function:
    
    Function f_byPtr( ByVal pLong As DWord ) As Long
      
      Local lLong As Long At pLong
      
      Function = lLong
    
    End Function
    
    Type t_Test     
      abc As Long
    End Type
    
    Dim foo As t_Test
    foo.abc = 54321
    
    PrintL Str$( f_ByPtr( VarPtr foo.abc ) )
                               
    WaitKey
    
    ' or create layover in advance:
    
    Function f_byref(ByRef lLong As Long) As Long
    
      Function = lLong                           
                               
    End Function
    
    Dim toPass as Long At VarPtr(foo.abc)
     
    PrintL Str$( f_ByRef( toPass ) )
    
    WaitKey
    
    Best would be if udt-elements would be accepted using normal syntax (Byref).


    If that's not possible - however..., why..., i don't care the reason... it could be substituted using ByPtr. Means

    Function myFunc(ByPtr lVar As someType )
    
    the function automatc creates a local layover lVar As someType At passed pointer.

    ByPtr of course awaits a pointer passed ByVal then. It would additionally enable automatic layover at some heap or StrPtr.

    But i would be satisfied already if i could just pass the UDT-element ByRef.
    Last edited by ReneMiner; 31-10-2014 at 12:07.
    I think there are missing some Forum-sections as beta-testing and support

Similar Threads

  1. Long-as pointers, is problem?
    By ReneMiner in forum thinBasic General
    Replies: 5
    Last Post: 30-05-2013, 17:27
  2. How to create a csv file with a time format (UTC time) ?
    By stephenjgray in forum thinBasic General
    Replies: 4
    Last Post: 30-05-2013, 09:29
  3. I wonder how long it takes to make an object.
    By kryton9 in forum Shout Box Area
    Replies: 0
    Last Post: 26-06-2011, 07:32
  4. Long time BASIC programmer now using thinBasic
    By BradleyH in forum Who you are
    Replies: 15
    Last Post: 19-10-2010, 00:37
  5. How to parse a parameter of a LONG type?
    By Michael Hartlef in forum Module SDK (Power Basic version)
    Replies: 7
    Last Post: 27-02-2007, 21:59

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
  •