During a print, the running total of filament used should be the sum of lastFilamentLength and filamentLength.  It should not be lastFilamentLength when non-zero and filamentLength otherwise.  To demonstrate, extrude a little plastic, then set the extruder temp to 0, then re-heat it and continue extruding.  Setting temp to 0 then makes lastFilamentLength be the amount extruded only up until the extruder was turned off.