Initialize List<string>[] array without rewriting it each frame

Hi guys struggling here with making my plugin work.
The problem is i can’t initialize the array without rewriting it every frame…

private List<string>[]() FileList;
private bool invalidate = true;

public void Evaluate(int SpreadMax)
{
 if (this.invalidate)
{
  List<string>[]() FileList = new List<string>[FInput.SliceCount](FInput.SliceCount);
}

results exception…

i’ve been looking around and found this LINK
do i have to use it?

any reason why not just initialize it in plugins constructor ? or use a simple bool like

private bool firstframe = true;

public void Evaluate(int SpreadMax)
{
if (firstframe)
{
//do your stuff

firstframe = false;

}
}

yea that’s exactly what i did, but that’s results an exception…

first this line genrates an array of string lists:

private List FileList;

and a list does not need a size, its optional.

maybe you wanted to write:

private List<string> FileList = new List<string>();
private bool invalidate = true;
 
public void Evaluate(int SpreadMax)
{
if (this.invalidate)
{
  FileList.Clear();
}
}

or as array of string lists:

private List<string>[]() FileList;
private bool invalidate = true;
 
public void Evaluate(int SpreadMax)
{
 if (this.invalidate)
{
  FileList = new List<string>[FInput.SliceCount](FInput.SliceCount);
}
}

but it might be more easy to manage as a list of lists:

private List<List<string>> FileList = new List<List<string>>();
private bool invalidate = true;
 
public void Evaluate(int SpreadMax)
{
 if (this.invalidate)
{
  FileList.Clear();
  //add the sub lists somehow
  FileList.Add(new List<string>());
  ...
}
}

a list also handles an array internally but i find it is more convenient to use and the performance is about the same, even faster in cases because the list code does intelligent memory handling of the internal array…

Hi tonfilm, that’s exactly what i’m doing, i’m generating array of lists with filenames.
The logic is pretty simple, as i got spreadable input of filenames, for each slice on input, i get all the files in the folder and index of my file. Then i can change previous next file with bangs. But if input is changed the whole thing gonna get reset…

there is the .cs file i started to rewrite, if u can take a look, maybe u can provide me with some feedback…

got this part also dos’t want to work…

updated cs

FilePlayer.zip (1.3 kB)

be very careful:

List FileList = bla;

makes a new local variable that is forgotten when the evaluate method is done… but what you want is to re/use the class field FileList, so DO NOT add the type declaration before the variable name, as i have written in the code above:

FileList = bla;

does that fix it?

tonfilm u can congratulate me! It’s working nicely and smooth ;]
Here is .cs if anyone wanna platy with it… Still fixing some minor issues tho…

looks like there is one more question is how to find out if slice count is changed?

FilePlayer.zip (1.3 kB)