Delegate Subs in REALBasic 5.5

I know that in the newer Xojo versions you can define a delegate for events, but for the life of me, I cannot figure out how to do that in REALBasic 5.5. Yes, I know it is a really old version, but I’m building a native app for MacOS 9. Also, if (in code) I create a new timer instance (ie. Dim tim = new Timer), how do I then assign a handler method for the Action event? I know I can if drop a timer control on the window , but I want to dynamically instantiate the the new object in code and not necessarily add it as a control on the window.

I guess the 2 main things I’m hoping someone could answer for me would be:

  1. How do you define a delegate in RB 5.5.5? Is it even possible? Or is that something that came in a later release?

  2. For objects that have events defined on them (the Timer class for example), how do you programmatically assign an event handler? When instantiating the Timer class, the ‘Action’ event doesn’t even appear to be a class member when using RB’s auto-completion. But if you drag-and-drop a Timer control on to a window and then ‘Edit Code → Controls → Timer1 → Action’ you can add handler code. What I was hoping for was something like:

Dim tim As Timer = new Timer

Or even what Xojo has:


Where your receiver class then inherits from the ‘actionNotificationReceiver’ interface (which exists in RB 5.5.5)

Ultimately, I’d like to define custom events and then be able to wire up my own handler for those events and I can’t seem to figure out how to do that through RB’s UI, which I definitely admit could just be me just not understanding something. But I also searched though several example projects and also the language reference looking for key words like ‘event’, ‘delegate’, ‘handler’, etc.

Any help from you fine folks would be greatly appreciated!

i not know about 5.5 but i would subclass the timer, use a own constructor method where you put the window (interface) in.
create/assign a interface (a few methods) for your window.
in this subclass there should appear the timer event where you call every registered object interface method.

Dim n as new NotificationTimer(self)
it store the self into a property from type interfacename.
Dim n as new NotificationTimer
n.Register(self) it could memory all objects into a list.

the interface have a method Notification.
in the window fill the Notification method for your need.

I could be wrong, but I believe RB5.5 predates those (and many other) features. I looked for release dates on delegates and AddHandler, but came up empty. @MarkusR has the right idea. You’re going to have to do extra work to support something so old from a version of the IDE that is so far behind the current framework.

The Language Ref for REALbasic 5.5.5 has no AddHandler or Delegate. It has AddressOf, but only mentions using it for declares.

delegates were introduced with Xojo in 2013.

Correction: they were added in RS2010r4

1 Like

Well… dang. I was afraid that would be the case. I think I’ll try and go with what @MarkusR suggested and see how that works. If not, I may have to use a different tech stack (Java, C/C++)

I basically did that long ago - I think it may have been even before 5.5.

I my case I just created an interface (TimerAction) with one method ("Action:) that passed the the timer instance into that method.

Item method got called in the timer action event in the subclass (which I think I called OwnedTimer)…

The mechanism works well and is easy to setup - and was the only way to do it get really back then.