Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:52 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : MMedit is adding lines to a file.

Author Message
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 05:43pm 07 Aug 2018
Copy link to clipboard 
Print this post

I am using NP++ to write a program, and MMedit to format it and therefore confirm that I haven't screwed up one of the structures.

The first line is a remark with the program name.
' A.BAS 8/7/2018 =============

The last line is also a remark.
' EOF ================


I write and save A.BAS in NP++.

I start MMedit and it automatically reloads the newly saved A.BAS. (MMedit had A.BAS loaded the last time I shut it down.)

I then hit Alt+P, then O to format, then Alt+F then S to save, then Alt+F4 to close MMedit.

Windows changes the focus back to NP++ which still has the old A.BAS loaded.
NP++ complains that another program has modified A.BAS so I let it reload A.BAS.

NP++ now shows that A.BAS has two additional blank lines added after the old end. This happens every time.
' EOF ================




NP++ also now sometimes shows that the first line of A.BAS has been duplicated.
' A.BAS 8/7/2018 =============
' A.BAS 8/7/2018 =============


Huh! What the ... moleijnn;lolasdf ;a; oma;omadf ....

Paul in NYEdited by Paul_L 2018-08-09
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 10:03pm 07 Aug 2018
Copy link to clipboard 
Print this post

Doing some of the formatting and checking procedures when the file doesn't have a final CRLF was causing problems so some of the procedures will add a CRLF 'to be sure'

I have only ever seen one blank line added.
I can't think of any reason for one duplicated line being added to the start of the file.

I will do some testing with NP++
What version of NP++ are you running. I am using 32bit V7.5.8

Jim
VK7JH
MMedit
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 11:48pm 07 Aug 2018
Copy link to clipboard 
Print this post

Hi Jim,

V 3.7.5 OS Ver 10

Paul in NY
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 12:59am 08 Aug 2018
Copy link to clipboard 
Print this post

Hi Jim,

It always seems to add two CRLFs at the end resulting in two blank lines.

The next time around it doesn't add any more, it's satisfied with the two.

Paul in NY
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 05:01am 08 Aug 2018
Copy link to clipboard 
Print this post

I don't know how many times I have told programmers that they need a trailing semicolon to suppress the addition of a newline in their file.
  Quote   PRINT #f, txt$;

Guess what I had left out.

The reason for the second newline was a bit more complicated.
I don't think I have broken anything else during the fix.

Try this updated TKN file

2018-08-08_145646_MMedit.zip

I do get very nervous about files without a newline on the last line.

Jim
VK7JH
MMedit
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 10:45am 08 Aug 2018
Copy link to clipboard 
Print this post

Hi Jim,

The last line of my files do not normally have a trailing newline. The new .tkn no longer adds any lines after the last line even without a newline at the end.

Are you saying that a trailing semicolon on the last line of the file will suppress the addition of a new line to the file, even though there is no trailing newline, like this?

EOF: '=======================================================;


Paul in NY
 
Azure

Guru

Joined: 09/11/2017
Location: Australia
Posts: 446
Posted: 10:51am 08 Aug 2018
Copy link to clipboard 
Print this post

I think he was referring to an oops he did in his program source code for MMEdit
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 09:45pm 08 Aug 2018
Copy link to clipboard 
Print this post

  Azure said   I think he was referring to an oops he did in his program source code for MMEdit

Correct.
I made one of the silly mistakes that I should have known better about.
It didn't matter normally because MMEdit does some cleaning up of the file endings when the file is opened. This hid the issue from me.

Jim

VK7JH
MMedit
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 07:04pm 09 Aug 2018
Copy link to clipboard 
Print this post

I'm older than you .... therefore I have made more silly mistakes in my time.

I'm glad I could help uncover this one and you could shoot the bug.

Paul in NY
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025