[Gambas-user] R: Access global variable from other .class

Jesus ea7dfh at ...2382...
Thu Jun 14 19:33:11 CEST 2012


Resent message. Don't know why the list didn't get it...

-------- Mensaje original --------
Asunto: Re: [Gambas-user] R:  Access global variable from other .class
Fecha: Thu, 14 Jun 2012 16:11:26 +0200
De: Jesus <ea7dfh at ...2382...>
Para: gambas-user at lists.sourceforge.net

El 14/06/12 10:58, Ru Vuott escribió:
> I do not know if I understand correctly. However, if you want to access
> the value of a variable from the parent class, or from another class, you
> must set this variable as "global" and "Public". In addition, you must set
> as "public" also controls the form and symbols of the "modules" in the options
> of ownership of your program.
>
> bye


Again, this is not a good idea/practice. Controls might remain Private
and you might use the OOP approach using Properties and/or getters and
setters. This is by far the most reliable and maintainable way to go, IMHO.

I don't want to enter in an endless discussion about it, but this is
only a good advise.

Regards,

Jesus



>
>
>
> --- Gio 14/6/12, sundar j<sundar_ima at ...251...>  ha scritto:
>
>> Da: sundar j<sundar_ima at ...251...>
>> Oggetto: [Gambas-user] Access global variable from other .class
>> A: "mailing list"<gambas-user at lists.sourceforge.net>
>> Data: Giovedì 14 giugno 2012, 06:28
>> I am trying to write a code for
>> accepting user password in a input box/textbox when user
>> click on button from main form. For user input i have
>> created new form named sudo.form and codes are in sudo.class
>> file. This sudo.class accepts user password through textbox
>> (hidden) and store it in global variable named password.
>> sudo form is shown when user click on button from main form.
>> Now my problem is that how do i access/capture this global
>> variable (password) from main program? For example,
>> accessing module variable (from sudo.module) we do it like:
>>
>> Public Sub function()
>> Dim accept as string
>> .
>> .
>> accept = sudo.password
>> Shell "echo "& accept& " | sudo -S
>> somecommand"
>> .
>> .
>> End
>>
>> Right now i do not have a code to post but will come back
>> later. But the general idea which i am trying to do is
>> explained above.
>

-- 
Jesus Guardon

-- 
Jesus Guardon




More information about the User mailing list