Skip to content

Instantly share code, notes, and snippets.

@currencysecrets
Created January 13, 2014 08:33
Show Gist options
  • Save currencysecrets/8396591 to your computer and use it in GitHub Desktop.
Save currencysecrets/8396591 to your computer and use it in GitHub Desktop.
Amibroker utility function on converting array to string - helpful for debugging just what's in those arrays. Needs the countArray functions.
EnableScript("JScript");
<%
function getArrayLength( a ) {
x = VBArray( a ).toArray();
for ( y = 0; y < x.length; y += 1 ) {
if ( x[y] == undefined ) break;
}
return y;
}
%>
function arrCount( arr ) {
scr = GetScriptObject();
a = 0;
if ( !IsNull( BeginValue( arr ) ) ) a = scr.getArrayLength( arr );
return a;
}
function arrayToStr( arr ) {
result = "[";
for ( i = 1; i < arrCount( arr ); i += 1 ) {
result += arr[i];
if ( i + 1 < arrCount( arr ) ) result += ",";
}
result += "]";
return result;
}
// usage
// _TRACE( arrayToStr( L ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment