Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Writing to the same line in the same file in a loop?
#1
Hey all,

I'm trying to write to the 1st line continously in a DO...LOOP, but instead it just writes line after line. I also tried using the SEEK command..I guess used that for the wrong use, it just leaves boxes. Here's my code

Code:
OPEN "testing.dat" FOR APPEND AS #1
DO
pie = int(rnd * 50) + 1
WRITE #1, pie
LOOP while inkey$ = ""
END

'thats the loop that writes line after line

OPEN "testing.dat" FOR APPEND AS #1
DO
pie = int(rnd * 50) + 1
SEEK #1, 1 'this doesnt leave it at the first line, does it?
WRITE #1, pie
LOOP while inkey$ = ""
END

'thats the loop that leaves black boxes..

So...anyone know how to solve my problem here...I'm trying to write on line, preferrably using commas between each pie variable..thanks!
quote="na_th_an"]
Greenday, Spice Girls... Can you tell the difference?
[/quote]
Reply
#2
Code:
OPEN "testing.dat" FOR APPEND AS #1
first = 1
DO
  pie = int(rnd * 50) + 1
  IF first THEN
    first = 0
  ELSE
    PRINT #1, ",";
  END IF
  PRINT #1, pie;
LOOP while inkey$ = ""
CLOSE #1
END
Reply
#3
Thanks a lot Plasma!
quote="na_th_an"]
Greenday, Spice Girls... Can you tell the difference?
[/quote]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)