Quite a few questions in SE regarding this, but my contract doesn't seem to be quite the same as those. I understand that variables defined inside the function (I have none), input parameters (I have 10), and output variables (also have 10) count in the 'must be less than 12' rule. But even that makes no sense. I mean... can you have a different number of input parameters than output variables? I would think you would get an error that they don't match if you did. In which case, 6 would be the maximum number of variables, not 12. Anyway, I'm looking for a solution to this. Is the only solution left, to split it into multiple functions? I'm getting the error only on the 'getSample' function, not the 'setSample' one.
pragma solidity ^0.4.24;
contract StackSample {
struct Sample {
uint var1;
uint var2;
uint var3;
uint var4;
uint var5;
uint var6;
uint var7;
uint var8;
uint var9;
uint var10;
}
mapping(uint => Sample) samples;
function setSample(uint _stackID, uint _var1, uint _var2, uint _var3, uint _var4, uint _var5, uint _var6, uint _var7, uint _var8, uint _var9, uint _var10) public {
var sample = samples[_stackID];
sample.var1 = _var1;
sample.var2 = _var2;
sample.var3 = _var3;
sample.var4 = _var4;
sample.var5 = _var5;
sample.var6 = _var6;
sample.var7 = _var7;
sample.var8 = _var8;
sample.var9 = _var9;
sample.var10 = _var10;
}
function getSample(uint _stackID) view public returns (uint, uint, uint, uint, uint, uint, uint, uint, uint, uint) {
return (samples[_stackID].var1, samples[_stackID].var2, samples[_stackID].var3, samples[_stackID].var4, samples[_stackID].var5, samples[_stackID].var6, samples[_stackID].var7, samples[_stackID].var8, samples[_stackID].var9, samples[_stackID].var10);
}
}