Unit is created in at start stack in a map window to hold variants
A global key command triggers the variant
Unit includes following traits:
Delete (on variant setting)
Report (on variant setting) - Format uses $OldMap$ (example desired report) “Variant-Alpha deletes UNIT A from Force Pool”
$OldMap$ returns nothing…
However, IF I manually move the unit within the map (exploring why this is happening) and THEN trigger the global key command
THEN $OldMap$ returns a value
I was reporting AFTER the delete action. I tested using both $CurrentMap$ and $OldMap$ before I posted my initial report - neither worked.
There appears to be no way of using system parameters to report information on a piece that has never moved prior to deletion.
While I could change the order of the report to report prior to deletion (as a workaround), having an engineering background, I really don’t want to report an activity prior it actually occurring. I’ve seen that approach lead to problems in the real world. (Example, you report something happens, but it’s possible the activity you are reporting on fails (for whatever reason)).
A classic debugging technique (for instance) is to report both PRIOR to and AFTER an event of interest…
I am surprised to learn that CurrentMap may be null in any circumstances except when a piece is on the palette; I do tend to deal with pre-set scenarios where pieces may well have been moved on the board already. Even so, a surprise and I haven’t been able to replicate it myself yet.
I appreciate your engineering discipline. That said, I stand by my statement that DELETE removes the piece and stops further processing by that piece. It is not possible for the piece itself to report after it has deleted itself. For a report after delete, it would have to be some other reporting mechanism (GKC on another piece, comes to mind).
If I’ve understood your description correctly, your piece is defined with a Delete trait followed by a Report trait, both listening for the same Key Command. In this case, you see a report because Non-trigger traits execute first, in bottom to top order, followed by trigger traits in top to bottom order. In your case: Report, followed by Delete, no trigger traits.
I think the solution to this issue is to treat the Delete trait as a Movement trait (which it essentially is) and have it set the Old properties prior to it executing.
This will ensure that oldMap is set to the Map of the board where the piece is being deleted from, even for newly created pieces that have not had oldMap set yet.
Sorry about my incorrect “advice” - until now I had failed to understand that the Report trait is special and always fires after Delete and all other traits.