Page 1 of 1

Cannot get Script IF statement to compile

Posted: Fri 8. Oct 2010, 19:52
by MrCreosote
Every IF statement in my scripts gets a compiler error saying it expected a ';' after the IF statement.

The following generates that error:

void test()
{
IF( 1 == 2 )
{
ShowTraceWin(true);
Trace(" 1 = 2 is TRUE" + "...\n");
}
}

The following trace is produced:

C:\_STOCKMODELSmb\01Preliminary\test.as

C:\_STOCKMODELSmb\01Preliminary\test.as (1, 1) : INFO : Compiling void test()
C:\_STOCKMODELSmb\01Preliminary\test.as (4, 2) : ERR : Expected ';'

1 Error(s).
0 Warning(s):

If I put the ';' where they want it (which is absurd), I get:

Compiling Script:
C:\_STOCKMODELSmb\01Preliminary\test.as

C:\_STOCKMODELSmb\01Preliminary\test.as (1, 1) : INFO : Compiling void test()
C:\_STOCKMODELSmb\01Preliminary\test.as (3, 2) : ERR : No matching signatures to 'IF(const bool)'

1 Error(s).
0 Warning(s):

_______________________________________________________

Having programmed in UNIX, this almost suggests that my script is not being interpreted as Angelscript.

I am pretty much at wits end on this one.

Thanks in advance,
Tom

========================================================================================
EDIT:

Looks like there is an issue with the filetype used for the script.

If I cut and past the code from ErrorCheck.as into my test.as file, it compiles.

If I type those statements, it produces the error.

I am going to scrutinize both files with a hex editor to see what the difference is.

It could be as simple as the handling of the CR and LF at each line end.

I did try saving Notepad text file as ANSI, Unicode, and UTF-8 (i think) and that made no difference.

Re: Cannot get Script IF statement to compile

Posted: Sat 9. Oct 2010, 10:48
by Admin
Hi, this is typed from my iPod so it will be a short one:

AngelScript, like C,C++,C# and Java is case sensitive. I.e., you have to put 'if' instead of 'IF'. Does that resolve your issue?

The first copiler message is because the Compiler thinks that you want to call a function with name 'IF' and thus it tells you to terminate that function call with a ';'. Once you do this the Compiler tells you that it does not know that function (no signature found for...).


Regards