I’d appreciate inspiration as to what I’m doing wrong here as I’m flummoxed! I have agents based on a shared prototype with four user-defined attributes, all numeric. Three are the results of prior calculations and their values, as revealed by setting them as Key Attributes, are as expected. However the fourth, which is defined in the prototype’s $Rule as
(i.e. simply attribute 4 = attribute 1 - attribute 2 - attribute 3) isn’t working. It’s evaluating as just attribute 1 ($WhatsFair). These are “unremarkable” numbers: $WhatsFair is typically between 0.5 and 2 and comes from a simple ratio calculation; $DidLastNight takes values of 0.9 or 0 only and is set by an if/else rule; similarly $DidNightBeforeThat takes 0.5 or 0 only set by an if/else
Any thoughts as to what may be amiss please? (This is TBX 7.0.1)
In a case like this I’d make a simulation test using fixed values of $WhatsFair, $DidLastNight and $DidNightBeforeThat. This strikes out any contribution of calculated values. I’d also try attribute 4 = (attribute 1 - attribute 2) - attribute 3, to see if there’s an evaluation issue; in the last attribute 3 is explicitly subtracted from the resolved value of attribute 1-attribute 2. As MB says without seeing more detail (as in the code in the source doc or a text doc that shows the problem) it is hard to diagnose further.
Thanks as ever both of you. I’m happy to debug methodically: just good to know that something along these lines should work (e.g. there’s no limitation of the code parser in handling sequential subtractions)
To satisfy yourself that sequential subtraction behaves as you expect, make a new document and a new note. Make $MyNumber a key attribute of that note.
Add the following rule to that note:
$MyNumber = 7 -4 -1
Deselect and reselect your note; what now is the value of $MyNumber?