BlitzMaxPath() doesn't work from a module

BlitzMax Forums/BlitzMax Beginners Area/BlitzMaxPath() doesn't work from a module

Kistjes(Posted 2009) [#1]
Hi!

I want a module to read a data file. So I can change some data without recompiling the module.
Therefor I need to address the correct folder, which is the module folder.
But I get an error when the the BlitzMaxPath() function is called:
"Unable to locate BlitzMax path"

If I just type
Print BlitzMaxPath()
and compile this it gives me the correct path but when I type the same line inside the module I get the error.

Any ideas?
(see BRL.MaxUtil for the BlitzMaxPath() function)

[edit]
btw. The function ModulePath(modID$) doesn't work correct!
I have a module 'color.mod' in the following path:
c:/Program Files/BlitzMax/mod/kistjes.mod/color.mod

Print ModulePath("color") returns:
C:/Program Files/BlitzMax/mod/color.mod

Hey? Where's kistjes.mod???
I would call this a bug.

[edit2] oops. When you type
Print ModulePath("kistjes.color")
it returns the correct path. Sorry :/

PS: as you can see this is all a Windows issue. Don't know what happens in MacOS or Linux.


klepto2(Posted 2009) [#2]
BlitzmaxPath only works if the MaxIDE is running as far as i remember. It reads a runtime path variable.

Also try Modulepath("kistjes.color").


Floyd(Posted 2009) [#3]
If this is for your own use then just write the path into your program.

But in general BlitzMaxPath() would be meaningless since there may be many versions of BlitzMax on one computer. I have two that show up in my Start..All Programs... list. There are others which are not even installed, but are simply backup copies in folders.


Kistjes(Posted 2009) [#4]
If this is for your own use then just write the path into your program.


It's not only for myself. A collegue of mine is using the same modules, but he owns a Mac. It would be nice if the module was platform independent.

A bit more about the module and why I use an external data file.
The color module offers a Color type that is color space independent, as you can describe the color object in RGB, CMY(K) or HSV.
The color module also stores and offers a color palette (approx. 200 colors) that is used by our visual designers. This allows me to describe colors by there name (in stead of their RGB values).

The color table is stored in a data file. Each line has: name, red, green, blue.
I want to be able to modify the data file without recompiling the color module.

So, yes if it was only for myself, I could write the path into the module. That is exactly what I have done so far.

Suggestions are very welcome.


Brucey(Posted 2009) [#5]
I'm not sure I follow what you want to do.

You want the module code, which is compiled into your executable, to read some data from the module folder?

Wouldn't it be better to copy the data to your application folder at build-time, perhaps as part of a post-build script?

Here's a small example which copies a DLL from a module folder to the application folder :
# post build script
#
#
@define doPostInstall

	# only interested for Win32 platform
	
	if bmk.Platform() == "win32" then

		local path = utils.ModulePath("bah.fmod") .. "/lib/win32/"
		local file = "fmodex.dll"

		# copy FMOD
		sys.CopyFile(path .. file, %exepath% .. "/" .. file)
		
	end

@end

# run the post install
doPostInstall

The post-build script would run as part of the application build process.

Of course, you may be after something completely different, in which case my post is entirely pointless :-)

As Floyd says, a runtime (for your app) BlitzMaxPath() is useless, for the reasons he stated.


Kistjes(Posted 2009) [#6]
How stupid of me!!!
I'm just transposing the problem from the module to every application using that module.
I understand what I was doing wrong but I do not know how to describe.

So, let's forget all about this and get back to work ;)
Sorry bothering you.