Author Topic: Changes to Text File  (Read 6942 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Changes to Text File
« Reply #15 on: March 15, 2020, 07:21:16 pm »
You're missing parts of it because you're still printing half to the screen and half to the file.

    IF LEFT$(LineTxt, 1) = "." THEN
        PRINT CHR$(13); CHR$(13)  'HERE YOU ARE PRINTING TO THE SCREEN.
        PRINT MID$(LineTxt, 2); " "; 'HERE TOO, THIS IS TO THE SCREEN
    ELSE
        WRITE #2, LineTxt 'write output to new file test.txt AND YET HERE IS TO THE FILE
        PRINT LineTxt; 'prints output to screen
    END IF

You'll need to convert all your print statements to the file, and not just part of them.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Changes to Text File
« Reply #16 on: March 15, 2020, 07:33:21 pm »
deja vu

« Last Edit: March 15, 2020, 07:41:45 pm by bplus »

Offline IronMan

  • Newbie
  • Posts: 38
    • View Profile
Re: Changes to Text File
« Reply #17 on: March 15, 2020, 11:19:07 pm »
I've always used PRINT #2, text$

WRITE #2 is something different

And everything you PRINT to screen do the exact same PRINT #2 to the file

    IF LEFT$(LineTxt, 1) = "." THEN
        PRINT CHR$(13); CHR$(13) ' <<<<<<<< this makes empty line PRINT #2, " "
        PRINT MID$(LineTxt, 2); " "; '<<<              and this                    PRINT #2, MID$(lineTxt, 2); " ";
    ELSE



PERFECT!

Thank you so much. It was the WRITE command I was using instead of PRINT. I thought if you were send to a file you used WRITE.

Thanks again.
Kent
        WRITE #2, LineTxt 'write output to new file test.txt '<<<<<<< PRINT #2, LineTxT
        PRINT LineTxt; 'prints output to screen

I just tested with forecaste.txt and looks good with PRINT #2 instead of WRITE #2

Offline IronMan

  • Newbie
  • Posts: 38
    • View Profile
Re: Changes to Text File
« Reply #18 on: March 15, 2020, 11:21:07 pm »
PERFECT!

That done it. I know now not to sue the WRITE and use the PRINT.

Thanks again, bplus
Kent
« Last Edit: March 15, 2020, 11:22:25 pm by IronMan »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Changes to Text File
« Reply #19 on: March 15, 2020, 11:27:20 pm »
Glad to help Kent, welcome to forum!