1. need help why is this code not working thanks for the help it is now working
- Posted by jpbg33 Apr 11, 2013
- 1210 views
Im trying to open a file by reading the first line of a file
and use the text on that line as a file name.
why dose this code not work
fh3 = w32FileOpen("c:\\joshg\\j.txt", "w") printf(fh3,"%s", {"c:\\\\joshg\\\\"}) printf(fh3,"%s", {"joshua"}) printf(fh3,"%s\n", {".txt"}) close(fh3) fh3 = w32FileOpen("c:\\joshg\\j.txt", "r") zzz = gets(fh3) zz = zzz close(fh3) fh3 = w32FileOpen(zz, "w") puts(fh3, "3") close(fh3) fh3 = w32FileOpen(zz, "r") zzz = gets(fh3) zz = value(zzz) close(fh3) wPrintf( {Window1, 70,10}, " %d", zz[2])
and this one will
the only differes is "\n" on line 4 " printf(fh3,"%s\n", {".txt"})"
i need "\n" because i may enter more than one file and i wont
each line to be a different file name
im very fusturated would apreshiate any help i can get
fh3 = w32FileOpen("c:\\joshg\\j.txt", "w") printf(fh3,"%s", {"c:\\\\joshg\\\\"}) printf(fh3,"%s", {"joshua"}) printf(fh3,"%s", {".txt"}) close(fh3) fh3 = w32FileOpen("c:\\joshg\\j.txt", "r") zzz = gets(fh3) zz = zzz close(fh3) fh3 = w32FileOpen(zz, "w") puts(fh3, "3") close(fh3) fh3 = w32FileOpen(zz, "r") zzz = gets(fh3) zz = value(zzz) close(fh3) wPrintf( {Window1, 70,10}, " %d", zz[2])
fh3 is an atom zz and zzz are objects in Window1 (intro)
2. Re: need help why is this code not working
- Posted by mattlewis (admin) Apr 11, 2013
- 1109 views
Im trying to open a file by reading the first line of a file
and use the text on that line as a file name.
why dose this code not work
...
and this one will
the only differes is "\n" on line 4 " printf(fh3,"%s\n", {".txt"})"
i need "\n" because i may enter more than one file and i wont
each line to be a different file name
You need to remove the '\n' from the end of the line after you read it in. It's being treated as part of the file name when you call w32FileOpen.
Matt
3. Re: need help why is this code not working
- Posted by euphoric (admin) Apr 11, 2013
- 1145 views
Trim the result of reading the file to take out the newline. That should help.