Newline is ignored at end of string in text windows

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Newline is ignored at end of string in text windows

Stein Rørvik
There is an issue with the way the linebreak \n symbol is handled when writing to text windows.
If the line ends in an explicit \n symbol (to give an extra linebreak), it is just ignored.
See the following three cases which one would expect to give the same result; the third one is printed wrongly.

This could perhaps also be a windows-only issue, perhaps related to the previous one I just posted to the list.

print("\\Clear");
print("----------");

print("abc");
print("");             //ok
print("");             //ok
print("123");

print("----------");

print("abc");
print("\n\n123");             //ok

print("----------");

print("abc");
print("\n\n");    //entire string is ignored
print("123");

print("----------");


I am using daily build ImageJ 1.51e with Java 1.6 on Windows 7/64-bit.


Stein


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Newline is ignored at end of string in text windows

Krs5
Dear Stein,

If you change the line print("\n\n");    to print("\n\n "); or  print("\n","\n");    it works as well.

Best wishes

Kees

-----Original Message-----
From: Stein Rørvik [mailto:[hidden email]]
Sent: 05 July 2018 09:08
To: [hidden email]
Subject: Newline is ignored at end of string in text windows

There is an issue with the way the linebreak \n symbol is handled when writing to text windows.
If the line ends in an explicit \n symbol (to give an extra linebreak), it is just ignored.
See the following three cases which one would expect to give the same result; the third one is printed wrongly.

This could perhaps also be a windows-only issue, perhaps related to the previous one I just posted to the list.

print("\\Clear");
print("----------");

print("abc");
print("");             //ok
print("");             //ok
print("123");

print("----------");

print("abc");
print("\n\n123");             //ok

print("----------");

print("abc");
print("\n\n");    //entire string is ignored
print("123");

print("----------");


I am using daily build ImageJ 1.51e with Java 1.6 on Windows 7/64-bit.


Stein


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Newline is ignored at end of string in text windows

Wayne Rasband-2
In reply to this post by Stein Rørvik
> On Jul 5, 2018, at 4:07 AM, Stein Rørvik <[hidden email]> wrote:
>
> There is an issue with the way the linebreak \n symbol is handled when writing to text windows.
> If the line ends in an explicit \n symbol (to give an extra linebreak), it is just ignored.

The bug that caused print("\n\n”) to be ignored is fixed in the latest ImageJ daily build (1.52e34). It’s also fixed in the 1.52e release candidate.

-wayne

> See the following three cases which one would expect to give the same result; the third one is printed wrongly.
>
> This could perhaps also be a windows-only issue, perhaps related to the previous one I just posted to the list.
>
> print("\\Clear");
> print("----------");
>
> print("abc");
> print("");             //ok
> print("");             //ok
> print("123");
>
> print("----------");
>
> print("abc");
> print("\n\n123");             //ok
>
> print("----------");
>
> print("abc");
> print("\n\n");    //entire string is ignored
> print("123");
>
> print("----------");
>
>
> I am using daily build ImageJ 1.51e with Java 1.6 on Windows 7/64-bit.
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Newline is ignored at end of string in text windows

Stein Rørvik
Thanks,

The example macro I submitted works fine now,
but the trailing \n's are still ignored if the string starts with anything else.

This one should be equivalent, but \n\n is ignored here too:

print("----------");
print("abc\n\n");
print("123");
print("----------");

Stein

-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of Wayne Rasband
Sent: 06. juli 2018 00:12
To: [hidden email]
Subject: Re: Newline is ignored at end of string in text windows

> On Jul 5, 2018, at 4:07 AM, Stein Rørvik <[hidden email]> wrote:
>
> There is an issue with the way the linebreak \n symbol is handled when writing to text windows.
> If the line ends in an explicit \n symbol (to give an extra linebreak), it is just ignored.

The bug that caused print("\n\n”) to be ignored is fixed in the latest ImageJ daily build (1.52e34). It’s also fixed in the 1.52e release candidate.

-wayne

> See the following three cases which one would expect to give the same result; the third one is printed wrongly.
>
> This could perhaps also be a windows-only issue, perhaps related to the previous one I just posted to the list.
>
> print("\\Clear");
> print("----------");
>
> print("abc");
> print("");             //ok
> print("");             //ok
> print("123");
>
> print("----------");
>
> print("abc");
> print("\n\n123");             //ok
>
> print("----------");
>
> print("abc");
> print("\n\n");    //entire string is ignored
> print("123");
>
> print("----------");
>
>
> I am using daily build ImageJ 1.51e with Java 1.6 on Windows 7/64-bit.
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html