i am not the best C programmer, so this might be a stupid question but:
in my app, i have 16 presets. here is the code for one of the preset
button handlers:
case midi1:
if (save)
{
prefs.mid1.chan=prefs.chan;
prefs.mid1.instrument=prefs.instrument;
prefs.mid1.vel=prefs.vel;
prefs.mid1.pitch=prefs.pitch;
prefs.mid1.range=prefs.range;
save = false;
}
else
{
SetFieldInt(instrumentlbl, prefs.mid1.instrument+1);
SetFieldInt(pitchlbl, prefs.mid1.pitch+1);
SetFieldInt(vellbl, prefs.mid1.vel+1);
SetFieldInt(rangelbl, prefs.mid1.range+1);
SetFieldInt(chanlbl, prefs.mid1.chan+1);
}
handled = true;
break;
it either sets the fields with a saved value or saves the current values
into a preset. i have sixteen version of this (16 presets), with mid1,
mid2, mid3, mid4, etc, so my code is quite huge. is there a
way to do this in a function where i could pass prefs.midX instead of
having 16 copies of nearly the same code?
i seem to remember someone recently saying that one shouldnt pass
structs in function parameters. if that is bad, then how can i take 16
code segments with nearly the same code and make 1 code segment with the
ability to fill in the changing part?
any ptrs?
:P