[Gambas-devel] Passing things

Ken Schrock schrockk at ...26...
Mon May 12 05:23:49 CEST 2003


Sorry about posting to the wrong list
And thanks for answering my question anyway : -)
Particularly since it doesn't look like I will be using it anyway
Anal retentive, overbearing, "modular", "tightly scoped", "object oriented"
Languages just keep me going back to C

Since this is the developers form...
Come on guys, seriously, I mean really...

Form1.Listbox1.Insert(Textbox1.Text)
 (or its equivalent in C)

Is simple, clean, elegant, intuitive, logical
Your two examples are none of those things
Think about it, think about the hoops you make people jump through
Just to pass a single simple string from a client window to a parent window

This may get you an award from an egghead language designer's group
But nobody will use it. That is fine if that is what you really want to do
However, if you want anybody to use it, you have to rethink this
I'm not going to go through all that and nobody else will either

It is a shame, as it is an excellent idea, and well executed
But it appears crippled by dictatorial design philosophy
And really, we don't need any more of that kind
The landscape is littered with plenty already

Benoit Minisini wrote:

>Le Dimanche 11 Mai 2003 03:35, Ken Schrock a écrit :
>  
>
>>I am having trouble passing data between objects, classes, forms, etc.
>>
>>To add an element to a listbox
>>Pop up a new form for entry, ok so far
>>
>>But in Form2 if one tries to pass data to Form1 with
>>Form1.Listbox1.Add(whatever) it says it can't find ListBox1
>>It appears the controls, if created by the IDE, aren't made public
>>And there seems to be no option in the properties box to do so
>>
>>Call a public function - Says it isn't static - Make it static
>>It says you can't use dynamic things in a static function
>>
>>Ok guys, give me a hint here
>>    
>>
>
>Hi Ken,
>
>You should have posted this mail on the user mailing-list. This is list is for 
>people who are developing Gambas, not developing WITH Gambas !
>
>Controls are not public, they are private. This way, the bad old VB developer 
>must adopt a cleaner way of writing its program :-)
>
>Forms are not self-instanciable. I.e. if you have a form Form1, then Form1 is 
>the name of the class, not the name of an instance !
>
>Here is a bad example of how to solve your problem, but easy to understand:
>
>MyForm1 = NEW Form1
>MyForm1.Show
>
>*** In MyForm1:
>
>MyForm2 = NEW Form2(MyForm1)
>MyForm2.ShowModal()
>
>...
>
>PUBLIC SUB AddToListBox(sElt AS String)
>
>  ListBox1.Add(sElt)
>
>END
>
>*** In MyForm2:
>
>PRIVATE MyForm1 AS Form1
>
>PUBLIC SUB _new(hForm AS Form1)
>
>  MyForm1 = hForm
>
>END
>
>...
>
>MyForm1.AddToListBox(TextBox1.Text)
>
>
>Here is a better way to do that:
>
>*** In Form1:
>
>sElt = Form2.Run()
>IF sElt THEN ListBox1.Add(sElt)
>
>*** In Form2
>
>STATIC sResult AS STRING
>
>STATIC PUBLIC FUNCTION Run() AS STRING
>
>  DIM hForm AS Form2
>
>  hForm = NEW Form2
>  IF NOT hForm.ShowModal() THEN RETURN
>  RETURN sResult
>
>END
>
>...
>
>PUBLIC SUB btnCancel_Click()
>
>  ME.Close()
>
>END
>
>PUBLIC SUB btnOK_Click()
>
>  sResult = TextBox1.Text
>  Me.Close(TRUE)
>
>END
>
>Regards,
>
>  
>

-- 
Using Lindows 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/devel/attachments/20030511/cb9e76f4/attachment.html>


More information about the Devel mailing list