[Gambas-user] Gambas IDE 1.9.49-2 New Function formating.
ron
ronstk at ...239...
Mon Jun 25 17:27:14 CEST 2007
On Monday 25 June 2007 12:45, Andreas Kostyrka wrote:
> 2007/6/24, Benoit Minisini <gambas at ...1...>:
> >
> > The highlighting routine is not yet clever enough to make the difference
> > between the two new syntaxes.
> >
> > This is not a big problem at the moment, as the compiler makes the
> > difference.
>
>
>
> This is a big problem. I somehow think that the IDE should allow me to enter
> legal code, without "fixing it" to something illegal?
>
> The issue is not the highlighting thing, the issue is the IDE fixing it wrongly.
A possible missuse of New and at the wrong place?
>
> Andreas
>
Explanation to help:
> $entries.Add(New("ABC", arg1))
Assuming $entries is a array variable.
You want to add something and that is between the parenthesis.
$entries.Add( what_you_want_to_add )
Here the 'what_you_want_to_add' is defined as 'New("ABC", arg1)'
What is that 'New' thingy ??
New is a method for creating objects and normal used as:
'Declares a table of strings
DIM aTable AS NEW String[12, 8]
See:http://gambasdoc.org/help/comp/gb/string[]/_new
'And usage of it in assignment in a loop
DIM aTable AS String[12, 8]
FOR x = 1 TO 10
aTable = New String[12, 8]
..... ' do somthing with aTable
entries.Add(aTable)
NEXT
------
Button = NEW Button(ME) AS "MyButton"
PUBLIC PROCEDURE MyButton_Click()
PRINT "My button was clicked !"
END
See:http://gambasdoc.org/help/lang/new
-----
hButton = New("Button", hParent)
'has exactly the same effect as:
hButton = NEW Button(hParent)
See:http://gambasdoc.org/help/lang/new2
-----
So if "ABC" is something like "Button" and arg1 like hParent then
theoretical .Add( New("ABC", arg1) ) should be correct.
However parsing complex constructions as argument or the .Add() does
not work well as you found.
The problem is the New inside the .Add() here and that expects a variable.
You can't also use .Add(Sqr(4),arg1) or .Add( MySubRoutine("anykey") , arg1 ) :)
!!! And how should we anyway know what "ABC" and arg1 are in your example? !!!!
Why make it so difficult when next code solved all possible miss
understanding by syntax parser and the human developer?
MyObjectToAdd = New("ABC",arg1) ' or New ABC(arg1) ?
$entries.Add( MyObjectToAdd )
Hope this gives some understanding.
---
Ron
More information about the User
mailing list