1. need help why is this code not working thanks for the help it is now working

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)

new topic     » topic index » view message » categorize

2. Re: need help why is this code not working

jpbg33 said...

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: need help why is this code not working

Trim the result of reading the file to take out the newline. That should help.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu