Jump to content
UBot Underground

Storing Line Break Character In Variable


Recommended Posts

I have hit a snag in a loop I am making to monitor list of stuff that went wrong and then display the list in an alert box at the end.

 

The problem is that to break the line in the alert box I need to use the charachter "\\n" as using "\n" stops the javascript from working (I am not sure why this is).

 

This isn't a problem if I am just running it from a single command such as:

 

alert("The Errors Were \\n Error 1 \\n Error 2 \\n Error 3");

 

But when I construct the error message from the list that holds all the error messages the "\\n" gets transformed into "\n".

 

For instance if I did:

 

SET #variable
$eval
a = "line 1 \\n line 2"

 

the variable "#variable" would actually be "line 1 \n line 2". So if you try and output it as a message in javascript like:

 

alert("{1})";

 

Then it doesn't work as the "\n" is breaking it.

 

The whole logic for what I am trying to achieve is this:

 

#count = 0

WHILE $list_total > #count
 {
  SET #message
    $eval (#message, $list_value(#count))
      a = "{1}" + "{2}\\n";
  }

RUN JAVASCRIPT (#message)
  alert("{1}");

 

Basically a simple loop that iterates over each list item and adds it to my #message variable so it can be displayed at the end of the process.

 

The only thing that is messing me up is the fact that "\n" stops the javascript alert working and if you pass "\\n" to a variable it comes back as "\n" when you call that variable in the javascript code.

 

I tried "\\\\n" and it ends up inserting an actual carriage return in the code which means it all appears on one line.

 

I have a workaround if just having the error message all appearing on one line with commas but it irks me. Anyone know a way round this?

 

Thanks

Link to post
Share on other sites

Again just a guess here....

 

What happens if you call the javascript using single quotes?

 

So..

alert('{1}');

 

I am more of a php guy than javascript but I know in php single quotes don't need to have things escaped. My last guess was OK so might be worth a shot :)

 

Andy

Link to post
Share on other sites
  • 2 weeks later...
  • 2 weeks later...

Guerrilla,

 

When you finally get this working would you mind posting an example bot showing it in action?

 

This would be a GREAT share for the whole community here. Maybe place it in the area "Bots - Buy, Borrow, Steal".

 

Thanks!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...