Guerrilla 19 Posted December 15, 2010 Report Share Posted December 15, 2010 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 Quote Link to post Share on other sites
Net66 54 Posted December 15, 2010 Report Share Posted December 15, 2010 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 Quote Link to post Share on other sites
Guerrilla 19 Posted December 15, 2010 Author Report Share Posted December 15, 2010 Nope. It's weird. "\n" break the javascript whether its in '' or "". Quote Link to post Share on other sites
Guerrilla 19 Posted December 19, 2010 Author Report Share Posted December 19, 2010 I been trying several things as a workaround. One thing I tried was replacing carriage returns with a placeholder to be replaced inside the code with a regex but I am getting this exception: Quote Link to post Share on other sites
Guerrilla 19 Posted December 28, 2010 Author Report Share Posted December 28, 2010 bump Quote Link to post Share on other sites
Guerrilla 19 Posted January 6, 2011 Author Report Share Posted January 6, 2011 Can this thread be moved to support please as its not getting any joy here? Quote Link to post Share on other sites
UBotBuddy 331 Posted January 6, 2011 Report Share Posted January 6, 2011 Guerrilla, Go here and place your ticket http://support.ubotstudio.com In my opinion I think this should go to Enhancements but let's try this first. Quote Link to post Share on other sites
Seth Turin 223 Posted January 6, 2011 Report Share Posted January 6, 2011 maybe try putting all the strings in an array, and then using alert(errorarray.join("\n")) Quote Link to post Share on other sites
Guerrilla 19 Posted January 6, 2011 Author Report Share Posted January 6, 2011 Thanks Seth, that will work. Quote Link to post Share on other sites
UBotBuddy 331 Posted January 6, 2011 Report Share Posted January 6, 2011 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! Quote Link to post Share on other sites
Guerrilla 19 Posted January 6, 2011 Author Report Share Posted January 6, 2011 Yeah I can do. Will work on it once I finish the sub im working on at the moment. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.