Using Neobook Syntax Highlighting

npPlotCreate "Graph" "[Result]"

npPlotTitleOptions "Graph" "Calls per year" "Tahoma|11|0,0,0" "[Result]"

npPlotAddSeries "Graph" "Calls" "skBar" "[Result]"

npPlotAxisXOptions "Graph" "Year" "1" "[Result]"

npPlotAxisYOptions "Graph" "Calls" "1" "[Result]"

npPlotBeginUpdate "Graph" "[Result]"

Setvar "[YearVar]" "[Year]"

StrDel "[YearVar]" "1" "2" "[YearShort]"

Setvar "[YearCount]" "0"

While "[YearCount]" "<=" "[YearShort]"

if "[YearCount]" "<" "10"

Setvar "[AddedZero]" "0"

else

Setvar "[AddedZero]" ""

endif

dbpQuery "FIRE" "tblIncidents" "IncidentDateTime BETWEEN #20[AddedZero][YearCount]-01-01# AND #20[AddedZero][YearCount]-12-31#"

setvar "[Year20[AddedZero][YearCount]]" "[FIRE.tblIncidents.$RecCount]"

npPlotAddXY "Graph" "Calls" "20[AddedZero][YearCount]" "[Year20[AddedZero][YearCount]]" "[Result]"

Math "[YearCount]+1" "0" "[YearCount]"

endwhile

npPlotEndUpdate "Graph" "[Result]"

CustomWindow "Call's per year" "-1" "-1" "Graph" "ToolWindow"

npPlotTitleOptions "Graph" "Calls per year" "Tahoma|11|0,0,0" "[Result]"

npPlotAddSeries "Graph" "Calls" "skBar" "[Result]"

npPlotAxisXOptions "Graph" "Year" "1" "[Result]"

npPlotAxisYOptions "Graph" "Calls" "1" "[Result]"

npPlotBeginUpdate "Graph" "[Result]"

Setvar "[YearVar]" "[Year]"

StrDel "[YearVar]" "1" "2" "[YearShort]"

Setvar "[YearCount]" "0"

While "[YearCount]" "<=" "[YearShort]"

if "[YearCount]" "<" "10"

Setvar "[AddedZero]" "0"

else

Setvar "[AddedZero]" ""

endif

dbpQuery "FIRE" "tblIncidents" "IncidentDateTime BETWEEN #20[AddedZero][YearCount]-01-01# AND #20[AddedZero][YearCount]-12-31#"

setvar "[Year20[AddedZero][YearCount]]" "[FIRE.tblIncidents.$RecCount]"

npPlotAddXY "Graph" "Calls" "20[AddedZero][YearCount]" "[Year20[AddedZero][YearCount]]" "[Result]"

Math "[YearCount]+1" "0" "[YearCount]"

endwhile

npPlotEndUpdate "Graph" "[Result]"

CustomWindow "Call's per year" "-1" "-1" "Graph" "ToolWindow"

Parsed in 0.009 seconds, using GeSHi 1.0.8.10

This code it's actually doing pretty much all what it's supposed to... except that the result its as follows:

Any clues =)

EDIT: I realized I can put all in a single While...