[Gambas-user] a few suggestions for improvement

Oliver Stieber oliver_stieber at ...370...
Wed Jan 5 16:23:38 CET 2005


 --- Toni Schornboeck <lists at ...706...> wrote: 
> Hello Folks. 
> 
> First I want to say that I like the Gambas
> Environment very much.
> But there are a few things that I don't like.
> I want to explain what I don't like, why and how it
> could be improved.
> I would be glad if you could answer me and discuss
> my proposals. 
> 
> 
> After a Form is closed, the object still lives, but
> at the same time is 
> dead.
> I'd like to write code like:
> dim f as Form
> f=new Form(foo)
> f.ShowModal()
> return f.Result 
> 


> or something like that. But it is not possible,
> because f dies after 
> "ShowModal()"
> I think that is unecessary. f should stay alive
> until it gets out of scope.
> It would be OK, if a closed form can never be opened
> again, therefore a
> f.ShowModal()
> f.ShowModal()
> could raise an error. 
> 
> Take for example a InputBox. AFAIK the currently
> best solution is:
> static public function Run() as String
>  dim f as InputBox
>  f=new InputBox
>  f.ShowModal()
>  return value
> end 
> 
> private static value as String 
> 
> public sub Form_Close()
>  value=Text1.Text
> end 
> 
> This Solution is just Plain ugly and can lead to
> Bugs, when 2 InputBoxes are 
> open at the same time. 
> 
>  
> 
> A constructor has always to be public. Why?
> I'd like to declare a constructor private to force
> the user of my code to 
> use a static
> construct (that means: a static function that
> returns the object).
> This can sometimes be useful, for example when using
> a factory to prohibit 
> the user from directly instanciating
> objects. 
> 
> 
Try this....
Crate a form with a textbox [textbox1] and two buttons
[ok] and [cancle]

put the following code in the form

' Gambas class file
PRIVATE myString AS String 
PUBLIC FUNCTION getValue() AS String
  
  ME.ShowModal 
  RETURN myString
  
  
END
PUBLIC SUB Ok_Click()

  myString = textbox1.Text 
 ME.Close 
END

PUBLIC SUB Cancle_Click()

  ME.Close 

END


Create a new form object and call getValue().


===BUG===
interestingly doing a me.hide instead of a me.close
results in some strange behaviour.
The showmodal never returns but if i call getValue
from another form, that form becomes active again.
(But I can't close it!)

So I think me.hide should terminate the event loop of
the form but it isn't properly.


	
	
		
___________________________________________________________ 
ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com




More information about the User mailing list