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

sundar j sundar_ima at ...251...
Thu Jun 14 07:40:33 CEST 2012


I have already tried and tested those option. Thoug it works i kept it as stand by option.  But i want my application to be universal and look native. In addition i want to know more on accessing variables from different class file.


From: Bruce <bbruen at ...2308...>
Sent: Thu, 14 Jun 2012 10:29:40 
To: sundar_ima at ...251..., mailing list for gambas users <gambas-user at lists.sourceforge.net>
Subject: Re: [Gambas-user] Access global variable from other .class
On Thu, 2012-06-14 at 04:28 +0000, sundar j wrote:

> 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 " &amp; accept &amp; " | 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.



Why not save yourself the bother and just use kdesu, kdesudo, gksu,

gksudo or pkexec (whichever fits your distro).



As in, for example:



        Shell "gksu -c somecommand" 





These all provide the privilege gui and probably much more security than

redoing it yourself.



hth

Bruce






More information about the User mailing list