From the Help, GetNetError is a function which returns a double.
I cannot get an assignment to work so I made a test case.
I cannot get the following test case to compile:
double a;
void main()
{
a = GetNetError;
}
When I try to compile, I get an error:
ERR: Can't implicitly convert from 'GetNetEditor' to 'double&'.
Its amazing how things clear up after a night's sleep (!)
Thanks
Tom
__________________________________________
EDIT: FOUND MY OWN ANSWER:
Assignment is wrong. Must be:
a = GetNetError();
You MUST include the empty parenthesis.
(For some reason I thought when you called a func or sub, you did not use empty paren. Perhaps this works when you call a sub, however, it appears that it does not work when using a function.)
It is amazing how problems can become crystal clear after a night's sleep (!)
Trouble with GetNetError Function
-
- Posts: 55
- Joined: Wed 21. Jul 2010, 18:43
Trouble with GetNetError Function
Last edited by MrCreosote on Fri 22. Oct 2010, 19:09, edited 1 time in total.
Re: Trouble with GetNetError Function
A function call in AngelScript, just like in C or C++, must always have brackets in the end. These brackets contain the parameters. If a function does not take any parameters the brackets are left empty but must still be there. This way the compiler can distinguish between a function call and any other expression. I.e. You must type:
Code: Select all
a = GetNetError();
Thomas Jetter
-
- Posts: 55
- Joined: Wed 21. Jul 2010, 18:43
Re: Trouble with GetNetError Function
I just discovered that the compiler will not flag an error when a procedure/subroutine is called w/o the empty parenthesis. (Is there a reason for this?)
So when you try to execute, that call statement does nothing.
It is interesting that the compiler will flag a function but not a procedure.
Thanks for the insight,
Tom
So when you try to execute, that call statement does nothing.
It is interesting that the compiler will flag a function but not a procedure.
Thanks for the insight,
Tom
Re: Trouble with GetNetError Function
The AngelScript compiler obivously does not raise a warning if an expression without effect is compiled.
I've posted a suggestion for improvement on this in the AngelScript forum so there is a good chance that this will get improved in the future.
In general, AngelScript does not distinguish between a function and a sub or procedure as VB or Pascal do for example.
Moreover, in C/C++ the name of a function represents its address and thus is a valid expression.
I.e. just stating a function name is a valid C/C++ expression, although without effect. This seems to be the case also in AngelScript although I'm not really sure if AngelScript supports function adresses to be used inside scripts.
Examples for expressions without effect:
Cheers
I've posted a suggestion for improvement on this in the AngelScript forum so there is a good chance that this will get improved in the future.
In general, AngelScript does not distinguish between a function and a sub or procedure as VB or Pascal do for example.
Moreover, in C/C++ the name of a function represents its address and thus is a valid expression.
I.e. just stating a function name is a valid C/C++ expression, although without effect. This seems to be the case also in AngelScript although I'm not really sure if AngelScript supports function adresses to be used inside scripts.
Examples for expressions without effect:
Code: Select all
int myVar = 5;
myVar; // Valid expression but without effect. Could raise a warning when being compiled.
Code: Select all
void SomeFunction()
{
...
}
SomeFunction; // Valid expression but without effect. Should raise a warning when being compiled.
Cheers
Thomas Jetter