toString function for Array

How do you convert an array to a string?

I’ve tried to look thru the documentation for answers but it seems a bit lacking

https://sdkdocs.roku.com/display/sdkdoc/roArray

“jaxim” wrote:
How do you convert an array to a string?

I’ve tried to look thru the documentation for answers but it seems a bit lacking

https://sdkdocs.roku.com/display/sdkdoc/roArray
What is it you want to do with the resulting string?
If the array consists of plain value types (string, integer, etc., or nested associative array or array of those), FormatJSON(array) might work for you.

Using JavaScript as an example, I would like to convert the values contained in an array to a comma delineated string like the following:

var monthNames = ['Jan', 'Feb', 'Mar', 'Apr'];
var myVar = monthNames.toString(); // assigns 'Jan,Feb,Mar,Apr' to myVar.

Source: https://developer.mozilla.org/en-US/doc … y/toString

“jaxim” wrote:
Using JavaScript as an example, I would like to convert the values contained in an array to a comma delineated string like the following:

var monthNames = ['Jan', 'Feb', 'Mar', 'Apr'];
var myVar = monthNames.toString(); // assigns 'Jan,Feb,Mar,Apr' to myVar.

There’s no intrinsic support for that in the current firmware.
You could write your own utility function for it.


myVar = "" : for each ms in monthNames : myVar  += "," + ms : end for : myVar = myVar.Mid(1)
print myVar 

thanks, RokuKC!

“jaxim” wrote:
Using JavaScript as an example, I would like to convert the values contained in an array to a comma delineated string
There is proposal to add exactly that - go and add your vote and voice @ https://forums.roku.com/viewtopic.php?f=34&t=96430