Test in the script console :
-----------------------------
if (1) print(_T("1")); else print(_T("2")); print(_T("3"));
or
if (1) {print(_T("1"));} else {print(_T("2"));} print(_T("3"));
------------------------
Will produce an error:
------------------------
Filename: ScriptConsole
Error:end of statement expected (; or If)
Details: ScriptConsole line = (1) column = (49) : error end of statement expected (; or If)
=================
As long as the "IF" statement does not follow the statement, there will be no error.
For example:
print(_T("3"));if (1) print(_T("1")); else print(_T("2"));
====================================================
I originally wanted to insert the version number of the library file in the path, so I used the following settings.
If the project does not provide a version number variable "wx_ver", the global variable "wx.ver" is used:
The compile variable :
path_inc =
$(CODEBLOCKS)\..\..\include\wxWidgets\[[local v_1=ReplaceMacros(_T("$(wx_ver)")); local s_1=ReplaceMacros(_T("$(#wx.ver)")); if (!(v_1.IsEmpty() || v_1.len()<3)) print(s_1); else print(v_1);]]\include" -I"$(CODEBLOCKS)\..\..\lib\wxWidgets\[[local v_1=ReplaceMacros(_T("$(wx_ver)")); local s_1=ReplaceMacros(_T("$(#wx.ver)")); if (!(v_1.IsEmpty() || v_1.len()<3)) print(s_1); else print(v_1);]]\shared\dll_i686\mswu$(debug_wx)
My project build option -> search directories ->Compiler :
$(path_inc)
-------------------------------------------
No error if there is no second [[ ... ]] .
--------------------------------------------
After a lot of combination tests, I found that it was the kind of error I encountered earlier.
I couldn't add any script content after the "if" statement, otherwise it would go wrong.
You should copy and paste the error message, if ever possible.
The error message is:
ScriptConsole line = (1) column = (49) : error end of statement expected (; or lf)
and not
ScriptConsole line = (1) column = (49) : error end of statement expected (; or If)
It misses a linefeed (or a semicoln), not an If-statement.
If you add a semicolon after the else-clause or place curly brackets ({and}) around the whole If-statement, it works:
> {if (1) {print(_T("1"));} else {print(_T("2"));}} print(_T("3"));
1
3
> if (1) print(_T("1")); else print(_T("2"));; print(_T("3"));
1
3
I assume, that only the first print belongs to the if-statement, otherwise you need to put the whole else-clause in curly-brackets.
> if (1) {print(_T("1"));} else {print(_T("2")); print(_T("3"));};
1
> if (0) {print(_T("1"));} else {print(_T("2")); print(_T("3"));};
2
3