Code-Beispiel
Variant.bi
Lizenz: | Erster Autor: | Letzte Bearbeitung: |
WTFPL | MOD | 23.11.2013 |
Umsetzung des Datentyps 'Variant' für FB.
>>Download des Codes und weiterer Beispielcodes<<
'Variant in FB
'20131123
'########################################################################################
#Ifndef memcpy
Function memcpy(destination As UByte Ptr, source As UByte Ptr, num As UInteger) As UByte Ptr
'Ersatz für "crt/string.bi"
'Prüft nicht nach der Größe von Destination
For i As Integer = 0 To num - 1
destination[i] = source[i]
Next
Return destination
End Function
#EndIf
'########################################################################################
Type Variant
Private:
wert As UInteger Ptr 'Pointer zum echten Datenblock
variante As Integer 'Typ der hinterlegten Daten
strLength As Integer 'Länge der Daten
size As Integer 'Größe des allozierten Speichers
Public:
Declare Constructor
Declare Constructor (x As Integer)
Declare Constructor (x As Double)
Declare Constructor (x As String)
Declare Constructor (x As Variant)
Declare Destructor
Declare Property Get As Any Ptr
Declare Property Get(ByRef x As Integer) As Integer
Declare Property Get(ByRef x As Double) As Double
Declare Property Get(ByRef x As String) As String
Declare Property Set(ByRef x As Integer)
Declare Property Set(ByRef x As Double)
Declare Property Set(ByRef x As String)
Declare Property Set(ByRef x As Variant)
Declare Function Getter As Integer
Declare Function getRealType As String
Declare Function leng As Integer
Declare Operator Cast As Integer
Declare Operator Cast As Double
Declare Operator Cast As String
Declare Operator += (ByRef x As Integer)
Declare Operator += (ByRef x As Double)
Declare Operator += (ByRef x As String)
Declare Operator += (ByRef x As Variant)
Declare Operator -= (ByRef x As Integer)
Declare Operator -= (ByRef x As Double)
Declare Operator -= (ByRef x As String)
Declare Operator -= (ByRef x As Variant)
Declare Operator *= (ByRef x As Integer)
Declare Operator *= (ByRef x As Double)
Declare Operator *= (ByRef x As String)
Declare Operator *= (ByRef x As Variant)
Declare Operator /= (ByRef x As Integer)
Declare Operator /= (ByRef x As Double)
Declare Operator /= (ByRef x As String)
Declare Operator /= (ByRef x As Variant)
Declare Operator \= (ByRef x As Integer)
Declare Operator \= (ByRef x As Double)
Declare Operator \= (ByRef x As String)
Declare Operator \= (ByRef x As Variant)
Declare Operator Let(ByVal x As Integer)
Declare Operator Let(x As Double)
Declare Operator Let(x As String)
Declare Operator Let(x As Variant)
Declare Operator For
Declare Operator Step
Declare Operator Next(ByRef x As Variant) As Integer
Declare Operator For(ByRef x As Variant)
Declare Operator Step(ByRef x As Variant)
Declare Operator Next(ByRef x As Variant, ByRef y As Variant) As Integer
Declare Operator [](index As UInteger) As UInteger
Declare Operator @ () As UInteger Ptr
End Type
'########################################################################################
Constructor Variant
Set = 0
End Constructor
Constructor Variant (x As Integer)
Set = x
End Constructor
Constructor Variant (x As Double)
Set = x
End Constructor
Constructor Variant (x As String)
Set = x
End Constructor
Constructor Variant (x As Variant)
Select Case x.Getter
Case 1
Set = x.Get(0)
Case 2
Set = x.Get(0.0)
Case 3
Set = x.Get("")
Case Else
Set = 0
End Select
End Constructor
Destructor Variant
DeAllocate(wert)
wert = 0
variante = 0
strLength = 0
size = 0
End Destructor
'########################################################################################
Operator Variant.Cast As Integer
Select Case variante
Case 1
Return Get(0)
Case 2
Return CInt(Get(0.0))
Case 3
Return 0
Case Else
Return 0
End Select
End Operator
Operator Variant.Cast As Double
Select Case variante
Case 2
Return Get(0.0)
Case 1
Return Cast(Double, Get(0))
Case 3
Return 0.0
Case Else
Return 0.0
End Select
End Operator
Operator Variant.Cast As String
Select Case variante
Case 3
Return Get("")
Case 1
If Get(0) >= 0 Then
Return Chr(32) & Str(Get(0))
Else
Return Str(Get(0))
EndIf
Case 2
If Get(0.0) >= 0 Then
Return Chr(32) & Str(Get(0.0))
Else
Return Str(Get(0.0))
EndIf
Case Else
Return ""
End Select
End Operator
Operator Variant.+= (ByRef x As Integer)
Select Case variante
Case 1
Set = Get(0) + x
Case 2
Set = Get(0.0) + x
Case 3
Set = Get("") & x
Case Else
Set = 0
End Select
End Operator
Operator Variant.+= (ByRef x As Double)
Select Case variante
Case 2
Set = Get(0.0) + x
Case 1
Set = Get(0) + x
Case 3
Set = Get("") & x
Case Else
Set = 0.0
End Select
End Operator
Operator Variant.+= (ByRef x As String)
Select Case variante
Case 3
Set = Get("") & x
Case 1
Set = Str(Get(0)) & x
Case 2
Set = Str(Get(0.0)) & x
Case Else
Set = ""
End Select
End Operator
Operator Variant.+= (ByRef x As Variant)
Select Case variante
Case 1
Select Case x.Getter
Case 1
Set = Get(0) + x.Get(0)
Case 2
Set = Get(0) + x.Get(0.0)
Case 3
Set = Get(0)
Case Else
Set = 0
End Select
Case 2
Select Case x.Getter
Case 1
Set = Get(0.0) + x.Get(0)
Case 2
Set = Get(0.0) + x.Get(0.0)
Case 3
Set = Get(0.0)
Case Else
Set = 0
End Select
Case 3
Select Case x.Getter
Case 1
Set = Get("") & Str(x.Get(0))
Case 2
Set = Get("") & Str(x.Get(0.0))
Case 3
Set = Get("") & x.Get("")
Case Else
Set = 0
End Select
Case Else
Set = 0
End Select
End Operator
Operator Variant.-= (ByRef x As Integer)
Select Case variante
Case 1
Set = Get(0) - x
Case 2
Set = Get(0.0) - x
Case 3
Set = Get("")
Case Else
Set = 0
End Select
End Operator
Operator Variant.-= (ByRef x As Double)
Select Case variante
Case 2
Set = Get(0.0) - x
Case 1
Set = Get(0) - x
Case 3
Set = Get("")
Case Else
Set = 0.0
End Select
End Operator
Operator Variant.-= (ByRef x As String)
Select Case variante
Case 3
Set = Get("")
Case 1
Set = Get("")
Case 2
Set = Get("")
Case Else
Set = ""
End Select
End Operator
Operator Variant.-= (ByRef x As Variant)
Select Case variante
Case 1
Select Case x.Getter
Case 1
Set = Get(0) - x.Get(0)
Case 2
Set = Get(0) - x.Get(0.0)
Case 3
Set = Get(0)
Case Else
Set = 0
End Select
Case 2
Select Case x.Getter
Case 1
Set = Get(0.0) - x.Get(0)
Case 2
Set = Get(0.0) - x.Get(0.0)
Case 3
Set = Get(0.0)
Case Else
Set = 0
End Select
Case 3
Set = Get("")
Case Else
Set = 0
End Select
End Operator
Operator Variant.*= (ByRef x As Integer)
Select Case variante
Case 1
Set = Get(0) * x
Case 2
Set = Get(0.0) * x
Case 3
Set = Get("")
Case Else
Set = 0
End Select
End Operator
Operator Variant.*= (ByRef x As Double)
Select Case variante
Case 2
Set = Get(0.0) * x
Case 1
Set = Get(0) * x
Case 3
Set = Get("")
Case Else
Set = 0.0
End Select
End Operator
Operator Variant.*= (ByRef x As String)
Select Case variante
Case 3
Set = Get("")
Case 1
Set = Get("")
Case 2
Set = Get("")
Case Else
Set = ""
End Select
End Operator
Operator Variant.*= (ByRef x As Variant)
Select Case variante
Case 1
Select Case x.Getter
Case 1
Set = Get(0) * x.Get(0)
Case 2
Set = Get(0) * x.Get(0.0)
Case 3
Set = Get(0)
Case Else
Set = 0
End Select
Case 2
Select Case x.Getter
Case 1
Set = Get(0.0) * x.Get(0)
Case 2
Set = Get(0.0) * x.Get(0.0)
Case 3
Set = Get(0.0)
Case Else
Set = 0
End Select
Case 3
Set = Get("")
Case Else
Set = 0
End Select
End Operator
Operator Variant./= (ByRef x As Integer)
Select Case variante
Case 1
Set = Get(0) / x
Case 2
Set = Get(0.0) / x
Case 3
Set = Get("")
Case Else
Set = 0
End Select
End Operator
Operator Variant./= (ByRef x As Double)
Select Case variante
Case 2
Set = Get(0.0) / x
Case 1
Set = Get(0) / x
Case 3
Set = Get("")
Case Else
Set = 0.0
End Select
End Operator
Operator Variant./= (ByRef x As String)
Select Case variante
Case 3
Set = Get("")
Case 1
Set = Get("")
Case 2
Set = Get("")
Case Else
Set = ""
End Select
End Operator
Operator Variant./= (ByRef x As Variant)
Select Case variante
Case 1
Select Case x.Getter
Case 1
Set = Get(0) / x.Get(0)
Case 2
Set = Get(0) / x.Get(0.0)
Case 3
Set = Get(0)
Case Else
Set = 0
End Select
Case 2
Select Case x.Getter
Case 1
Set = Get(0.0) / x.Get(0)
Case 2
Set = Get(0.0) / x.Get(0.0)
Case 3
Set = Get(0.0)
Case Else
Set = 0
End Select
Case 3
Set = Get("")
Case Else
Set = 0
End Select
End Operator
Operator Variant.\= (ByRef x As Integer)
Select Case variante
Case 1
Set = Get(0) \ x
Case 2
Set = Get(0.0) \ x
Case 3
Set = Get("")
Case Else
Set = 0
End Select
End Operator
Operator Variant.\= (ByRef x As Double)
Select Case variante
Case 2
Set = Get(0.0) \ x
Case 1
Set = Get(0) \ x
Case 3
Set = Get("")
Case Else
Set = 0
End Select
End Operator
Operator Variant.\= (ByRef x As String)
Select Case variante
Case 3
Set = Get("")
Case 1
Set = Get("")
Case 2
Set = Get("")
Case Else
Set = 0
End Select
End Operator
Operator Variant.\= (ByRef x As Variant)
Select Case variante
Case 1
Select Case x.Getter
Case 1
Set = Get(0) \ x.Get(0)
Case 2
Set = Get(0) \ x.Get(0.0)
Case 3
Set = Get(0)
Case Else
Set = 0
End Select
Case 2
Select Case x.Getter
Case 1
Set = Get(0.0) \ x.Get(0)
Case 2
Set = Get(0.0) \ x.Get(0.0)
Case 3
Set = Get(0.0)
Case Else
Set = 0
End Select
Case 3
Set = Get("")
Case Else
Set = 0
End Select
End Operator
Operator Variant.Let(x As Integer)
Set = x
End Operator
Operator Variant.Let(x As Double)
Set = x
End Operator
Operator Variant.Let(x As String)
Set = x
End Operator
Operator Variant.Let(x As Variant)
Select Case x.Getter
Case 1
Set = x.Get(0)
Case 2
Set = x.Get(0.0)
Case 3
Set = x.Get("")
Case Else
Set = 0
End Select
End Operator
Operator Variant.For
End Operator
Operator Variant.Step
Set = Get(0) + 1
End Operator
Operator Variant.Next(ByRef x As Variant) As Integer
Return Get(0) <= x.Get(0)
End Operator
Operator Variant.For(ByRef x As Variant)
End Operator
Operator Variant.Step(ByRef x As Variant)
Set = Get(0) + x.Get(0)
End Operator
Operator Variant.Next(ByRef x As Variant, ByRef y As Variant) As Integer
If y >= 0 Then
Return Get(0) <= x.Get(0)
Else
Return Get(0) >= x.Get(0)
EndIf
End Operator
Operator Variant.@ () As UInteger Ptr
Return wert
End Operator
Operator Variant.[] (index As UInteger) As UInteger
Select Case variante
Case 1, 2
Return 0
Case 3
Return (*Cast(ZString Ptr, wert))[index]
Case Else
Return 0
End Select
End Operator
'########################################################################################
Property Variant.Get As Any Ptr
Select Case variante
Case 1
Return Cast(Integer Ptr, wert)
Case 2
Return Cast(Double Ptr, wert)
Case 3
Return Cast(ZString Ptr, wert)
Case Else
Return 0
End Select
End Property
Property Variant.Get(ByRef x As Integer) As Integer
If wert <> 0 Then
Return *Cast(Integer Ptr, wert)
Else
Return 0
EndIf
End Property
Property Variant.Get(ByRef x As Double) As Double
If wert <> 0 Then
Return *Cast(Double Ptr, wert)
Else
Return 0.0
EndIf
End Property
Property Variant.Get(ByRef x As String) As String
If wert <> 0 Then
Dim As String ret = *Cast(ZString Ptr, wert)
If Len(ret) = strLength - 1 Then
Return ret
Else
ret = ""
Dim As Integer size = SizeOf(ZString) * (strLength - 1)
Dim As UByte Ptr temp = CAllocate(size, SizeOf(ZString))
If temp <> 0 Then
memcpy(temp, Cast(UByte Ptr, wert), size)
For i As Integer = 0 To strLength - 2
ret &= Chr(temp[i])
Next
Return ret
Else
Return ""
EndIf
EndIf
Else
Return ""
EndIf
End Property
'########################################################################################
Property Variant.Set(ByRef x As Integer)
If variante <> 1 Then
If variante <> 0 Then
DeAllocate(wert)
wert = 0
strLength = 0
size = 0
EndIf
variante = 1
wert = Callocate(1, SizeOf(Integer))
strLength = 4
size = 4
EndIf
If wert <> 0 Then
memcpy(Cast(UByte Ptr, wert), Cast(UByte Ptr, @x), SizeOf(Integer))
Else
wert = Callocate(1, SizeOf(Integer))
If wert <> 0 Then
memcpy(Cast(UByte Ptr, wert), Cast(UByte Ptr, @x), SizeOf(Integer))
Else
'
EndIf
EndIf
End Property
Property Variant.Set(ByRef x As Double)
If variante <> 2 Then
If variante <> 0 Then
DeAllocate(wert)
wert = 0
strLength = 0
size = 0
EndIf
variante = 2
wert = Callocate(1, SizeOf(Double))
strLength = 8
size = 8
EndIf
If wert <> 0 Then
memcpy(Cast(UByte Ptr, wert), Cast(UByte Ptr, @x), SizeOf(Double))
Else
wert = Callocate(1, SizeOf(Double))
If wert <> 0 Then
memcpy(Cast(UByte Ptr, wert), Cast(UByte Ptr, @x), SizeOf(Double))
Else
'
EndIf
EndIf
End Property
Property Variant.Set(ByRef x As String)
strLength = Len(x) + 1
Select Case variante
Case 3
If size <= strLength Then
size = (strLength + (strLength Shr 3))
If wert <> 0 Then
wert = Reallocate(wert, size * SizeOf(ZString))
Else
wert = Callocate(size, SizeOf(ZString))
EndIf
EndIf
Case 0
variante = 3
size = (((strLength) + 31) And Not 31)
wert = Callocate(size, SizeOf(ZString))
Case 1, 2
DeAllocate(wert)
wert = 0
variante = 3
size = (((strLength) + 31) And Not 31)
wert = Callocate(size, SizeOf(ZString))
Case Else
variante = 0
Set = x
End Select
If wert <> 0 Then
memcpy(Cast(UByte Ptr, wert), Cast(UByte Ptr, StrPtr(x)), SizeOf(ZString) * (strLength - 1))
Else
wert = Callocate(size, SizeOf(ZString))
If wert <> 0 Then
memcpy(Cast(UByte Ptr, wert), Cast(UByte Ptr, StrPtr(x)), SizeOf(ZString) * (strLength - 1))
Else
'
EndIf
EndIf
End Property
Property Variant.Set (ByRef x As Variant)
Select Case x.Getter
Case 1
Set = x.Get(0)
Case 2
Set = x.Get(0.0)
Case 3
Set = x.Get("")
Case Else
Set = 0
End Select
End Property
'########################################################################################
Function Variant.Getter As Integer
Return variante
End Function
Function Variant.getRealType As String
Select Case variante
Case 1
Return "Integer"
Case 2
Return "Double"
Case 3
Return "String"
Case Else
Return "unbekannt"
End Select
End Function
Function Variant.leng As Integer
Select Case variante
Case 3
Return (strLength - 1)
Case 1
Return 4
Case 2
Return 8
Case Else
Return -1
End Select
End Function
'########################################################################################
Function Right OverLoad (ByRef x As Variant, ByRef n As Integer) As String
Return Right(x.Get(""), n)
End Function
Function Left OverLoad (ByRef x As Variant, ByRef n As Integer) As String
Return Left(x.Get(""), n)
End Function
#If __FB_VERSION__ <= "0.24"
Function UCase OverLoad (ByRef x As Variant) As String
Return UCase(x.Get(""))
End Function
Function LCase OverLoad (ByRef x As Variant) As String
Return LCase(x.Get(""))
End Function
#EndIf
Function Val OverLoad (ByRef x As Variant) As Double
Select Case x.Getter
Case 1
Return x.Get(0)
Case 2
Return x.Get(0.0)
Case 3
Return Val(x.Get(""))
Case Else
Return 0
End Select
End Function
Function ValInt OverLoad (ByRef x As Variant) As Integer
Select Case x.Getter
Case 1
Return x.Get(0)
Case 2
Return CInt(x.Get(0.0))
Case 3
Return ValInt(x.Get(""))
Case Else
Return 0
End Select
End Function
Function ValUInt OverLoad (ByRef x As Variant) As UInteger
Select Case x.Getter
Case 1
Return x.Get(0)
Case 2
Return CInt(x.Get(0.0))
Case 3
Return ValUInt(x.Get(""))
Case Else
Return 0
End Select
End Function
Function ValLng OverLoad (ByRef x As Variant) As LongInt
Select Case x.Getter
Case 1
Return x.Get(0)
Case 2
Return CInt(x.Get(0.0))
Case 3
Return ValLng(x.Get(""))
Case Else
Return 0
End Select
End Function
Function ValULng OverLoad (ByRef x As Variant) As ULongInt
Select Case x.Getter
Case 1
Return x.Get(0)
Case 2
Return CInt(x.Get(0.0))
Case 3
Return ValULng(x.Get(""))
Case Else
Return 0
End Select
End Function
Function Hex OverLoad (ByRef x As Variant) As String
Select Case x.Getter
Case 1
Return Hex(x.Get(0))
Case 2
Return Hex(x.Get(0.0))
Case 3
Return Hex(Val(x.Get("")))
Case Else
Return ""
End Select
End Function
Function WHex OverLoad (ByRef x As Variant) As String
Select Case x.Getter
Case 1
Return WHex(x.Get(0))
Case 2
Return WHex(x.Get(0.0))
Case 3
Return WHex(Val(x.Get("")))
Case Else
Return ""
End Select
End Function
Function Bin OverLoad (ByRef x As Variant, d As Integer = 0) As String
Select Case x.Getter
Case 1
If d = 0 Then
Return Bin(x.Get(0))
Else
Return Bin(x.Get(0), d)
EndIf
Case 2
If d = 0 Then
Return Bin(x.Get(0.0))
Else
Return Bin(x.Get(0.0), d)
EndIf
Case 3
If d = 0 Then
Return Bin(Val(x.Get("")))
Else
Return Bin(Val(x.Get("")), d)
EndIf
Case Else
Return ""
End Select
End Function
Function WBin OverLoad (ByRef x As Variant, ByRef d As Integer = 0) As String
Select Case x.Getter
Case 1
If d = 0 Then
Return WBin(x.Get(0))
Else
Return WBin(x.Get(0), d)
EndIf
Case 2
If d = 0 Then
Return WBin(x.Get(0.0))
Else
Return WBin(x.Get(0.0), d)
EndIf
Case 3
If d = 0 Then
Return WBin(Val(x.Get("")))
Else
Return WBin(Val(x.Get("")), d)
EndIf
Case Else
Return ""
End Select
End Function
'Function Dir OverLoad (x As Variant, y As Integer = &H21, z As Integer Ptr = 0) As Variant
' Dim As String temp
' Dim As Variant ret
' temp = x
' ret = Dir(temp, y, z)
' Return ret
'End Function
'########################################################################################
Operator + (ByRef lhs As Variant, ByRef rhs As Integer) As Variant
Select Case lhs.Getter
Case 1
Return lhs.Get(0) + rhs
Case 2
Return lhs.Get(0.0) + rhs
Case 3
Return rhs
Case Else
Return rhs
End Select
End Operator
Operator + (ByRef lhs As Integer, ByRef rhs As Variant) As Variant
Select Case rhs.Getter
Case 1
Return lhs + rhs.Get(0)
Case 2
Return lhs + rhs.Get(0.0)
Case 3
Return lhs
Case Else
Return lhs
End Select
End Operator
Operator - (ByRef lhs As Variant, ByRef rhs As Integer) As Variant
Select Case lhs.Getter
Case 1
Return lhs.Get(0) - rhs
Case 2
Return lhs.Get(0.0) - rhs
Case 3
Return rhs
Case Else
Return rhs
End Select
End Operator
Operator - (ByRef lhs As Integer, ByRef rhs As Variant) As Variant
Select Case rhs.Getter
Case 1
Return lhs - rhs.Get(0)
Case 2
Return lhs - rhs.Get(0.0)
Case 3
Return lhs
Case Else
Return lhs
End Select
End Operator
Operator * (ByRef lhs As Variant, ByRef rhs As Integer) As Variant
Select Case lhs.Getter
Case 1
Return lhs.Get(0) * rhs
Case 2
Return lhs.Get(0.0) * rhs
Case 3
Return rhs
Case Else
Return rhs
End Select
End Operator
Operator * (ByRef lhs As Integer, ByRef rhs As Variant) As Variant
Select Case rhs.Getter
Case 1
Return lhs * rhs.Get(0)
Case 2
Return lhs * rhs.Get(0.0)
Case 3
Return lhs
Case Else
Return lhs
End Select
End Operator
Operator / (ByRef lhs As Variant, ByRef rhs As Integer) As Variant
Select Case lhs.Getter
Case 1
Return lhs.Get(0) / rhs
Case 2
Return lhs.Get(0.0) / rhs
Case 3
Return rhs
Case Else
Return rhs
End Select
End Operator
Operator / (ByRef lhs As Integer, ByRef rhs As Variant) As Variant
Select Case rhs.Getter
Case 1
Return lhs / rhs.Get(0)
Case 2
Return lhs / rhs.Get(0.0)
Case 3
Return lhs
Case Else
Return lhs
End Select
End Operator
Operator \ (ByRef lhs As Variant, ByRef rhs As Integer) As Variant
Select Case lhs.Getter
Case 1
Return lhs.Get(0) \ rhs
Case 2
Return lhs.Get(0.0) \ rhs
Case 3
Return rhs
Case Else
Return rhs
End Select
End Operator
Operator \ (ByRef lhs As Integer, ByRef rhs As Variant) As Variant
Select Case rhs.Getter
Case 1
Return lhs \ rhs.Get(0)
Case 2
Return lhs \ rhs.Get(0.0)
Case 3
Return lhs
Case Else
Return lhs
End Select
End Operator
Operator + (ByRef lhs As Variant, ByRef rhs As Double) As Variant
Select Case lhs.Getter
Case 1
Return lhs.Get(0) + rhs
Case 2
Return lhs.Get(0.0) + rhs
Case 3
Return rhs
Case Else
Return rhs
End Select
End Operator
Operator + (ByRef lhs As Double, ByRef rhs As Variant) As Variant
Select Case rhs.Getter
Case 1
Return lhs + rhs.Get(0)
Case 2
Return lhs + rhs.Get(0.0)
Case 3
Return lhs
Case Else
Return lhs
End Select
End Operator
Operator - (ByRef lhs As Variant, ByRef rhs As Double) As Variant
Select Case lhs.Getter
Case 1
Return lhs.Get(0) - rhs
Case 2
Return lhs.Get(0.0) - rhs
Case 3
Return rhs
Case Else
Return rhs
End Select
End Operator
Operator - (ByRef lhs As Double, ByRef rhs As Variant) As Variant
Select Case rhs.Getter
Case 1
Return lhs - rhs.Get(0)
Case 2
Return lhs - rhs.Get(0.0)
Case 3
Return lhs
Case Else
Return lhs
End Select
End Operator
Operator * (ByRef lhs As Variant, ByRef rhs As Double) As Variant
Select Case lhs.Getter
Case 1
Return lhs.Get(0) * rhs
Case 2
Return lhs.Get(0.0) * rhs
Case 3
Return rhs
Case Else
Return rhs
End Select
End Operator
Operator * (ByRef lhs As Double, ByRef rhs As Variant) As Variant
Select Case rhs.Getter
Case 1
Return lhs * rhs.Get(0)
Case 2
Return lhs * rhs.Get(0.0)
Case 3
Return lhs
Case Else
Return lhs
End Select
End Operator
Operator / (ByRef lhs As Variant, ByRef rhs As Double) As Variant
Select Case lhs.Getter
Case 1
Return lhs.Get(0) / rhs
Case 2
Return lhs.Get(0.0) / rhs
Case 3
Return rhs
Case Else
Return rhs
End Select
End Operator
Operator / (ByRef lhs As Double, ByRef rhs As Variant) As Variant
Select Case rhs.Getter
Case 1
Return lhs / rhs.Get(0)
Case 2
Return lhs / rhs.Get(0.0)
Case 3
Return lhs
Case Else
Return lhs
End Select
End Operator
Operator \ (ByRef lhs As Variant, ByRef rhs As Double) As Variant
Select Case lhs.Getter
Case 1
Return lhs.Get(0) \ rhs
Case 2
Return lhs.Get(0.0) \ rhs
Case 3
Return rhs
Case Else
Return rhs
End Select
End Operator
Operator \ (ByRef lhs As Double, ByRef rhs As Variant) As Variant
Select Case rhs.Getter
Case 1
Return lhs \ rhs.Get(0)
Case 2
Return lhs \ rhs.Get(0.0)
Case 3
Return lhs
Case Else
Return lhs
End Select
End Operator
Operator + (ByRef lhs As Variant, ByRef rhs As Variant) As Variant
Select Case lhs.Getter
Case 1
Select Case rhs.Getter
Case 1
Return lhs.Get(0) + rhs.Get(0)
Case 2
Return lhs.Get(0) + rhs.Get(0.0)
Case 3
Return lhs.Get(0)
Case Else
Return lhs.Get(0)
End Select
Case 2
Select Case rhs.Getter
Case 1
Return lhs.Get(0.0) + rhs.Get(0)
Case 2
Return lhs.Get(0.0) + rhs.Get(0.0)
Case 3
Return lhs.Get(0.0)
Case Else
Return lhs.Get(0.0)
End Select
Case 3
Select Case rhs.Getter
Case 1
Return lhs.Get("") & Str(rhs.Get(0))
Case 2
Return lhs.Get("") & Str(rhs.Get(0.0))
Case 3
Return lhs.Get("") & rhs.Get("")
Case Else
Return lhs.Get("")
End Select
Case Else
Return 0
End Select
End Operator
Operator - (ByRef lhs As Variant, ByRef rhs As Variant) As Variant
Select Case lhs.Getter
Case 1
Select Case rhs.Getter
Case 1
Return lhs.Get(0) - rhs.Get(0)
Case 2
Return lhs.Get(0) - rhs.Get(0.0)
Case 3
Return lhs.Get(0)
Case Else
Return lhs.Get(0)
End Select
Case 2
Select Case rhs.Getter
Case 1
Return lhs.Get(0.0) - rhs.Get(0)
Case 2
Return lhs.Get(0.0) - rhs.Get(0.0)
Case 3
Return lhs.Get(0.0)
Case Else
Return lhs.Get(0.0)
End Select
Case 3
Select Case rhs.Getter
Case 1
Return 0 - rhs.Get(0)
Case 2
Return 0 - rhs.Get(0.0)
Case 3
Return 0
Case Else
Return 0
End Select
Case Else
Return 0
End Select
End Operator
Operator * (ByRef lhs As Variant, ByRef rhs As Variant) As Variant
Select Case lhs.Getter
Case 1
Select Case rhs.Getter
Case 1
Return lhs.Get(0) * rhs.Get(0)
Case 2
Return lhs.Get(0) * rhs.Get(0.0)
Case 3
Return lhs.Get(0)
Case Else
Return lhs.Get(0)
End Select
Case 2
Select Case rhs.Getter
Case 1
Return lhs.Get(0.0) * rhs.Get(0)
Case 2
Return lhs.Get(0.0) * rhs.Get(0.0)
Case 3
Return lhs.Get(0.0)
Case Else
Return lhs.Get(0.0)
End Select
Case 3
Select Case rhs.Getter
Case 1
Return rhs.Get(0)
Case 2
Return rhs.Get(0.0)
Case 3
Return 0
Case Else
Return 0
End Select
Case Else
Return 0
End Select
End Operator
Operator / (ByRef lhs As Variant, ByRef rhs As Variant) As Variant
Select Case lhs.Getter
Case 1
Select Case rhs.Getter
Case 1
Return lhs.Get(0) / rhs.Get(0)
Case 2
Return lhs.Get(0) / rhs.Get(0.0)
Case 3
Return lhs.Get(0)
Case Else
Return lhs.Get(0)
End Select
Case 2
Select Case rhs.Getter
Case 1
Return lhs.Get(0.0) / rhs.Get(0)
Case 2
Return lhs.Get(0.0) / rhs.Get(0.0)
Case 3
Return lhs.Get(0.0)
Case Else
Return lhs.Get(0.0)
End Select
Case 3
Select Case rhs.Getter
Case 1
Return rhs.Get(0)
Case 2
Return rhs.Get(0.0)
Case 3
Return 0
Case Else
Return 0
End Select
Case Else
Return 0
End Select
End Operator
Operator \ (ByRef lhs As Variant, ByRef rhs As Variant) As Variant
Select Case lhs.Getter
Case 1
Select Case rhs.Getter
Case 1
Return lhs.Get(0) \ rhs.Get(0)
Case 2
Return lhs.Get(0) \ rhs.Get(0.0)
Case 3
Return lhs.Get(0)
Case Else
Return lhs.Get(0)
End Select
Case 2
Select Case rhs.Getter
Case 1
Return lhs.Get(0.0) \ rhs.Get(0)
Case 2
Return lhs.Get(0.0) \ rhs.Get(0.0)
Case 3
Return lhs.Get(0.0)
Case Else
Return lhs.Get(0.0)
End Select
Case 3
Select Case rhs.Getter
Case 1
Return rhs.Get(0)
Case 2
Return rhs.Get(0.0)
Case 3
Return 0
Case Else
Return 0
End Select
End Select
End Operator
Operator + (ByRef lhs As Variant, ByRef rhs As String) As Variant
Select Case lhs.Getter
Case 1
Return Str(lhs.Get(0)) & rhs
Case 2
Return Str(lhs.Get(0.0)) & rhs
Case 3
Return lhs.Get("") & rhs
Case Else
Return rhs
End Select
End Operator
Operator + (ByRef lhs As String, ByRef rhs As Variant) As Variant
Select Case rhs.Getter
Case 1
Return lhs & Str(rhs.Get(0))
Case 2
Return lhs & Str(rhs.Get(0.0))
Case 3
Return lhs & rhs.Get("")
Case Else
Return lhs
End Select
End Operator
'########################################################################################
Function VGetMouse(ByRef x As Variant, ByRef y As Variant, ByRef wheel As Variant = 0, ByRef buttons As Variant = 0, ByRef clip As Variant = 0) As Integer
Dim As Integer xr, yr, wheelr, buttonsr, clipr, ret
ret = GetMouse(xr, yr, wheelr, buttonsr, clipr)
x = xr
y = yr
wheel = wheelr
buttons = buttonsr
clip = clipr
Return ret
End Function
#Define Length(x) x.leng
'########################################################################################
Zusätzliche Informationen und Funktionen | |||||||
---|---|---|---|---|---|---|---|
|