Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu May 25, 2017 3:56 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Possible to get names of class/modules at run-time?
PostPosted: Fri May 24, 2013 10:04 pm 
Offline
User avatar

Joined: Sun Dec 10, 2006 7:57 am
Posts: 124
Location: Addison, Texas
Add a couple of custom modules or classes to a project, and name them. Is there a way to retrieve the names of these classes/modules within an application/project at run-time using code?

_________________
Respectfully,
Eric Brown

http://www.facebook.com/ericdbrown


Top
 Profile  
 
 Post subject: Re: Possible to get names of class/modules at run-time?
PostPosted: Sat May 25, 2013 4:13 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
Yes, using the Introspection class. There is an example in the documentation.

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
 
 Post subject: Re: Possible to get names of class/modules at run-time?
PostPosted: Sat May 25, 2013 8:33 pm 
Offline
User avatar

Joined: Sun Dec 10, 2006 7:57 am
Posts: 124
Location: Addison, Texas
Thanks, simulanics. I figured introspection is the place to go for this; however, I have no idea what I'm doing. I can find ways to pull method names, etc. out of a class that is already known, but I can't find a way to pull the class names themselves from the app. I'll re-read the documentation and see what I can figure out. Again, I appreciate the assistance.

_________________
Respectfully,
Eric Brown

http://www.facebook.com/ericdbrown


Top
 Profile  
 
 Post subject: Re: Possible to get names of class/modules at run-time?
PostPosted: Sat May 25, 2013 8:41 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
edb wrote:
Thanks, simulanics. I figured introspection is the place to go for this; however, I have no idea what I'm doing. I can find ways to pull method names, etc. out of a class that is already known, but I can't find a way to pull the class names themselves from the app. I'll re-read the documentation and see what I can figure out. Again, I appreciate the assistance.


put App (without quotes) in place of the control/class name in the Introspection Methods parameter...

Dim myMethods() As Introspection.MethodInfo = Introspection.GetType(App).GetMethods
For i As Integer = 0 To myMethods.Ubound
msgbox myMethods(i).Name
Next


:-) hope that helps...

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
 
 Post subject: Re: Possible to get names of class/modules at run-time?
PostPosted: Sat May 25, 2013 8:52 pm 
Offline
User avatar

Joined: Sun Dec 10, 2006 7:57 am
Posts: 124
Location: Addison, Texas
simulanics wrote:
edb wrote:
Thanks, simulanics. I figured introspection is the place to go for this; however, I have no idea what I'm doing. I can find ways to pull method names, etc. out of a class that is already known, but I can't find a way to pull the class names themselves from the app. I'll re-read the documentation and see what I can figure out. Again, I appreciate the assistance.


put App (without quotes) in place of the control/class name in the Introspection Methods parameter...

Dim myMethods() As Introspection.MethodInfo = Introspection.GetType(App).GetMethods
For i As Integer = 0 To myMethods.Ubound
msgbox myMethods(i).Name
Next


:-) hope that helps...


Tried that already, and unfortunately the names of my classes/modules don't appear in the return array.

_________________
Respectfully,
Eric Brown

http://www.facebook.com/ericdbrown


Top
 Profile  
 
 Post subject: Re: Possible to get names of class/modules at run-time?
PostPosted: Sat May 25, 2013 9:57 pm 
Offline

Joined: Sat Jul 16, 2011 2:45 pm
Posts: 76
If I understand correctly, you want to use the "runtime" function:
http://docs.realsoftware.com/index.php/Runtime

With the introspection system "GetType" method:
http://docs.realsoftware.com/index.php/ ... on.GetType

Then you should be able to go over all the runtime objects and check the various Type properties (such as fullname):
http://docs.realsoftware.com/index.php/TypeInfo


Top
 Profile  
 
 Post subject: Re: Possible to get names of class/modules at run-time?
PostPosted: Sat May 25, 2013 10:35 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
lukus001 wrote:
If I understand correctly, you want to use the "runtime" function:
http://docs.realsoftware.com/index.php/Runtime

