Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Files
#1
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. [Image: KkatSad.txt]

post 198
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#2
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
Reply
#3
what if i want to read from file 1 add a string to the front of it then put it in file 2?
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#4
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...
Reply
#5
ok...
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#6
wait that doesn't work. i want it at the begining of everyline. and when i do that it is all mess up.
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#7
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.
Reply
#8
thanks it works!
[Image: KkatBigGrin.txt]
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)