DIALOG CREATE,Chart element,-1,0,382,318 
  DIALOG ADD,STYLE,STYLE1,,8,,WHITE,BLACK 
  DIALOG ADD,EDIT,EDIT1,260,105,180,20,125 
  DIALOG ADD,BUTTON,SETCHART,260,290,65,20,Set 
  DIALOG ADD,COMBO,CHARTCOMBO,260,5,95,21,,LIST 
  DIALOG SHOW 

%%Chartpos = chart1|10|10|200|200|Chart 1|500 
rem       %%Chartpos = Name | X | Y | Wid | Hei | Value | Maxvalue 
rem Name             = The name of the element, like 'chart1' 
rem X                = The charts' top position 
rem Y                = The charts' position from the left 
rem Wid              = Width 
rem Hei              = Height 
rem Value            = The name that will be displayed. Can be empty. 
rem Maxvalue         = The highest value shown by the chart. If you use a higher one it isn't visible 

rem You must give up the properties that must be shown. 
rem You cannot add some later. if you want a blank one, use Name1|0 |Color
rem Usage: You must give up a name, a |, followed by the value 
%%Chartitems = Name1|100|DKBLUE|Name2|200|DKRED|Name3|300|DKBLUE|Name4|50|DKRED|Name5|90|DKBLUE|Name6|258|DKRED 
gosub Makechart 

rem -------------------------------------------------------------------------- 
rem Example: (Same as above, but this on is much better looking) 
rem   %%Chartpos = chart1|10|10|200|200|Chart 1|500 
rem   %%Chartitems = Name1|100|Name2|200|Name3|300|Name4|50|Name5|90|Name6|258 
rem   gosub Makechart 
rem -------------------------------------------------------------------------- 
rem If you want to delete this chart use this: 
rem   dialog delete,chart1 
rem -------------------------------------------------------------------------- 

rem This will load all the items in List 9, the chart items, into CHARTCOMBO 
rem If you want to use it an other way, you must know how it's build up. 
rem Name |Value 
rem Name1|100 
rem Name2|200 
rem Name3|300 
gosub Setchartcombo 



:Evloop 
wait event 
%%event = @event() 
goto %%event 

:Setchartbutton 
rem Use this to give a chart a new value. 
rem Usage: 
rem   %%Setchart = Name|Value 
rem   gosub Setchart 
rem Where Name is the name of the chartitem 

%%Setchart = @item(chartcombo)|@dlgtext(EDIT1) 
gosub Setchart 
goto evloop 

:Setchartcombo 
rem This is to set all the chart-items into the Chartcombo. 
rem You don't have to use this, it is just an example. 
%%repeatcounter = 0 
repeat 
parse "%%chartitemname",@item(9,%%repeatcounter) 
list add,chartcombo,%%chartitemname 
%%repeatcounter = @succ(%%repeatcounter) 
until @equal(%%repeatcounter,@count(9)) 
rem This is to make sure that there always a selected item. 
list seek,chartcombo,0 
exit 

:Close 
exit 

rem -------------------------------------------------------------------- 
rem - This is the main source, which must be included in every program - 
rem - which must use this Chart-code.                                  - 
rem -------------------------------------------------------------------- 

:Setchart 
option fieldsep,| 
parse "%%var1;%%var2",%%setchart 
list seek,9,0 
%%var3 = @match(9,%%var1|) 
%%var3 = @succ(@index(9)) 
dialog set,%%name%%var3,%%var3@cr()@chr(10)%%var2
%%var2 = @fmul(@fdiv(%%height,%%maxvalue),%%var2) 
%%var2 = @strdel(%%var2,@pos(@chr(46),%%var2),@len(%%var2)) 
dialog setpos,%%name%%var3,@fadd(@fadd(%x,@diff(%%height,%%var2)),3),@diff(@fadd(@fadd(%y,@prod(%%var3,%%breedte)),5),%%breedte),%%breedte,@diff(%%var2,6) 
exit 

:Makechart 
option decimalsep,. 
option fieldsep,| 
parse "%%name;%x;%y;%%width;%%height;%%value;%%maxvalue",%%chartpos 
dialog add,group,%%name,%x,%y,%%width,%%height,%%value 
list create,9 
repeat 
parse "%1;%2;%3",%%Chartitems 
rem info %1 
rem info %2 
rem info %3 
%%Chartitems = @strdel(%%Chartitems,1,@sum(@succ(@len(%1)),@succ(@len(%2)),@succ(@len(%3)))) 
list add,9,%1|%2|%3 
until @equal(@len(%%Chartitems),0) 
%%aantal = @count(9) 
%%breedte = @diff(@div(%%width,%%aantal),2) 
%%var1 = 0 
repeat 
parse "%%this;%%hoogte;%%color",@item(9,%%var1) 
%%var2 = @fmul(@fdiv(%%height,%%maxvalue),%%hoogte) 
%%var2 = @strdel(%%var2,@pos(@chr(46),%%var2),@len(%%var2)) 
dialog add,style,style@sum(%%var1,2),,,,%%color 
dialog add,Edit,%%name@succ(%%var1),@fadd(@fadd(%x,@diff(%%height,%%var2)),3),@fadd(@fadd(%y,@prod(%%var1,%%breedte)),5),%%breedte,@diff(%%var2,6),@succ(%%var1)@cr()@chr(10)%%hoogte,,style@sum(%%var1,2),MULTI
rem The next line makes sure that there isn't a event if someone presses a chartbutton. 
rem You can disable this by deleting the next line: 
dialog disable,%%name@succ(%%var1) 
%%var1 = @succ(%%var1) 
until @equal(%%var1,@count(9)) 
exit 
