Converting A Method To or From Shared
· Aug 2, 03:26 PMThe REALbasic IDE has a menu item that, when selected, will convert properties to and from shared. But unfortunately there is no corresponding item for conversion of methods. In the course of refactoring I frequently need to do this as well. It turns out that it can be done via a simple trick.
Cut the shared method, saving it to the clipboard. Then paste it into your favorite text editor. You should see something like
Shared Sub Refactor() //your code here End Sub
To convert this, remove the word "Shared". Then copy the remaining text and paste it back into the class. You now have an object method.
Conversely, you can convert an object method to a shared method by adding the word "Shared" just before the word "Sub" or "Function".
Update: This has been fixed in REALbasic 2007r4.
Comment
Commenting is closed for this article.
Um… that menu is there for methods as well…
— Aaron Ballman · Aug 4, 12:51 PM · #
Perhaps it’s my advancing age, but I can’t find it. For properties, I see it at the bottom of the contextual menu that appears when I click on a property.
— charles · Aug 4, 12:59 PM · #
It’s there for methods as well, saying “Convert to Shared” or “Convert to Regular” depending on the context.
— Aaron Ballman · Aug 8, 07:06 PM · #