Boriel Basic Forum
its fussy about #include - Printable Version

+- Boriel Basic Forum (https://forum.boriel.com)
+-- Forum: Compilers and Computer Languages (https://forum.boriel.com/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://forum.boriel.com/forumdisplay.php?fid=11)
+---- Forum: Help & Support (https://forum.boriel.com/forumdisplay.php?fid=16)
+---- Thread: its fussy about #include (/showthread.php?tid=393)

Pages: 1 2


its fussy about #include - slenkar - 2011-10-30

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


Re: its fussy about #include - boriel - 2011-10-31

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>



Re: its fussy about #include - nitrofurano - 2011-10-31

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?


Re: its fussy about #include - britlion - 2011-10-31

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.


Re: its fussy about #include - slenkar - 2011-10-31

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


Re: its fussy about #include - boriel - 2011-10-31

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


Re: its fussy about #include - slenkar - 2012-06-14

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


Re: its fussy about #include - britlion - 2012-06-14

Capital letters?


Re: its fussy about #include - slenkar - 2012-06-14

all lowercase

strangely it works in tommy gun but not in BorIDE


Re: its fussy about #include - boriel - 2012-06-14

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).


Re: its fussy about #include - LCD - 2012-06-15

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.


Re: its fussy about #include - slenkar - 2012-06-15

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

so..why does it work with tommy gun?


Re: its fussy about #include - LCD - 2012-06-15

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.


Re: its fussy about #include - slenkar - 2012-06-15

i sent you both files now


Re: its fussy about #include - LCD - 2012-06-16

slenkar Wrote:i sent you both files now
No new messages yet in contro panel... Sure you sent them to me?