New topic: Overloading Methods and Event Definitions
<http://forums.realsoftware.com/viewtopic.php?t=45834> Page 1 of 1 [ 4 posts ] Previous topic | Next topic Author Message Jason_Adams Post subject: Overloading Methods and Event DefinitionsPosted: Wed Nov 07, 2012 9:18 am Joined: Fri Nov 10, 2006 4:10 pm Posts: 1713 Location: Michigan, USA Let's say we have a class with a sub and Event Definition, both called Foo() Now if we mean to call explicitly call the event, we can use RaiseEvent: RaiseEvent Foo This works great. But is there a similar way to explicitly call the sub? If I just use Foo(), it gives me a compile error that it's unclear which I'm referring to. I hoped that using Call might do the trick, but it didn't. I'm trying to avoid horribly redundant naming, and would rather overload the name. Thoughts? _________________ Windows 7 Ultimate x64 Windows XP Pro SP3 Ubuntu 11.04 via Virtual Box RS Enterprise 2012r1.1 Programming Tutorials & Free Projects: http://www.JasonTheAdams.com "Christianity has not been tried and found wanting; it has been found difficult and not tried." - G.K. Chesterton Top DaveS Post subject: Re: Overloading Methods and Event DefinitionsPosted: Wed Nov 07, 2012 9:55 am Joined: Sun Aug 05, 2007 10:46 am Posts: 4238 Location: San Diego, CA Overloading requires that the signature be DIFFERENT for example you could have two events (methods etc) called FOO if one was SUB FOO and another was SUB FOO(x as integer) In the case of your event..... when FOO fires.... instead of putting all the code in the event response... have IT call a subroutine Then THAT subroutine can be called from wherever you like (another event, another method etc) _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top Jason_Adams Post subject: Re: Overloading Methods and Event DefinitionsPosted: Wed Nov 07, 2012 10:09 am Joined: Fri Nov 10, 2006 4:10 pm Posts: 1713 Location: Michigan, USA Thanks, Dave, I follow. Let me unpack a bit more: I have a class, TestHandler, that is the base class for all my test types. The TestHandler has two similar methods: Sub BeginTesting() Event BeginTesting() Once the test begins the sub is called, which performs tasks that any test must perform. At the end of the sub the event is raised, giving all subclasses the opportunity to make any pre-tests adjustments specific to that test type. Now, I understand that parameters allow for immediate overloading, and returns don't â the signature, as you called it, is defined by the name and parameters. I wasn't sure if, internally, an event was considered unique to a method, or if there's no distinction and therefore must abide by the same rules. This isn't so much a problem as much as a moment of curiosity. I like knowing how things work. _________________ Windows 7 Ultimate x64 Windows XP Pro SP3 Ubuntu 11.04 via Virtual Box RS Enterprise 2012r1.1 Programming Tutorials & Free Projects: http://www.JasonTheAdams.com "Christianity has not been tried and found wanting; it has been found difficult and not tried." - G.K. Chesterton Top npalardy Post subject: Re: Overloading Methods and Event DefinitionsPosted: Wed Nov 07, 2012 10:21 am Real Software Engineer Joined: Sat Dec 24, 2005 8:18 pm Posts: 7532 Location: Canada, Alberta, Near Red Deer Jason_Adams wrote:Let's say we have a class with a sub and Event Definition, both called Foo() Now if we mean to call explicitly call the event, we can use RaiseEvent: RaiseEvent Foo This works great. But is there a similar way to explicitly call the sub? If I just use Foo(), it gives me a compile error that it's unclear which I'm referring to. I hoped that using Call might do the trick, but it didn't. I'm trying to avoid horribly redundant naming, and would rather overload the name. Thoughts? Call just lets you ignore returned values from a function You might try self.Foo however I have my doubts about this working. I'd really avoid having a method & and event named the same since it's entirely likely to cause confusion for the compiler. _________________ My web site Great White Software RBLibrary.com REALbasic learning Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 4 posts ]
-- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
