Forums > Javascript

newline with post()

March 16, 2007 | 11:34 am

Hi,

From the manual it’s clear that printing a new line in the max window can be done by calling the post() method without arguments.

It looks as if lines printed with the [print] object always have a line break after their content, but also before their content if the previous line was from the post() command.

Thus both the newline post() done before a [print] and a newline post() done after a [print] always result in an empty line. I hope I am clear, my english isn’t really sufficient.

Is there a way to avoid this?

Regards,
Mattijs


March 17, 2007 | 11:38 pm

Allright, sorry ;) Here is an example:

#P comment 22 23 166 9109513 Is there a way to use newline commands in js printing and avoid empty lines in the max window?;
#P comment 89 183 166 9109513 notice the empty line between the print from the js and the print from the print object.;
#P window linecount 1;
#P comment 89 163 166 9109513 2) then press this one;
#P message 22 164 46 9109513 fromprint;
#P newex 22 184 26 9109513 print;
#P message 22 105 63 9109513 printjs fromjs;
#P newex 22 125 46 9109513 js print.js;
#P comment 89 105 166 9109513 1) press this one a few times;
#P connect 2 0 1 0;
#P connect 4 0 3 0;

— save as printjs.js

autowatch = 1;

function printjs(v)
{
post(v);
post();
}

Mattijs


March 22, 2007 | 5:35 pm

try:
post("nmymessage"1,2,3);

or try
post("mymessage",1,2,3,"n");

the "" alerts the system that the "n" means "newline". Similar is "t" for tab.
I prefer the "nmessage" as it’s easier to type than "n" at the end of every post()!

P


March 22, 2007 | 6:57 pm

Quote: pnyboer wrote on Thu, 22 March 2007 18:35
—————————————————-
> try:
> post("nmymessage"1,2,3);
>
> or try
> post("mymessage",1,2,3,"n");
>
> the "" alerts the system that the "n" means "newline". Similar is "t" for tab.
> I prefer the "nmessage" as it’s easier to type than "n" at the end of every post()!
>
> P
—————————————————-

Hi mr. Nyboer, thanks for your reply.

I know about the newline command but it has the same problem. You could try in the patch I posted. I think the problem simply is that there is an automatic newline when switching from javascript output to max output.

Cheers,
Mattijs


March 26, 2007 | 12:39 am

Quote: Mattijs wrote on Fri, 23 March 2007 06:57
—————————————————-
I think the problem simply is that there is an automatic newline when switching from javascript output to max output.
—————————————————-

Seems so. It’s mildly annoying, and tends to force me to use one or the other, but not both. Also seems that subsequent post() calls will generate an unasked-for newline if any non-js processing has occurred in between, even without [print] output? Meh.


March 26, 2007 | 9:42 am

Quote: johnpitcairn wrote on Mon, 26 March 2007 02:39
—————————————————-
> Quote: Mattijs wrote on Fri, 23 March 2007 06:57
> —————————————————-
> I think the problem simply is that there is an automatic newline when switching from javascript output to max output.
> —————————————————-
>
> Seems so. It’s mildly annoying, and tends to force me to use one or the other, but not both. Also seems that subsequent post() calls will generate an unasked-for newline if any non-js processing has occurred in between, even without [print] output? Meh.
>
—————————————————-

Exactly.

Ok, this is a bugreport/feature request as far as I’m concerned.

Regards,
Mattijs


Viewing 6 posts - 1 through 6 (of 6 total)