[Gambas-user] Gambas IDE 1.9.49-2 New Function formating.
Benoit Minisini
gambas at ...1...
Tue Jun 26 21:19:01 CEST 2007
On mardi 26 juin 2007, ron wrote:
> On Tuesday 26 June 2007 11:41, Andreas Kostyrka wrote:
> > Nope, as I've pointed out already, NEW is an operator. New is a function.
>
> If your 'New' is a _function_, I must assume it is made by you in your
> code.
>
> As the syntax give examples as:
>
> a) hButton = New("Button", hParent) ' or
> b) Button = NEW Button(ME) AS "MyButton" ' or
> c) DIM iMyArray AS NEW Integer[] ' and this one
>
> 'New' here is not a simple function but a constructor method and
> returns a object, yes functions returns something to. (the way i see)
>
> Did you made a function yourself as:
>
> FUNCTION New(sString,vArgs)
> dim iTmp as INTEGER
> itmp=CINT(sNumber)
> iTmp=iTmp+iNumber
> return iTmp
> END
>
> Beside both New' and NEW' are reserved words in gambas and the example
> function above should even normally not be allowed to make yourself.
>
> Simply as your previous code is $entries.Add(New("ABC", arg1))
> you do not tell exact what you want.
> I assume "ABC" is just typing something but it is not unimportant.
>
>
> The "ABC" argument should be a control or data type or results to it.
> There is no control named "ABC" or data type with that id.
>
> The only conclusion is that you made yourself the function 'New'
> which clashes with the reserved keywords in gambas.
> Gambas can only highlight/beautify the code as is done
>
> $entries.Add(New("ABC", arg1)) ' you try syntax rule 'a'
>
> gets changed by the IDE to
>
> $entries.Add( NEW ("ABC", arg1)) ' because function New("a",b) can't
>
> What happen if you do $entries.Add(New("Button", arg1)) ?
>
> As I suggest previous, do it with two lines and this complex
> construction could/should be solved.
>
> Lets wait what Benoit say more about it. I can be wrong to :(
>
>
> Ron
>
Guys, you really make a problem from nothing. :-)
NEW is a special assignment operator, *and* a function. As Gambas is not case
sensitive, you can write it as you like: NEw, NeW, nEw, and so on.
The only little problem is the syntax highlighter. It is just not clever
enough for making the difference between NEW as an operator, and New as a
function.
The compiler can do the difference: it is just a matter of seeing if there is
a brace after the NEW keyword.
This is not a bug. Just a little visual glitch :-)
Note that I may fix it in the future. :-)
Regards,
--
Benoit Minisini
More information about the User
mailing list