#if Targetxxxx

I’ve seen this a lot in posts on the forums and even in code submitted as part of bug reports

If TargetWindows Then
  // Windows only code not excluded from compilation.
End If

The code inside the if will only execute on Windows. However becuase this code is just a normal if it HAS to COMPILE on ALL targets even if the intention is that it only be used on Windows (which it obviously is)

If you intend some code to ONLY be used on Windows you’re better off to use this form

#If TargetWindows Then
  // Declares for example
#Endif

This code will ONLY exist in a Windows builds and so can ONLY execute on Windows.… Read the rest

Classes, Instances and Objects

There’s a fun “theoretical question” on the forums.

What is the relationship between a class, object, and instance?

Lets see if I can help any (or maybe just confuse the heck out of folks even more)

In Xojo in the IDE when you define a CLASS you are creating a “template” for how every item of this type will behave.… Read the rest

Silent readership

I’m curious about something. Actually I’m curious about a LOT of things; just ask my Canadian Skip Patrol instructors 😛
But I’m REALLY curious about one thing when it comes to this blog.

I can see there are a decent number of readers & views thanks to the stats that WordPress gives me. But, there’s very few comments.… Read the rest

Performance tweaks

In Xojo there are a number of things you can do to improve the performance of your code.

There are various pragmas you can enable that can improve speed – I’d suggest only doing this once you code is fully debugged and known to be working properly as turning these checks of can mean IF you have a bug your application just crashes hard.… Read the rest

Structures vs Classes

While structures & classes may seem to be very similar in most respects there aren’t many cases when I would suggest you use a structure instead of a class.

A class with public member properties isnt that different from a structure in terms of how your code uses it.

The biggest difference is that for a class you must use new to get a new instance.… Read the rest

Operator_compare

Ever wanted to define a class, maybe a vector class, and make it possible to write code like

dim v1 as new Vector(1,1)
dim v2 as new Vector(2,2)

if v1 v2 then
  // do something when v1 v2
elseif v1 < v2 then
  // do something when v1 < v2
else
  // do something when v1 = v2
end if

Perhaps you have some other kind of class you’d like to define that has some kind of custom mechanism to compare itself to other instances – or even other data types.… Read the rest

Method signatures

I know I’ve probably used this term a bunch in other blog posts but I don’t think I’ve ever explained what a method signature is.

In Xojo a “method signature” is the unique way Xojo identifies each method so it can know which method you are calling in your code.

So what does that include ?… Read the rest

2019r3

I’ll admit that I really haven’t seriously touched R3 since most of its focus was on iOS and dark mode which isn’t something that matters to me.

The times I did start it I found it to still be slow like R2.1 and otherwise not many significant differences in the things I was trying.

Autocomplete is still glaringly bright in dark mode on macOS.… Read the rest