Not compiling if subs are closed/folded

Previous topic - Next topic

ampos

In my prog I have a main loop and 3 SUBs.

LOOP
sub paint
sub init
sub mouse

If all the subs are unfolded, the game compiles and run fine. Sub Mouse doesnt affect compiler error

PAINT sub FOLDED & INIT sub unfold
"Krakout.gbas"(88) error : IF without ENDIF / THEN

PAINT sub UNFOLD and INIT sub fold
Wordcount:125 commands
compiling:
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp: In function `DGInt __GLBASIC__::inicia()':
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:573: error: a function-definition is not allowed here before '{' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:594: error: a function-definition is not allowed here before '{' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:601: error: a function-definition is not allowed here before '{' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp: At global scope:
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:614: error: expected `}' at end of input
*** FATAL ERROR - Please post this output in the forum

check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

MrTAToad

I would check to make sure you have an ENDIF command in the inicia function/subroutine.

Or you need to upgrade GLBasic.

ampos

GLB is updated.

Currently I am on free version

If it is a missing IF/ENDIF (which I am unable to locate), why does it works when SUBs are unfolded? Or why the strange error when one sub is fold and the other unfold?

I am on Win7/64, and it also gives me the same error on Win XP/64.

This is driving me crazy.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

MrTAToad

Can you provide the code you are using ?  SUB's with IF/ENDIF work fine here...

ampos

This little test program just gives the error, but ony if the SUBs are closed.

Code (glbasic) Select
// --------------------------------- //
// Project: Krakout
// Start: Monday, September 13, 2010
// IDE Version: 8.085


TYPE Mouse
   x
   y
   b1
   b2
ENDTYPE
GLOBAL mouse AS Mouse

DIM r#[8][3]

modo=4     // 1=320x200 2=480x320 (IPhone) 3=640x400 4=960x480 (Iphone4) 5=1280x800

GOSUB inicia

REPEAT


SHOWSCREEN

UNTIL salir=1

// ------------------------------------------------------------- //
// ---  INICIA  ---
// ------------------------------------------------------------- //
SUB inicia:

SETCURRENTDIR("Media") // seperate media and binaries?
SYSTEMPOINTER TRUE
IF modo=4
SETSCREEN 960,640,0
pat$="960/"
ratio#=3.0
ENDIF

ENDSUB // INICIA

// ------------------------------------------------------------- //
// ---  PINTACOSAS  ---
// ------------------------------------------------------------- //
SUB pintacosas:



ENDSUB // PINTACOSAS


// ------------------------------------------------------------- //
// ---  MIRAMOUSE  ---
// ------------------------------------------------------------- //
SUB miramouse:



ENDSUB // MIRAMOUSE


// ------------------------------------------------------------- //
// ---  MUEVECOLORES  ---
// ------------------------------------------------------------- //
SUB muevecolores:



ENDSUB // MUEVECOLORES


check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

ampos

Amazing...

I created a new proyect, and typed my entire source to get it working again.

I did a copy and paste on a plain TXT windows file. Then I was copying on a new source bits of code, and some of them work and other dont. Very strange. So I ended typing most of the source.

I will keep the "mistery" source on disk to be sent to Kitty, so he can find any strange ascii code hidden in the source, and maybe find how the IDE put it there.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

MrTAToad

#6
Ah ha - I get it too...

The code its generating is :

Code (glbasic) Select

DGInt inicia(void){
   __PPRegisterFunction
#undef __FKT
  #define __FKT __l_dbg_cont
  __VAR_CONTAINER __FKT;

#undef __GLBNO__
#define __GLBNO__ 32
ON_DEBUG(0,32);
SETCURRENTDIR(CGStr("Media"));
//seperate media and binaries?;SYSTEMPOINTER TRUE;IF modo=4;SETSCREEN 960,640,0;pat$="960/";ratio#=3.0;ENDIF;;ENDSUB //INICIA;.

#undef __GLBNO__
#define __GLBNO__ 33
//------------------------------------------------------------- //.

#undef __GLBNO__
#define __GLBNO__ 34
//---  PINTACOSAS  ---.

#undef __GLBNO__
#define __GLBNO__ 35
//------------------------------------------------------------- //.

#undef __GLBNO__
#define __GLBNO__ 36

#undef __GLBNO__
#define __GLBNO__ 37
ON_DEBUG(0,37);
// ------------------------ //
DGInt pintacosas(void){
   __PPRegisterFunction
#undef __FKT
  #define __FKT __l_dbg_cont
  __VAR_CONTAINER __FKT;

#undef __GLBNO__
#define __GLBNO__ 38
ON_DEBUG(0,38);
return 0;
}


The IF/ENDIF commands are causing the problem - even though they are matching, the code folding is obviously having trouble with them...

Slydog

It looks like it's merging the lines after '//seperate media and binaries?'.
Try adding an extra line before:
Code (glbasic) Select
SYSTEMPOINTER TRUE
to see if that helps.
(still a GLBasic bug though!)
Maybe you don't have both ASC(13)+ASC(10) (CR+LF) after the '?', but only one of them?
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

MrTAToad


ampos

Definitly a bug, related with comments

Code (glbasic) Select

repeat
   print "TEST",10,10   //just a test. Place a TAB before //
   showscreen

until final=1

SUB testing:

endsub


But now, if I cut&copy, it gives the error:

Code (glbasic) Select

repeat
   gosub testing
   showscreen

until final=1

SUB testing:
   print "TEST",10,10   //just a test. Place a TAB before //
endsub


And only if SUB is folded. If the comment is removed from inside the SUB, it works.

Can someone recreate this one?
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

MrTAToad

Yes, happens here too - this sort of thing has happened before unfortunately...

ampos

I have limited it even more. No comments inside SUBs. Strange.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE