Results 1 to 1 of 1

Thread: Type_Exists(sType) ?

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

    Type_Exists(sType) ?

    as topic says i try to get a function together that tells me if String sType contains the name of a valid type/udt. Simply trying to dim something like sType always results in an error if sType contains an invalid type. But that's not the intention for this "request".

    it's more like
    Type t_Type
      A As Byte
      
      GetA   As Function
      SetA   As Function  
      GetB   As Function
      SetB   As Function  
      '...
      
    End Type  
    
    Type t_Type_Private Extends t_Type
      B As Byte
    End Type
    
    Function t_Type.GetA() As Byte  
      
      If Type_Exists( Me.Typename & "_Private" ) Then
        Local RealMe Like Me.Typename & "_Private" At VarPtr(Me)
      Else
        Local RealMe Like Me.Typename At VarPtr(Me)
      EndIf
       
      Function = RealMe.A
    End Function
    
    '...
    
    Assume Me.Typename would return/contain "t_Type" here...

    of course this approach won't work with somehow dimensioned variables since i can not return the base-type only while in reality the variable is the extended type...
    but works pretty well when using absolute variables on heaped data and some special way of "dimensioning"
    Last edited by ReneMiner; 22-08-2014 at 15:00.
    I think there are missing some Forum-sections as beta-testing and support

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
  •