Cannot get Script IF statement to compile

This forum is dedicated to everything about MemBrain Scripting. All Questions or other contributions with respect to scripting should be placed here.
Especially, if you have an interesting script that you might want to share with other MemBrain users, please post it within a new topic in this forum. Try to choose a title for your topic that allows other users to quickly identify the basic purpose of your script.
Post Reply
MrCreosote
Posts: 55
Joined: Wed 21. Jul 2010, 18:43

Cannot get Script IF statement to compile

Post by MrCreosote » Fri 8. Oct 2010, 19:52

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.

User avatar
Admin
Site Admin
Posts: 438
Joined: Sun 16. Nov 2008, 18:21

Re: Cannot get Script IF statement to compile

Post by Admin » Sat 9. Oct 2010, 10:48

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
Thomas Jetter

Post Reply