Skip to content

Instantly share code, notes, and snippets.

@currencysecrets
Last active December 18, 2020 20:20
Show Gist options
  • Save currencysecrets/8349570 to your computer and use it in GitHub Desktop.
Save currencysecrets/8349570 to your computer and use it in GitHub Desktop.
Count Array length in Amibroker. One of the most frustrating aspects when starting out with AmiBroker is being able to count an array's length. To execute this function simply paste the two functions into your code and whenever you want to count the length of an array simply call arrCount( yourArray );
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment