[Gambas-user] File opening dialog and one more question

Dmitrij Malkov dima.malkov.russia at ...626...
Fri Jan 6 16:33:28 CET 2012



bbb888 wrote:
> 
>> ? And why I can't create objects of class CUnits after calling
>> CUnit.HowManyUnits()?
> 
> A) Because gambas syntax doesn't allow it.
> B) What in the great scheme of things has this got to do with Static?
> 

About "B". 
I'm not an englishman, so, as I understood you, you are wondered of how the
function CUnit.HowManyUnits() refers to Static or what It does with static
variables or what the practical value of class CUnits and this function is.

This code I wrote after reading about Static variables and functions in the
C++ book. In that book autor explained that Static variables are not cloned
when new object of some class are been existed and every object can read and
modify the static variables that are common for all of them. Besides, Static
variables can be read and modified without any object just by
"ClassName.Function" where "Function" is a static function that works with
static variables. The code I have written here is a translated to Gambas
code from that book about C++, It illustrates that static variables are not
cloning while creation of a new object. 

I wondered that the code
-------------------------------------------
Public Sub Main()
   CUnit.HowManyUnits()
End
-------------------------------------------
works, but the code
-------------------------------------------
Public Sub Main()
   CUnit.HowManyUnits()
   Dim Unit1 As New CUnit 
End
-------------------------------------------
does not ("Dim is unexpected"). I awaited a message like "CUnit is not an
object" in a worst time. You answered, that gambas syntax doesn't allow it.
But in the documentation the next only is written: "All DIM declarations
must be in the FUNCTION or SUB before the first executable command." I don't
see that I have breaked this.

Thank you.

------------
Dmitrij Malkov



-- 
View this message in context: http://old.nabble.com/File-opening-dialog-and-one-more-question-tp33085420p33093687.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list