Read a file with a variable in the filepath.

Just starting out? Need help? Post your questions and find answers here.
doraemon
New User
New User
Posts: 9
Joined: Thu Sep 18, 2003 2:33 pm

Read a file with a variable in the filepath.

Post by doraemon »

I need to make something like this:

;ReadFile(#FileModel , "Dades\" && Marca$ && ".txt")

Marca is a variable selected by a ComboBoxGadget.

Anyone can sayme the correct way to make it??

Carles "Doraemon" Bernardez
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

Perhaps

Code: Select all

ReadFile(#File, "Dades" + marca$ + ".txt")
doraemon
New User
New User
Posts: 9
Joined: Thu Sep 18, 2003 2:33 pm

Post by doraemon »

freedimension wrote:Perhaps

Code: Select all

ReadFile(#File, "Dades" + marca$ + ".txt")
It do not run fine :(

exaple of the datas:
MyProgram:dades/alcatel.txt
"" dades/nokia.txt
"" dades/sony.txt
........
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Have you got a "/" in there somewhere?

If I suspect problems with paths I construct it in a variable, eg,

fp.s = path+file

then check it using...

debug ">"+fp+"<"

and then it should be clear where the problem is.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Remember the slash after the folder name:

;ReadFile(#FileModel , "Dades\" && Marca$ && ".txt")

becomes:

Code: Select all

marca$ = "alcatel"
;or marca$ = "nokia"
;or marca$ = "sony"
ReadFile(#FileModel, "Dades\" + marca$ + ".txt")
--Kale

Image
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

Yeah, I forgot the Slash
Post Reply