Posts: 2,765
Threads: 138
Joined: Nov 2002
for example lets say i was making a file copier. How do i open a file. get input from it then print to another file?
File1:
Hi
Bob
File2:
Hi
Bob
I tryed some things but none worked.
post 198
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 358
Threads: 15
Joined: May 2003
the easy way is to shell to dos and use the dos copy command.
within QB, the best way depends on your data-type. If you can't count on formatting (deliminated data or line breaks) then you can use something like the following.
Code:
PRINT "Input a string to place at the front of :", filein$
INPUT frontstring$
OPEN filein$ FOR BINARY AS #1
OPEN fileout$ FOR BINARY AS #2
PUT #2, , frontstring$
DO UNTIL EOF(1)
GET #1, , datachunk&
PUT #2, , datachunk&
LOOP
CLOSE #1
CLOSE #2
Posts: 2,765
Threads: 138
Joined: Nov 2002
what if i want to read from file 1 add a string to the front of it then put it in file 2?
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 358
Threads: 15
Joined: May 2003
Quote:what if i want to read from file 1 add a string to the front of it then put it in file 2?
You are kidding, right???
OK...I'll edit my last post to show you...
Posts: 2,765
Threads: 138
Joined: Nov 2002
ok...
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 2,765
Threads: 138
Joined: Nov 2002
wait that doesn't work. i want it at the begining of everyline. and when i do that it is all mess up.
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 358
Threads: 15
Joined: May 2003
Quote:i want it at the begining of everyline. and when i do that it is all mess up.
Every line??? that's why I said the method you use depends on what kind of data the file contains. You should open the file in one of the text modes then and use LINE INPUT
Look up the following keywords that pertain to file I/O
OPEN
CLOSE
INPUT
OUTPUT
APPEND
RANDOM
BINARY
WRITE
GET
PUT
What you want to do is read a line of data into a string, then prepend the string with your string, then write the result to the file.
Posts: 2,765
Threads: 138
Joined: Nov 2002
thanks it works!
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.