Tip: You can return a calculation from a window without instantiating it

I needed to run some checks on data before allowing a window to be displayed. You can add a shared method to the window, pass the data in and return a value. Only then you can decide to instantiate the window.

I like my checks being associated with the window as they are related and it’s not enough code to make it worthwhile creating a wrapper class for logic and window.

Just learned this today (after coding in Xojo for over a decade)!

Well… That’s not a window related thing. You just learned about Xojo shared properties and methods of a class (known as static properties and methods of a class in some languages).


Me too - still learning after over a decade of using the thing :slight_smile: It’s a very rich tool.

It was intuitive to me to use in classes. Just never occurred to me to use it in a Window! :slight_smile:

i know 2 applications

you can use the class name itself without using the new key word (single instance)
somehow it is possible = MyClass.MyMethod()
means also you can access variables from everywhere, sometimes useful.

in other languages it is possible that the calling method stay in memory.
usually a method allocate memory and release this memory at the end.
advantage: it can be used recursive and every method have it own variables.
static: recycling it is much faster and recursive/parallel would have a conflict.