The following code doesn’t work as I expected:
outputmacro: ^addUpdateFact (^subject ^object ^flag)
@0 = ^query(direct_svo ^subject verb ^object 1)
^if (^length(@0) == 0)
{
@20 += ^createfact(^subject verb ^object (FACTTRANSIENT ^flag))
}
else
{
^addproperty(@0 ^flag)
}
If the fact triple is not found then a fact is created with a flag. That works perfectly.
But if the fact already exists, I just want to update the flag for it. But ^addproperty cannot decode the flag when is passed as a parameter. It logs a “Unknown addproperty value ^2”.
It is the same result if I use a $$variable instead.
Should this syntax work, or am I left with the workaround of
^if (^flag == USER_FLAG1)
{
^addproperty(@0 USER_FLAG1)
}
else if (^flag == USER_FLAG2)
{
^addproperty(@0 USER_FLAG2)
}
else if (^flag == USER_FLAG3)
{
^addproperty(@0 USER_FLAG3)
}
In a slightly similar vein, on a directflag_* query, then the flag value to be match against cannot be expressed as the string constant, i.e. USER_FLAG1 and I have to use the underlying numeric value instead, i.e. 4096.