array problems
I'm using 2.4.1, and I have a problem with arrays. Here's some example code:
int[] test(5);
int a=3;
test[0]=a;
int b;
b=test[0];
Now this gives "Expected data type" for the third line, and "Expected identifier" for the last one. Is it supposed to work like this?
Testing Angelscript further, with the following code:
struct testStruct{
int variable;
};
testStruct tempStruct;
tempStruct.variable=1;
The last line gives an "Expected identifier". I wonder if I'm using it wrong?
Thanks for any help!
struct testStruct{
int variable;
};
testStruct tempStruct;
tempStruct.variable=1;
The last line gives an "Expected identifier". I wonder if I'm using it wrong?
Thanks for any help!
Strange. These are parser errors, but I can't see anything wrong with your code, unless...
Could it be that the tokenizer is unable to separate the tokens correctly? Try adding whitespaces between the tokens and see if it works. Example:
If that works then it is of course a bug in the library that I will correct a.s.a.p. I will add this test to the test suite in order to make sure it works in future versions.
Could it be that the tokenizer is unable to separate the tokens correctly? Try adding whitespaces between the tokens and see if it works. Example:
test[0] = a;b = test[0];...tempStruct.variable = 1;
If that works then it is of course a bug in the library that I will correct a.s.a.p. I will add this test to the test suite in order to make sure it works in future versions.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Unfortunately it does not help. I'm going to see if any of the sample programs exhibit the same behaviour. Strangely the library seems to work fine for me otherwise.
That lead the to the right track somehow, it turns out the code I was describing was outside a function, and thus did not work. I had assumed it would work like old C, and writing such code outside functions would be alright.
One bit of wisdom from this could be to put in place some sort of compiler check and special error message for this. I of course won't be needing it since I won't be writing code outside functions anymore, and one can always hope nobody else will make that mistake. ;)
By the way, thanks for the great library WitchLord! I'll drop you a link to the game once we have something to show off with.
One bit of wisdom from this could be to put in place some sort of compiler check and special error message for this. I of course won't be needing it since I won't be writing code outside functions anymore, and one can always hope nobody else will make that mistake. ;)
By the way, thanks for the great library WitchLord! I'll drop you a link to the game once we have something to show off with.
I see. That would indeed cause these errors. I'll see if there is someway that I can give a more helpful error message if someone tries to put statements in the global scope.
I look forward to seeing the game you're making.
Regards,
Andreas
I look forward to seeing the game you're making.
Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement