How can I do a simple line break?

mredge73

Member
Ahhh....
I don't want to ask this question...
This should be simple but I am getting frustrated and I cannot find it in the wiki or in these forums and on yahoo it says that java uses lots of different end of line characters so this is what I tried:

print("I want to put: " + "/n" +" this on another line.");
print("I want to put: /n this on another line.");
print("I want to put: " + "/r/n" +" this on another line.");
print("I want to put: /r/n this on another line.");
print("I want to put: " + "\n" +" this on another line.");
print("I want to put: \n this on another line.");
print("I want to put:/nthis on another line.");
print("I want to put:" +"/endl" +" this on another line.");
print("I want to put:" +"\endl" +" this on another line.");
print("I want to put:" +"/l" +" this on another line.");
print("I want to put:" +"\l" +" this on another line.");


Here is my output:

I want to put: /n this on another line.
I want to put: /n this on another line.
I want to put: /r/n this on another line.
I want to put: /r/n this on another line.
I want to put: this on another line.
I want to put: this on another line.
I want to put:/nthis on another line.
I want to put:/endl this on another line.
I want to put:\endl this on another line.
I want to put:/l this on another line.
I want to put: this on another line.

Can anyone help me?
 

Camber

Member
It would be nice to use the '\n', but just do it manually with print(""); like this:

print("I want to put: "); print(""); print(" this on another line.");
 

mredge73

Member
That is what I usually do Camber, but it won't work with what I want to do now.
I want to build a large string with a few new lines in it so I can pass it as a function.

For example:

string StringFunction()
{
//do stuff
string new= "I want to hit enter /n here /n here /n and here";
//do stuff and add more to string new
return new;
}

void main
{
print(StringFunction());
}
 

Bale

Minion
You can use print_html(string) to use <br /> to create a new line. It will also allow you to do any other sort of formatting you could possibly desire.

print_html("I want to put: " + "<br />" +" this on another line.")



PS. Bizarrely, I've found that \n works well in a user_confirm() command, even though it doesn't work in print(). I have no idea why...
 
Last edited:

mredge73

Member
Thanks guys that helps
I got it working, now I need to figure out how to do colors but that should not be that hard, I hope.
 

Bale

Minion
But Alhifar, you already suggest that he use print_html(), so you know that doesn't work! print_html only takes a single parameter. Do it like this:

Code:
print_html("<font color=\"[COLOR="Blue"]blue[/COLOR]\">I want to put: <br /> this on another line.</font>")
Replace the word blue with the color of your choice by name or hex. Since you're using html tags, you can color both lines differently if you want. Heck, you could even use italics or anything else that html can do.
 
Last edited:

Bale

Minion
Yeah, I figured it was something silly like that. I was amused seeing you tell him to use the print(string, string) command just after telling him to use the print_html(string) command. I've been strung out like that also.
 

mredge73

Member
thanks guys for your help
It sucks when I can create some wickedly cool logic but I get held up on some simple print commands and cannot display the output where I can read it.
 

mredge73

Member
Back to this topic again:

How do you create line breaks in a Kmail?
I haven't found a character combination that will create line breaks in a kmail. I want to build a kmail forwarding function but it isn't readable without line breaks to break between messages.
 

StDoodle

Minion
After some testing, I've found that if you use ASH, build a string with "\n" where you want line breaks, and pass that string as the message part during cli_execute("kmail to PLAYER || " + string); it will work.
 

zarqon

Well-known member
Note that the above solution will probably not work if the message gets sent as a gift. ZLib's kmail() function, like CLI's "send", will switch to sending gifts if the recipient is unable to receive regular kmail, and when that happens messages arrive all skanky (url-encoded). I haven't figured this out yet. But for regular kmails, it works great.
 
Top