Log in

View Full Version : Some help on how to use arrays in AviSynth+


ccicnce113424
10th July 2020, 07:05
Is there a detailed introduction to array usage? How to get the length of an array? How do I traverse an array? Can I add or delete elements to the array dynamically?

StainlessS
11th July 2020, 01:43
See ReadMe.txt in Avisynth-3.6.2_20200624_test1-filesonly.7z (I presume that its in the setup version too).

Excerpt

Example:

'''
a = [1.0, 2.0, 4.2]
b = [3, 4, 5]
multi = [a,b]

sum = Summa(multi[0], multi[1], 2)
SubTitle(Format({sum}))

Function Summa(array "x", array "y", int "N")
{
sum = 0.0
FOR(i=0,N-1) {
sum = sum + x[i] * y[i]
}
return sum
}

or

Function Summa(float_array x, float_array y, int "N")
{
sum = 0.0
FOR(i=0,N-1) {
sum = sum + x[i] * y[i]
}
return sum
}
'''


there is more in there.

Also, extracted from 3.6.2 dll [EDIT: we can only extract a single function parameter list, where function has several alternative parameter lists we can extract only one]


AviSynth+_3.6.2_(r3300,_master,_i386)_ORDERED_Function_List


There follows a list of all function names together with CPP style argument specifiers that inform
Avisynth the argument types and optional names. Optional arguments have square brackets surrounding
their name as in [name] and are followed by a type specifier character that gives the type.
Unnamed arguments are not optional. eg "cc[arg1]b[arg2]i" would be two compulsory unnamed clip args,
followed by optional 'arg1' of type bool and optional 'arg2' of type int.

# Argument type specifier strings.
c - Video Clip
i - Integer number
f - Float number
s - String
b - boolean
. - Any type (dot)
# Array Specifiers
i* - Integer Array, zero or more
i+ - Integer Array, one or more
.* - Any type Array, zero or more
.+ - Any type Array, one or more
# Etc
###################################

Array ".*"
ArrayGet ".i+"
ArraySize ".*"
IsArray "."
propGetAsArray "cs[offset]i"
propSetArray "csn"


All function parameter lists extracted from 3.6.2, see SendSpace below in my sig, "AviSynth+_3.6.2_(r3300,_master,_i386)_ORDERED_Function_List.TXT.7z".

EDIT: Post where arrays were first suggested in devs forum (dont know if implemented same way).
https://forum.doom9.org/showthread.php?p=1784532#post1784532