Forum

Attempted to divide by zero in PluginInterfaces.V2 when dealing with spread of spreads

Hello!
I have

[Input("Key")](Input("Key"))
public ISpread<ISpread<string>> FKey;

[Input("Write From")](Input("Write From"))
public ISpread<ISpread<int>> FFrom;

and i do this at some point (this is the line which the exception references):

temp.Fields[FKey[i](FKey[i)[j](j)].Position = FFrom[i](i)[j](j);

and in some cases when the “Write From” (FFRom) pin should have a 0 binsize this is what i get:

quote
System.DivideByZeroException: Attempted to divide by zero.
at VVVV.Utils.VMath.VMath.Zmod(Int32 z, Int32 d)
at VVVV.PluginInterfaces.V2.Spread`1.get_Item(Int32 index)
at VVVV.Nodes.RawUpdateObjectNode.Evaluate(Int32 spreadMax) in e:\vvvv\mcropack\VVVV.Packs.mcro\src\RawObject\RawObject\ObjectManagement.cs:line 249
at VVVV.Hosting.IO.PluginContainer.Evaluate(Int32 spreadMax)

“ObjectManagement.cs” is my stuff however i suspect the error is somewhere in “get_Item(Int32 index)” or “Zmod(Int32 z, Int32 d)”
can somebody help me?

You need to check FFrom.SliceCount before accessing FFrom(i) and FFrom(i).SliceCount before accessing FFrom(i)(j). One of them is zero and that’s why you get the exception.