With the introspection system "GetType" method:
http://docs.realsoftware.com/index.php/ ... on.GetType

Then you should be able to go over all the runtime objects and check the various Type properties (such as fullname):
http://docs.realsoftware.com/index.php/TypeInfo


That dont seem to work either... I was reading that custom modules and classes are handled differently than the built-in ones by the compiler...so it's as if they don't exist...I'm sure there has to be a way though...the method you mentioned above would be the following:

Dim myDbMethods() As Introspection.MethodInfo
Dim o as Runtime.ObjectIterator=Runtime.IterateObjects
While o.MoveNext
myDbMethods() = Introspection.GetType(o.current).GetMethods
For i As Integer = 0 To myDbMethods.Ubound
Listbox1.AddRow(myDbMethods(i).Name)
Next
Wend

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
 
 Post subject: Re: Possible to get names of class/modules at run-time?
PostPosted: Sat May 25, 2013 10:45 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
For my project over at www.simscript.org I had to fan-angle a bunch of API's to peek for method names. SimScript is a plugin engine to compile plugins (like applications) for Xojo/RS..they can have interfaces, access the parent app's properties, methods, etc...and pass information back and forth between the loaded plugin and the Xojo/RS application and/or the Plugin Designer debugger. :-) Unfortunately that is proprietary code..but there is demos and source if you're interested. There has to be a "purely" Xojo/RS method to obtain all the methods from custom classes/modules...I've search almost a year and still no answer so the previously mentioned project required some 'creativity.'

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
 
 Post subject: Re: Possible to get names of class/modules at run-time?
PostPosted: Sun May 26, 2013 12:49 am 
Offline
Real Software Engineer

Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7858
Location: Canada, Alberta, Near Red Deer
simulanics wrote:
There has to be a "purely" Xojo/RS method to obtain all the methods from custom classes/module

Classes yes
Modules no - at least not without using unsupported hackery

_________________
Norman Palardy (Real Software)


Top
 Profile  
 
 Post subject: Re: Possible to get names of class/modules at run-time?
PostPosted: Sun May 26, 2013 3:37 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
You can't find a list of all classes in your RB app.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
 
 Post subject: Re: Possible to get names of class/modules at run-time?
PostPosted: Sun May 26, 2013 9:02 am 
Offline
User avatar

Joined: Thu Sep 10, 2009 2:50 am
Posts: 418
Location: Santa Cruz, CA, USA
Would it be possible to use IDE Scripting to auto-generate this info?

I've done this before by saving as XML, processing that and dragging a generated class file back into the project. Clumsy but the only way without hackery or possibly IDE Scripting.


Top
 Profile  
 
 Post subject: Re: Possible to get names of class/modules at run-time?
PostPosted: Sun May 26, 2013 2:26 pm 
Offline
Real Software Engineer

Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7858
Location: Canada, Alberta, Near Red Deer
doofus wrote:
Would it be possible to use IDE Scripting to auto-generate this info?

I've done this before by saving as XML, processing that and dragging a generated class file back into the project. Clumsy but the only way without hackery or possibly IDE Scripting.


I'll confess I'm VERY curious how you'd even make use of this or what the intent is

_________________
Norman Palardy (Real Software)


Top
 Profile  
 
 Post subject: Re: Possible to get names of class/modules at run-time?
PostPosted: Sun May 26, 2013 2:42 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
You can save your project as an XML document and get grab them from there for purposes such as documenting them but as norm said, without unsupported "Hackery" it is not possible.

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
 
 Post subject: Re: Possible to get names of class/modules at run-time?
PostPosted: Fri May 31, 2013 6:58 pm 
Offline
User avatar

Joined: Thu Sep 10, 2009 2:50 am
Posts: 418
Location: Santa Cruz, CA, USA
npalardy wrote:
I'll confess I'm VERY curious how you'd even make use of this or what the intent is


:) I don't really remember. I think it was for a graph editor where the user can add nodes for any class available to the app, including those in the RB API, and rather than manually maintain the functions for listing and constructing classes it seemed saner to auto-generate. Or maybe it was for an RBScript app; can't find the projects atm.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group