Writing a file without line feed. - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://staging.qb64phoenix.com/forumdisplay.php?fid=10) +---- Thread: Writing a file without line feed. (/showthread.php?tid=595) |
Writing a file without line feed. - SquirrelMonkey - 07-08-2022 I want to replace text strings of a binary file (a P2000T .CAS file). Unfortunately, QB64 adds a line feed character. When I use "PRINT" it adds a CHR$(13) or CHR$(10), when I use "WRITE" it put a double quote at the beginning of the file. How can I prevent this? Code: (Select All) [quote] RE: Writing a file without line feed. - bplus - 07-08-2022 You could write your file at end of processing as one big long line with Chr$(10) or Chr$(13) delimiters for lines, file it as Binary too. RE: Writing a file without line feed. - RhoSigma - 07-08-2022 Hi, it's very easy, just put an semi-colon behind the print: Code: (Select All) PRINT "Hello" 'this will actually print Hello + CHR$(13) + CHR$(10) RE: Writing a file without line feed. - SquirrelMonkey - 07-08-2022 I tried that. When I type "Print #f2%, line$;" it still adds a character. RE: Writing a file without line feed. - bplus - 07-08-2022 Oh load file as string, use replace$ sub and then file as string, even more efficient! RE: Writing a file without line feed. - SquirrelMonkey - 07-08-2022 Do you have an example? Does that work with file names of any size? RE: Writing a file without line feed. - SquirrelMonkey - 07-08-2022 It shows up here. RE: Writing a file without line feed. - RhoSigma - 07-08-2022 (07-08-2022, 05:08 PM)SquirrelMonkey Wrote: I tried that. When I type "Print #f2%, line$;" it still adds a character. That's odd, then I'd say that character is already part of line$ and not added by the PRINT, but as far as I see you use LINE INPUT, which usually skips CRLF. However, try this: Code: (Select All) OPEN "B", #1, "YourOriginalFile" RE: Writing a file without line feed. - bplus - 07-08-2022 Roughly, Open file for binary as #1 buf$ = space$(LOF(1)) get #1, , buf$ close #1 flie$ = replace$(buf$, old$, new$) ' find replace in QB64.exe code files Open NewFile for binary as #1 put #1, , file$ close #1 ' check new file kill oldfile name Newfile as OldFile ' EDIT: help has old and new the other way and confused me but you want the new file to have the old name. Faster than digging around QB64 files: Code: (Select All) Function strReplace$ (s$, replace$, new$) 'case sensitive 2020-07-28 version RE: Writing a file without line feed. - SquirrelMonkey - 07-08-2022 Wow, that worked! Thank you so much! |