Include Function

BlitzPlus Forums/BlitzPlus Programming/Include Function

genjibox(Posted 2004) [#1]
Lately while programming in BlitzPlus, I have been getting tired of having to type out all of the include functions by hand, so I thought I'd make a function to load them for me. But after making it and testing, it returns an error of 'Expecting include filename' If someone could please help out by showing me whats wrong I would be very greatful, thank you for your time.

Function load_scripts(path$)
	stream = ReadDir(path$)
	Repeat
		file$ = NextFile(stream)
		If Instr(file$,"bb") = 0
			;Null
		Else
			included$ = path$ + "/" + file$
			Include included$
			included$ = ""
		EndIf
	Until file$ = ""
	CloseDir(stream)
End Function



Floyd(Posted 2004) [#2]
This can't work.

Include is a preprocessing step. It happens when the code is compiled. So it can't be determined when the program is running.

You could change this so load_scripts(path$) is part of a separate program. It would read all the file names and write a new file "MyIncludes.bb" which would look like this:

Include "myfile1.bb"
Include "myfile2.bb"

Run this before compiling your main program, which would simply include the file "MyIncludes.bb".

Another possible snag is the order in which files are included.
But if the included files just contain functions then that shouldn't be a problem.


Hotcakes(Posted 2004) [#3]
Or, better yet, get www.proteanide.co.uk and use the project manager. =]