That seems to have fixed one issue around this. Now I'm able to set the multislot field to an "empty" multifieldValue. Nice!
I'm now running into a different issue. When I try to set that multifield value twice in a row, I get the following error:
[PRNTUTIL3]
*** CLIPS SYSTEM ERROR ***
ID = SYMBOL6
CLIPS data structures are in an inconsistent or corrupted state.
This error may have occurred from errors in user defined code.
Replace the `main` function in `main.c` to reproduce:
int main(
int argc,
char *argv[])
{
mainEnv = CreateEnvironment();
Build(mainEnv, "(deftemplate foo (multislot bar))");
Fact *f = AssertString(mainEnv, "(foo (bar 1 2 \"Foo!\"))");
FactModifier *fm = CreateFactModifier(mainEnv, f);
MultifieldBuilder *mb = CreateMultifieldBuilder(mainEnv, 1);
MBAppendInteger(mb, 1);
Multifield *mf = MBCreate(mb);
MBDispose(mb);
FMPutSlotMultifield(fm, "bar", mf);
Fact *f2 = FMModify(fm);
FMDispose(fm);
FactModifier *fm2 = CreateFactModifier(mainEnv, f2);
MultifieldBuilder *mb2 = CreateMultifieldBuilder(mainEnv, 1);
MBAppendInteger(mb2, 2);
Multifield *mf2 = MBCreate(mb2);
MBDispose(mb2);
FMPutSlotMultifield(fm2, "bar", mf2);
Fact *f3 = FMModify(fm2);
FMDispose(fm2);
FactModifier *fm3 = CreateFactModifier(mainEnv, f3);
MultifieldBuilder *mb3 = CreateMultifieldBuilder(mainEnv, 1);
MBAppendInteger(mb3, 3);
Multifield *mf3 = MBCreate(mb3);
MBDispose(mb3);
FMPutSlotMultifield(fm3, "bar", mf3);
Fact *f4 = FMModify(fm3);
FMDispose(fm3);
Facts(mainEnv, "stdout", NULL, -1, -1, -1);
DestroyEnvironment(mainEnv);
return -1;
}