Author Topic: Bizzarre error with $include  (Read 4914 times)

0 Members and 1 Guest are viewing this topic.

Offline eekee

  • Newbie
  • Posts: 3
    • View Profile
Bizzarre error with $include
« on: November 07, 2021, 01:53:37 am »
Hullo! I just used $include for the first time, and I got a bizzarre error. The screenshot shows the actual error along with the version. The compiler (or the IDE, at least,) appears to think there's some unbalanced use of SUB or FUNCTION, but there isn't. The included file, turtle.bas, compiles and runs, (it just doesn't do anything beyond initializing variables,) so I haven't forgotten END SUB or anything.

Oh... I think I see. Is it because turtle.bas contains SUB and FUNCTION definitions; can statements not be placed after such things? It looks like I need to make one of two changes to turtle.bas: split it up into separate initialization and routine files or put all its initialization into a subroutine. Is that right? (I'd like it to be wrong.)

Marked as best answer by eekee on November 26, 2021, 02:09:33 am

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: Bizzarre error with $include
« Reply #1 on: November 07, 2021, 02:49:23 am »
Indeed, the main body of the code may not appear after any subroutines. The standard pattern is to include "turtle.bi" at the top of the program with needed declarations, and "turtle.bm" at the bottom with Sub and Function implementations.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Bizzarre error with $include
« Reply #2 on: November 07, 2021, 09:01:09 am »
Welcome @eekee I look forward to fixing your Turtles code as stated and checking it out.

Oh not finished, don't forget to change Turtle Angle degrees into radians in Sin() and Cos() for Move use _D2R() degrees to radians.
« Last Edit: November 07, 2021, 09:20:44 am by bplus »

Offline Colonel_Panic

  • Newbie
  • Posts: 54
    • View Profile
Re: Bizzarre error with $include
« Reply #3 on: November 07, 2021, 04:04:27 pm »
hi eekee.

I ran into the $INCLUDE statement fairly recently as well.
My best tip for always being able to stop and figure out whats going wrong?

I go and PHYSICALLY cut and paste into code that section, and replace the include.
Problems? easier to see now.
go BACK and physically cut and paste and put the INCLUDE back in.
=====================================
physically cut and pasting back and forth several times? quickly cured my issues with $INCLUDE
(at least for now)

Offline xra7en

  • Seasoned Forum Regular
  • Posts: 284
    • View Profile
Re: Bizzarre error with $include
« Reply #4 on: November 08, 2021, 05:50:54 pm »
put the include on line 15


then run and adjust the program as needed. that is the only thing I see from the image. :-)

You may have to do some shuffling in the include file if there are sub/functions.

INCLUDE FILE
put all your programs at the beginning
then sub at the bottom, save it.
then when you "include" it, put it on line 15 (in this case), it should flow like the parent file.
just incase someone didn't mention that LOL

good luck!


I just like re-writing old DOS book games into modern QB64 code - weird hobby, I know!

Offline eekee

  • Newbie
  • Posts: 3
    • View Profile
Re: Bizzarre error with $include
« Reply #5 on: November 26, 2021, 07:08:42 am »
put the include on line 15
I tried this first, but got an even weirder error. :) When I entered `TPen down` in turtle-test.bas, (a normal use of TPen,) it told me "name already in use".

Indeed, the main body of the code may not appear after any subroutines. The standard pattern is to include "turtle.bi" at the top of the program with needed declarations, and "turtle.bm" at the bottom with Sub and Function implementations.
This worked, thanks! :)
Welcome @eekee I look forward to fixing your Turtles code as stated and checking it out.

Oh not finished, don't forget to change Turtle Angle degrees into radians in Sin() and Cos() for Move use _D2R() degrees to radians.
Good catch, thanks!