On Wed, Dec 28, 2011 at 11:20 PM, John Spikowski
<supp...@scriptbasic.org> wrote:
> On Tue, 2011-12-27 at 22:03 -0300, Sebastian Kulesz wrote:
>> Hi! I am having some problems when using the Object.GetProperty method
>> when the object parameter to be used is stored in a string. The
>> structure of my project is as follows
>>
>> ============
>> Module Module1{
>>
>> public Var1 as string
>>
>> }
>>
>>
>> ============
>> Module Main (Starting class){
>>
>> public sub Main()
>>
>>     DIM sModule as String
>>
>>     sModule="Module1"
>>
>>     Object.GetProperty(sModule, "Var1")
>>
>> END
>>
>> }
>> ============
>>
>> The normal behavior is to know the first parameter  of the GetProperty
>> method, hence calling Object.GetProperty(Module1, "Var1"), but i need
>> the first parameter to be dynamic, therefore being of a type different
>> than object
>>
>> I would like to know if there is a way to get an instance of an object
>> by knowing the class/module name, or if the GetProperty method can be
>> modified to accept a string as a parameter, same as the second
>> argument
>>
>> Thanks!
>>
> Benoît has already responded on this but I'm currious, before using
> Gambas, were you using the IUP (Portable User Interface) GUI library?
>
> Your requests sounds very IUPish. ;-)
>
>

I understand that by looking this problem from the coding side, a
pointer makes much sense. But my problem is this:
I have a fixed set of modules. Each of them have the same properties
and one method. By checking the user's system, a module may or may not
be loaded and added into a treeview. Now, when the user clicks on a
treeview item, I want to load the properties of the corresponding
module. To do this, I can only know the selected module from the
treeview key, which is a string that matches the module name.

The problem would be here, as I cannot tell the Object.GetProperty to
fetch a property from this string.

I managed, though, to get around this problem. I just coded a huge
select case function, which returns the object from a given string.
But every time I add a module I have to add useless code that makes my
app more error prone and less maintainable.

Thanks!

PD: I heard a few times about the IUP library, but I never actually used it ;)

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to