
-----------------------------------
Kuntzy
Mon Feb 02, 2004 10:23 pm

Printing to a file problem ... embarssing
-----------------------------------
just look at this code, and when you open up the text file, all of the lines are running continueously after one another? what have i forgotten?

-----------------------------------
Kuntzy
Mon Feb 02, 2004 10:24 pm


-----------------------------------
don;t post anything about how stupid i am, i feel stupd enough for even asking this

-----------------------------------
Paul
Mon Feb 02, 2004 10:27 pm


-----------------------------------
What do you mean? It looks fine to me if your trying to find prime numbers from 2 to 150, though you don't show the prime number factors.

-----------------------------------
santabruzer
Mon Feb 02, 2004 10:38 pm


-----------------------------------
well .. you just gotta do this or something of the sort :

var fil : int
open : fil, "Factors.txt", put

for i : 2 .. 150
    put : fil, chr (10), "Factors of ", i, ": " ..
    put "Factors of  ", i, ": " ..
    for j : 2 .. i - 1
        if i mod j = 0 then
            put : fil, j, "  " ..
            put j, " " ..
        end if
    end for
    put ""
end for

close (fil)


As you can see.. 
 put : fil, chr (10), "Factors of ", i, ": " ..
is added, and the chr (10) basically is the "enter" in the txt file...

-----------------------------------
Kuntzy
Tue Feb 03, 2004 8:34 pm


-----------------------------------
yeah, thanx for the help, the code was fine except for writing to the file, i couldn't get the line to skip down on the text file.

-----------------------------------
Mazer
Wed Feb 04, 2004 2:32 pm


-----------------------------------
Hey Kuntzy,
just replace the

put ""

after your for loop with

put : fil, ""

Or, if you want the output on the screen to be properly formatted, then add the previous line instead of using it to replace that first one.
