I’m trying to write a drop-in replacement for the Screen() class, implementing it as a class called cScreen which has shared methods such as Count.
To make it easy to use, I want to be able to replace
dim s as Screen = Screen(N)
dim s as cScreen = cScreen(N)
To accomplish this, I’ve added this to my cScreen class:
Public Shared Function Operator_Subscript(index as integer) as cScreen return mScreens(index) End Function
But when I compile, I get this error:
dim s as cScreen = cScreen(N) // Type Mismatch error: Expected class cScreen but got Integer
It appears the compiler is seeing “cScreen(N)” as a cast, not as Operator_Subscript.
I’m using Xojo 2019R1.1