FAQ  •  Register  •  Login

its fussy about #include

<<

slenkar

Posts: 267

Joined: Sun Feb 13, 2011 3:33 am

Location: Kentucky US, used to be Birmingham UK

Post Sun Oct 30, 2011 7:53 pm

its fussy about #include

the compiler doesnt like it when #include statements are not the first thing in a line
so this will work:
#include
but this will not:
<space> #include
the error message complains about a period or full stop being in the wrong place which is not the right issue.

This may turn someone off the language if they cant solve the problem
<<

boriel

Site Admin

Posts: 1158

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Mon Oct 31, 2011 10:19 am

Re: its fussy about #include

This is not exactly a bug. Every preprocessor line *must* start with # as a first character. Otherwise is a BASIC line (which will trigger a syntax error).
To tabulate preprocessor lines, use tab *after* the # symbol:

  Code:
REM this is Wrong
    # include <file.bas>

REM this is OK
#    include <file.bas>
<<

nitrofurano

Posts: 152

Joined: Thu Sep 29, 2011 12:44 pm

Location: Porto, Portugal

Post Mon Oct 31, 2011 3:24 pm

Re: its fussy about #include

btw, about #include, can i only use include on libraries placed at '(installed-directory)/library/' ? would be great if the compiler would check them also on other directories, like from a './library/' where the compilable .bas code is, for a more comfortable use when we create our own libraries, and don't want to mess them with the default ones? or maybe i'm missing some important documented information? what do you all think?
<<

britlion

Posts: 680

Joined: Mon Apr 27, 2009 7:26 pm

Location: Slough, Berkshire, UK

Post Mon Oct 31, 2011 4:41 pm

Re: its fussy about #include

IF you use #include "file.bas" instead of <file.bas> it will look in the same directory as the current basic file, rather than in the library.
<<

slenkar

Posts: 267

Joined: Sun Feb 13, 2011 3:33 am

Location: Kentucky US, used to be Birmingham UK

Post Mon Oct 31, 2011 4:50 pm

Re: its fussy about #include

britlion wrote:IF you use #include "file.bas" instead of <file.bas> it will look in the same directory as the current basic file, rather than in the library.


I was having trouble with that myself thanks
<<

boriel

Site Admin

Posts: 1158

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Mon Oct 31, 2011 7:51 pm

Re: its fussy about #include

Notice that all this behavior (the # placement and the "filename.bas" and <filename.bas> includes) is the cpp (C PreProcessor) standard behavior. :wink:
<<

slenkar

Posts: 267

Joined: Sun Feb 13, 2011 3:33 am

Location: Kentucky US, used to be Birmingham UK

Post Thu Jun 14, 2012 4:05 pm

Re: its fussy about #include

I split up my code into 2 files so now I have to include linefile.bas
I tried this:

#include "linefile.bas"


but it says

Error: cannot open "linefile.bas" file.

im sure it is in the same directory as main.bas
<<

britlion

Posts: 680

Joined: Mon Apr 27, 2009 7:26 pm

Location: Slough, Berkshire, UK

Post Thu Jun 14, 2012 4:55 pm

Re: its fussy about #include

Capital letters?
<<

slenkar

Posts: 267

Joined: Sun Feb 13, 2011 3:33 am

Location: Kentucky US, used to be Birmingham UK

Post Thu Jun 14, 2012 5:07 pm

Re: its fussy about #include

all lowercase

strangely it works in tommy gun but not in BorIDE
<<

boriel

Site Admin

Posts: 1158

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Thu Jun 14, 2012 6:08 pm

Re: its fussy about #include

Can you run it from the command line?
  Code:
zxb -Tab main.bas

If it does not complain, it's probably not related to the compiler. Also check lettercase in the name (some OS requires the letter case to match the file name).
<<

LCD

Posts: 521

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Fri Jun 15, 2012 12:05 am

Re: its fussy about #include

Strange... I tested it in BorIDE and it was working fine, even without the path but in same directory as the main file, it found and included the file without problems.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

slenkar

Posts: 267

Joined: Sun Feb 13, 2011 3:33 am

Location: Kentucky US, used to be Birmingham UK

Post Fri Jun 15, 2012 2:19 pm

Re: its fussy about #include

when I ran the command line it said cant open file like with BorIDE,

so..why does it work with tommy gun?
<<

LCD

Posts: 521

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Fri Jun 15, 2012 8:29 pm

Re: its fussy about #include

slenkar wrote:when I ran the command line it said cant open file like with BorIDE,

so..why does it work with tommy gun?

When you send me all files, I can try. At moment I'm not at home. Will return sunday, but can download small files and check them.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

slenkar

Posts: 267

Joined: Sun Feb 13, 2011 3:33 am

Location: Kentucky US, used to be Birmingham UK

Post Fri Jun 15, 2012 9:48 pm

Re: its fussy about #include

i sent you both files now
<<

LCD

Posts: 521

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Sat Jun 16, 2012 10:37 am

Re: its fussy about #include

slenkar wrote:i sent you both files now

No new messages yet in contro panel... Sure you sent them to me?
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Next

Return to Help & Support

Who is online

Users browsing this forum: No registered users and 0 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO