Last active
December 18, 2020 20:20
-
-
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 );
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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