Variable path names

Blitz3D Forums/Blitz3D Beginners Area/Variable path names

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!



;  Note to run run this piece of code
;  It will be necessary to have a text
;  file saved at:-
;  "C:\Blitzer\DataPath"
;  with the following text on the first line
;  "C:\Blitzer\data1.dat""
.main

AppTitle "Stripping off the speech marks from a pathname"
Graphics 640, 420, 16, 2 ; 


Dim path$(50);chars max need this for string manipulation
			 ; to strip off the " marks

filein = ReadFile("C:\Blitzer\DataPath")

;Readin the path from the file:-

Data1path$ = ReadLine$( filein)

;close the file which holds the path to the first piece of data:-

CloseFile( filein );

Print "Debug.. the path For Data1path$ is:-"
Print Data1path$ +":End of path"      ;   displaying the fact the
									  ;   path from the .ini file
									  ;   is prefixed and suffixed
									  ;   by :   "{pathname}"

; ---stripping off speech marks--------
Print "Stripping off speech marks from start and end of path:-"

Data2path$ = Data1path$
endofstring = Len (Data1path$)-1
For T = 2 To endofstring
x=T-2
path$(x)=Mid$(Data2path$,t,1)

Print Mid$(Data2path$,t,1)
newpath$=newpath$+Mid$(Data2path$,t,1)
Next

;Print newpath$
;For T = 1 To Len(newpath$)
;Print Mid$(name$,t,1)
;Next
filename$=newpath$


Print "filename$ is now set as:-----"+filename$
If FileType(filename$)=1 Then Print "The file exists!"
If FileType(filename$)=0 Then Print "File not found!"
If FileType(filename$)=2 Then Print "This is a directory!"

filename$= "C:\Blitzer\data1.dat"
Print filename$
If FileType(filename$)=1 Then Print "The file exists!"
If FileType(filename$)=0 Then Print "File not found!"
If FileType(filename$)=2 Then Print "This is a directory!"
If filename$=Data1path$ Then Print "One file equals the other...."

Print "Press any key to quit."

WaitKey()




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.