writing to file without overwriting text already there? 
Author Message
 writing to file without overwriting text already there?

How can you write to file without overwriting text already there,  in
qbasic? Simply doing the "PRINT #1" overwrites all text previously
there... Is there a way not to do that?

-Yiango



Fri, 27 Aug 1999 03:00:00 GMT  
 writing to file without overwriting text already there?


Quote:
> How can you write to file without overwriting text already there,  in
> qbasic? Simply doing the "PRINT #1" overwrites all text previously
> there... Is there a way not to do that?

OPEN the file FOR APPEND rather than FOR OUTPUT.  Then PRINT #1 will add lines of text to the end of the file.

Tom Lake



Sat, 28 Aug 1999 03:00:00 GMT  
 writing to file without overwriting text already there?

Quote:

>How can you write to file without overwriting text already there,  in
>qbasic? Simply doing the "PRINT #1" overwrites all text previously
>there... Is there a way not to do that?

Sounds as though you're using OPEN File$ FOR OUTPUT,
this will erase any existing files data.

If you want to add data to the end of a sequential file then
use -
  OPEN File$ for APPEND as #1

You can then use a SEEK #1, BytePosition to write
to any position within the file.

TTfn,

Craig Wright___



Sat, 28 Aug 1999 03:00:00 GMT  
 writing to file without overwriting text already there?

You could try  Open "File" For Append As #1



Quote:
> How can you write to file without overwriting text already there,  in
> qbasic? Simply doing the "PRINT #1" overwrites all text previously
> there... Is there a way not to do that?

> -Yiango




Sat, 28 Aug 1999 03:00:00 GMT  
 writing to file without overwriting text already there?

Quote:

> How can you write to file without overwriting text already there,  in
> qbasic? Simply doing the "PRINT #1" overwrites all text previously
> there... Is there a way not to do that?

> -Yiango


Try OPEN"myfile" FOR APPEND AS #1


Sun, 29 Aug 1999 03:00:00 GMT  
 writing to file without overwriting text already there?

Quote:

>How can you write to file without overwriting text already there,  in
>qbasic? Simply doing the "PRINT #1" overwrites all text previously
>there... Is there a way not to do that?

Hi,

  Sounds like you need to move "up" to RELative (or RANdom) files. This system
allows you to select which portion (record) of the file you wish to read/write
without disturbing the rest of the file. Help pretty well explains it and with
a bit of practice it will become familiar very quickly. If, however, you find
yourself having trouble, let us know.

Kali soy mera,

  ____    _    ____      ____  _____
 |  _ \  / \  / ___) __ | ___)(_   _)  Nutz'n Bolts
 | |_)  / _ \ \____\/  \|  _)   | |   powerbasic PBL
 |____//_/ \_\(____/\__/|_|     |_|    N-B-V206.ZIP



Sun, 29 Aug 1999 03:00:00 GMT  
 writing to file without overwriting text already there?


 > Newsgroups: comp.lang.basic.misc
 > Subject: [News] writing to file without overwriting text already there?
 > Date: Mon, 10 Mar 97 18:05:20 GMT


 >
 > How can you write to file without overwriting text already there,  in
 > qbasic? Simply doing the "PRINT #1" overwrites all text previously
 > there... Is there a way not to do that?
 >
 > -Yiango

Hi, CY!

Try this ( PB3.2, convert to Qbasic yourself :)...

'--------------------------------------------------------------------------

CLS

INPUT "What line to edit "; LineToEdit%   ' Input line number...

FileName$ = "ANY.TXT"                     ' Insert real file name ...
D$=SPACE$(256)
P1& = 0
CR$ = CHR$(13)
Nf% = FREEFILE
RealLine% = 1
OPEN "B", Nf%, FileName$
  EndOfFile& = LOF(Nf%)
  WHILE P1& < EndOfFile&

    SEEK Nf%, P1&
    GET Nf% , , D$
    P2& = INSTR( D$, CR$ )
    IF RealLine% = LineToEdit% THEN

      s$ = LEFT$( D$, P2&-1 )
      LL% = LEN(s$)

      IF LL% = 0 THEN             ' Nothing to edit ...
        EXIT LOOP
      END IF

      PRINT "LineToEdit:   (";LL%;" bytes)"
      PRINT s$
      PRINT "NewLine:"
      INPUT , NewLine$
      NewLine$ = LEFT$( NewLine$ + SPACE$(LL%), LL%)
      SEEK Nf%, P1&
      PUT Nf% , , NewLine$
      EXIT LOOP

    END IF
    INCR P1&, P2& + 1
    INCR RealLine%

  WEND
  CLOSE Nf%
  PRINT "Done!"                   ' Enjoy !
  BEEP
  END
'--------------------------------------------------------------------------

    Good luck,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Tue, 31 Aug 1999 03:00:00 GMT  
 writing to file without overwriting text already there?

instead of using

open"file.dat" for output as #1
print #1, "hello"

, try this.....

open "file.dat"for append as #1
print #1,"hello"

The append option will write your data at the end of the file where you
left off without eraseing any previous data contained within the file.The
output option
completely overwrites all previous data in the file.



Thu, 09 Sep 1999 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Writing Text File without CR LF

2. write text to file without the quotes

3. writing to a text file without using quotes?

4. Writing text to a file without quote's

5. Read and write text files in vbScript (without a DSN)

6. Copy files without overwrite

7. Reading from a text file and writing toa text file from Vis Bas 6.0

8. Write contents of listbox to text file/populate listbox from text file

9. OutputTo function overwrites file that already exists - without prompting. Solution?

10. Overwriting line in a text file

11. overwriting a given line in a text file

12. overwriting a given line in a text file

 

 
Powered by phpBB® Forum Software