Using Sub button to create new subroutine inserts before last line of code

Previous topic - Next topic

Cliff3D

So if there's no white space at the end of your program, just...


Code (glbasic) Select
main:
code...
more code...
even more code...
END


before your subroutine, afterwards there will be:

Code (glbasic) Select
main:
code...
more code...
even more code...
// ------------------------------------------------------------- //
// ---  MYSUBROUTINE  ---
// ------------------------------------------------------------- //
SUB ShowPlayField:



ENDSUB // MYSUBROUTINE


END


which fails to compile with this error:

*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.8.044 SN:1c15d767 - 2D, WIN32
"OneMore.gbas"(41) error : command not inside function or sub

Moru

Make your program like this:

Main:

Loop

End

Everything after this line has to be functions or data:
Function x:
endfunction

Cliff3D

Quote from: Moru on 2010-Sep-08
Make your program like this:

Main:

Loop

End

Everything after this line has to be functions or data:
Function x:
endfunction

Yes. If your last line is "END" and you use the "Sub" button to create a new subroutine, it will place it BEFORE your last line, not after it. The Sub button is prone to CAUSING the errorm which might fox newbies.