Variable path names

Blitz3D Forums/Blitz3D Beginners Area/Variable path names

Blitzplotter(Posted 2006) [#1]
I had searched through the file path examples and have not been able to resolve a coding problem. I have used the following code to try and read a file path from an .ini file.

String manipulation resolved my no file found problem.

Removed original code, updated code below. The reason my variable path was not being recognised was it was constructed :-

"data1.dat"

I have included the code I 'hacked' together to strip of the speechmarks from the pathname. Hope this is useful to somebody.....

When I hard coded the path, it worked fine. But when I attempted to use the 'variable' I had read in from a .txt file, the file could not be found.


WolRon(Posted 2006) [#2]
Code looks fine.
You didn't supply us with enough information.
You didn't show us the returned value from the ReadString$ command. I suspect that you intended to use the ReadLine$ command, not the ReadString$ command.


Blitzplotter(Posted 2006) [#3]
Your suggestion has got me thinking though.... thanks.


Blitzplotter(Posted 2006) [#4]
I modified my code so that the Readline$ is used again and pasted some text on the end to make sure
no 'hidden' chars, it still initially failed to recognise my variable path ? transferred the string into an array, stripped of the speechmarks, hey presto!



When I hard coded the path, it worked fine. But when I attempted to use the 'variable' I had read in from a .txt file, the file could not be found. Incidentally the 'variable' path printed to the screen had looked exactly the same as the hard coded path, however the " " at the start and end of the path prevented the file from being recognised.

Thanks to RWolbeck for his input.


Sir Gak(Posted 2006) [#5]
By default, Blitz looks for info to be loaded in the same directory/folder as where the Blitz program was loaded and run. You may want to create subdirectories (ie folders) inside the one where the program resides.
So, in your case:

Blitzer ;your directory
DataPath ;within the Blitzer directory, new directory called DataPath
Saves ;for game saves
Maps ;for, whatelse? maps!
etc...

When you want to access data1.dat inside DataPath, you would use:
filein = ReadFile("DataPath\data1.dat")

Blitz will start from wherever on your hard drive the directory "Blitzer" is found, and see if it can find the subdirectory DataPath, and looking inside it, find the file data1.dat.

This way, you can always move "Blitzer" around in your hard drive's many folders, and it won't matter where it is, it will always find the data.


Blitzplotter(Posted 2006) [#6]
Thanks Sir Gak, my file manipulation knowledge has moved yet further forward.. Thanks again. I had been using a file manipulation GUI I hacked togehter in VB6 to modify my pathname files, this was the cause of the unwanted {""} at the start and end of my pathnames.

My data display project has reached the awkward phase where I've to stop tinkering with the GUI that displays the data (written in Blitz3D....) and put my efforts into the Hardware which will produce the data for representation on a cartesian graph.