[Solved] String concatenation in JS function called from LC

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Cairoo
Posts: 112
Joined: Wed Dec 05, 2012 5:54 pm

[Solved] String concatenation in JS function called from LC

Post by Cairoo » Thu Apr 04, 2013 7:03 pm

Dear experts

I am using LiveCode's browser support, to display Maths. I make calls to JavaScript functions and some of these functions take arguments. One of the JavaScript functions must append string data to its arguments, but fails to do so for no appearent reason. The concatenation only fails when the function is called from my LiveCode app. It works without a problem if the function is called from outside of my LiveCode app.

The LC documentation says that LC internally treats the arguments as null terminated strings. Could that be the cause of the problem? How can it be fixed? It should be noted that my dev environment is Microsoft Windows 8.

Thanks in advance

Cairoo

Edit: I've created and attached a sample project to demonstrate the problem. Please have a look.
Attachments
js-concat-problem.zip
(1.56 KiB) Downloaded 312 times
Last edited by Cairoo on Fri Apr 05, 2013 10:46 am, edited 1 time in total.

Cairoo
Posts: 112
Joined: Wed Dec 05, 2012 5:54 pm

Re: String concatenation in JS function called from LC

Post by Cairoo » Fri Apr 05, 2013 10:46 am

Never mind; I found the solution.

All I had to do was to write a JavaScript function that removes the null terminator from the argument. It works now.

Here's the JavaScript code for removing the null terminator from a string:

Code: Select all

function removeNullTerminator(theNullTerminatedString) {
    var theArray = theNullTerminatedString.split('');
    theArray.splice(theArray.length - 1, 1);
    var newString = theArray.join('');
    return newString;
}
Thanks for reading.

Post Reply