Hello,
Is it possible to create a function (or method) with arguments where one argument can be either a custom type or an Int?
Like I would like to use in this code...
When I build this I get the error Unable to convert from 'Object' to 'Int' at line
Is it possible to create a function (or method) with arguments where one argument can be either a custom type or an Int?
Like I would like to use in this code...
Type TColor Field piRed% Field piGreen% Field piBlue% Function Create:TColor(iRed% = 0, iGreen% = 0, iBlue% = 0) Local o:TColor = New TColor o.piRed = iRed o.piGreen = iGreen o.piBlue = iBlue Return o End Function Method SetColorValues(oClr_iRed:Object, iGreen% = Null, iBlue% = Null) If TColor(oClr_iRed) Then 'oClr_iRed = a TColor type piRed = TColor(oClr_iRed).GetRed() piGreen = TColor(oClr_iRed).GetGreen() piBlue = TColor(oClr_iRed).GetBlue() Else 'oClr_iRed = a Int piRed = Int(oClr_iRed) piGreen = iGreen piBlue = iBlue End If End Method Method GetRed%() Return piRed End Method Method GetGreen%() Return piRed End Method Method GetBlue%() Return piRed End Method 'etc... End Type Local clr:TColor = TColor.Create(200, 100, 10) Local clr2:TColor = TColor.Create(100,10,100) clr.SetColorValues(100, 20, 200) clr.SetColorValues(clr)
When I build this I get the error Unable to convert from 'Object' to 'Int' at line
piRed = Int(oClr_iRed)