Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / #include isn't including...

Author
Message
BN2 Productions
22
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 8th Oct 2008 05:50
For some reason, when I am calling #include, it still won't recognize my function names from the other file.

I thought that #include would make the program include the functions from the included source file. However, I use it, and then try to use one of the functions, and darkbasic just says "Unknown Command". I haven't really had this problem before, and to not use #include would be cumbersome and problematic in this case.

Thanks for your help

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 8th Oct 2008 06:01
Is this for the darknoob project? If it is I already throw the codes from the other file into the main file.
BN2 Productions
22
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 8th Oct 2008 06:09 Edited at: 8th Oct 2008 06:13
Yeah, the idea is that the function will exist in the main generating code, for testing and such. Then, rather than using a million write strings, I wanted to just include the main source file into the new code and run that function, but it won't let me compile, since it won't recognize the function.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Oct 2008 12:02
There are a couple of things to check:

First, make sure the #Include command is as all the way over to the left margin of your source. This was driving me crazy at one point trying to figure out why it wasn't working!

If you are running a script (say menu maker or whatever) and you output a file that is a series of functions, you cannot #include this file in the already running or compiled script. All includes are run when the script is first run/compiled. You cannot add any additional includes as the script is running. They just won't be recognized.

Make sure your #include path and file name are correct. The best scenario is to have the library in the same directory as the main source and only use the file name after the #include.

The only code that is actually loaded by an #include command are functions. So your wording:
Quote: "I wanted to just include the main source file into the new code and run that function"


seems to suggest you are including your main source into your library functions which won't work (unless the main source is one big function).

Enjoy your day.
BN2 Productions
22
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 8th Oct 2008 19:25
Sorry if I mis-stated, here is what I want.

I am making a menu-maker program for the challenge. Basically it generates code to make a menu based off of what you specify. There are a few functions that both the main source and the generated file will share. Rather than having the program re-write the same code, I wanted to just #include the original file so that the newly generated code can use the functions.

I will check my margins now, if it doesn't work, I will post my code.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
BN2 Productions
22
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 9th Oct 2008 00:08 Edited at: 9th Oct 2008 00:12
Ok, sorry for the double post, but I have both solved it and encountered a new problem with it.

It didn't work because the filename had spaces in it, which I guess is a problem. Eliminating that cause it to recognize the function call, but for some reason constantly tells me that I have used an unrecognized array. I know it is related to the #include command because when I rem it out, the program compiles fine (except for the missing command).

I eliminated the possibility of an array in the function that isn't in the generated code by copy and pasting the function into the generated file and reming out the #include command. It compiled fine, so I am not exactly sure what the problem is.

[Edit]
Solved it. The problem wasn't in the function I needed, it was the use of arrays in OTHER function in the file (that I wasn't using anyway) that didn't exist in the new file. To fix it I just copied over the dim statements and it works fine.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 10th Oct 2008 15:52
Another tip, if it hasn`t been mentioned yet:

If you use #include, make sure the file you are including has no spaces in its name, or it won`t load (at least that`s the case with me...).

Suicide is away of telling God, You can’t fire me I quit !!!!!
BN2 Productions
22
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 10th Oct 2008 23:58
Quote: "It didn't work because the filename had spaces in it,"


A little late, but thanks anyway. That would have been nice if they had it in the help files .

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?

Login to post a reply

Server time is: 2026-06-26 10:41:41
Your offset time is: 2026-06-26 10:41:41