On Sun, 2012-05-06 at 13:06 +0100, RICHARD WALKER wrote:
> Greetings to the list on a fine Sunday afternoon (should be outside
> enjoying it instead of hacking on a new project!).
> 
> I am having difficulty understanding the correct way to program with
> arrays in Gambas 3. The documentation has this warning notice:
> 
> In Gambas 3, embedded arrays cannot be used as local variables
> anymore. But they can be public!
> 
> This is from http://gambasdoc.org/help/lang/arraydecl?show&v3
> 
> The same page shows that local variables are declared as:
> 
> (1) DIM Identifier AS [ NEW ] Datatype [ Array dimensions ... ]
> 
> Embedded arrays are defined as being declared in this way:
> 
> (2) [ STATIC ] { PUBLIC | PRIVATE } Identifier [ Array dimensions ...
> ] AS Native Datatype
> 
> My difficulty is that I do not understand how an embedded array
> declared with syntax (2) can be taken for a local variable, which is
> declared with syntax (1). Is there some other non-technical meaning
> for "local variable" which is intended in the notice?
> 
> Richard
Ah! Richard,

Isn't language a wonderful thing.
Or syntax, if you prefer.

Look very, very carefully at the bits before "Identifier" in that help
page.  Now think, where do I use those keywords "DIM" and "PRIVATE" when
declaring a variable (or a constant for that matter).

Got it?

No?

Class Frog

Static Private maxlegs as Integer
Private legs as integer

Public Sub _new(iLegs as Integer)

Dim mylegs as Integer

If iLegs<=Frog.maxlegs then 
  mylegs=iLegs
  legs=mylegs
Endif

End

Static Public Sub _init()
  maxlegs=3
End


If the above hasn't got frogs legs, eggs and whatever dancing before
your eyes, go back and look at each of the 37 words.

It may take some practice.... it's taken me about 3 years :-)

Bruce 


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to