make "InputXValues (array 100 0) make "InputYValues (array 100 0) make "InputXValuesSorted (array 100 0) make "InputYValuesSorted (array 100 0) make "NumOfInputValues 0 make "NumOfListBoxInputs 0 make "AxisXLength 450 make "AxisYLength 250 make "AxisXName "X" make "AxisYName "Y" make "MaxXValue 0 make "MaxYValue 0 make "MinXValue 0 make "MinYValue 0 make "CanDraw 0 make "FromFile 0 make "FileOpen 0 make "InsertFileWindowOpen 0 make "CurrentFileName "podatki.dat make "DefaultFileName "podatki.dat to MainWindow clean windowcreate "main "MainWindow [Diagrami] 200 150 150 150[] staticcreate "MainWindow "infoXXX1 [Risanje crtnih diagramov] 30 10 100 100 staticcreate "MainWindow "infoXXX2 [Program iz mnozice parov stevilcnih vrednosti narise crtni diagram. Pare vrednosti lahko vnesemo rocno v programu, oziroma jih nalozimo iz datoteke. Za zacetek klikni na gumb "Zacni"!] 10 25 130 130 buttoncreate "MainWindow "buttonRun [Zacni] 15 80 70 20 [ InsertAxisNamesWindow] buttoncreate "MainWindow "buttonInfo [Info] 15 100 70 20 [ infoX ] buttoncreate "MainWindow "buttonExit [Koncaj] 90 80 40 40 [ Exit ] end to InsertFileNameWindow :source if :InsertFileWindowOpen < 1 [ make "sourceX :source windowcreate "main "InsertFileName [Datoteka] 200 150 90 60[] Staticcreate "InsertFileName "textline222 [ Vnesi ime datoteke] 10 5 100 100 comboboxcreate "InsertFileName "FileNameBox 10 15 70 20 buttoncreate "InsertFileName "GetName [Vnesi!] 10 35 30 10 [SetFileName :sourceX] buttoncreate "InsertFileName "Cancel1 [Preklici!] 45 35 30 10 [cancelOpensaveFile] make "InsertFileWindowOpen 1 comboboxsettext "FileNameBox :DefaultFileName ] end to cancelOpensaveFile comboboxdelete "FileNameBox buttondelete "GetName windowdelete "InsertFileName make "InsertFileWindowOpen 0 end to SetFileName :source ifelse EMPTYP comboboxgettext "FileNameBox[][ make "CurrentFileName first comboboxgettext "FileNameBox comboboxdelete "FileNameBox buttondelete "GetName windowdelete "InsertFileName make "InsertFileWindowOpen 0 ifelse :source < 1[LoadFile][SaveToFile] ] end to LoadFile openread :CurrentFileName setread :CurrentFileName make "FileOpen 1 make "NumOfInputValuesTEMP readword make "AxisXName readlist make "AxisYName readlist make "FromFile 1 runLineGraph repeat :NumOfInputValuesTEMP [ make "x readword make "y readword insertLineGraphValue :x :y ] setread [] close :CurrentFileName make "FileOpen 0 end to SaveToFile openwrite :CurrentFileName setwrite :CurrentFileName print :NumOfInputValues print :AxisXName print :AxisYName make "i 1 repeat :NumOfInputValues[ print item :i :InputXValues print item :i :InputYValues make "i :i +1] setwrite [] close :CurrentFileName end to insertLineGraphValue :x :y make "bad_values 0 ifelse :FileOpen > 0 [ make "InsertValue1 :x make "InsertValue2 :y ][ if EMPTYP comboboxgettext "Value1 [make "bad_values 1] if EMPTYP comboboxgettext "Value2 [make "bad_values 1] if :bad_values < 1[ ifelse numberp first comboboxgettext "Value1 [make "InsertValue1 first comboboxgettext "Value1][make "bad_values 1] ifelse numberp first comboboxgettext "Value2 [make "InsertValue2 first comboboxgettext "Value2][make "bad_values 1] ] comboboxsettext "Value1 [] comboboxsettext "Value2 [] ] if :bad_values < 1[ ;pogledamo ce smo to vrednost ze vnesli make "i 1 make "is_inserted 0 make "on_index -1 repeat :NumOfInputValues[ if :InsertValue1 = item :i :InputXValues[ make "is_inserted 1 make "on_index :i ] make "i :i +1] ; to vrednost smo ze vnesli, zato moramo "povoziti" staro if :is_inserted = 1 [ setitem :on_index :InputXValues :InsertValue1 setitem :on_index :InputYValues :InsertValue2 ] ; te vrednosti se nismo vnesli if :is_inserted = 0 [ setitem :NumOfInputValues + 1 :InputXValues :InsertValue1 setitem :NumOfInputValues + 1 :InputYValues :InsertValue2 make "NumOfInputValues :NumOfInputValues + 1; ] make "MaxXValue ifelse (item :NumOfInputValues :InputXValues) > :MaxXValue [item :NumOfInputValues :InputXValues] [:MaxXValue] make "MaxYValue ifelse (item :NumOfInputValues :InputYValues) > :MaxYValue [item :NumOfInputValues :InputYValues] [:MaxYValue] make "MinXValue ifelse (item :NumOfInputValues :InputXValues) < :MinXValue [item :NumOfInputValues :InputXValues] [:MinXValue] make "MinYValue ifelse (item :NumOfInputValues :InputYValues) < :MinYValue [item :NumOfInputValues :InputYValues] [:MinYValue] listboxaddstring "ListX item :NumOfInputValues :InputXValues listboxaddstring "ListY item :NumOfInputValues :InputYValues make "NumOfListBoxInputs :NumOfListBoxInputs + 1 ] end to sort ;vse zastavice postavimo na 0 make "MarkValuesList (array :NumOfInputValues + 1 0) make "i 1 repeat :NumOfInputValues[ setitem :i :MarkValuesList 0 make "i :i +1] make "MinimumIndex -1 make "NextSorted 1 ;Iteriramo cez vse v listi in poiscemo najmanjsega ;Ko ga najdemo ga oznacimo make "j 1 repeat :NumOfInputValues [ make "i 1 make "Minimum 10000 repeat :NumOfInputValues [ make "CurrentValue item :i :InputXValues if :CurrentValue < :Minimum [ make "IsMarkt item :i :MarkValuesList if :IsMarkt = 0 [ make "Minimum :CurrentValue make "MinimumIndex :i ] ] make "i :i + 1] ;Oznacimo najmanjsega in ga damo na listo sortiranih! setitem :MinimumIndex :MarkValuesList 1 setitem :NextSorted :InputXValuesSorted item :MinimumIndex :InputXValues setitem :NextSorted :InputYValuesSorted item :MinimumIndex :InputYValues make "NextSorted :NextSorted + 1 make "j :j + 1 ] end to drawLineGraph if :NumOfInputValues > 0 [ sort make "PointSelected 1 make "PreviousAngle 0 make "MinXValue ifelse :MinXValue < 0 [-:MinXValue] [0] make "MinYValue ifelse :MinYValue < 0 [-:MinYValue] [0] make "MaxXDiff ifelse :MinXValue + :MaxXValue = 0 [1] [:MinXValue + :MaxXValue] make "MaxYDiff ifelse :MinYValue + :MaxYValue = 0 [1] [:MinYValue + :MaxYValue] make "ScaleX int ( :AxisXLength / :MaxXDiff )* 2/3 make "ScaleY int ( :AxisYLength / :MaxYDiff )* 2/3 make "x1Position item 1 :InputXValuesSorted make "y1Position item 1 :InputYValuesSorted clean home drawAxis setxy :x1Position * :ScaleX :y1Position *:ScaleY pendown repeat :NumOfInputValues [ circle 2 make "x1Position item :PointSelected :InputXValuesSorted make "y1Position item :PointSelected :InputYValuesSorted make "x2Position item :PointSelected + 1 :InputXValuesSorted make "y2Position item :PointSelected + 1 :InputYValuesSorted setxy :x1Position* :ScaleX :y1Position *:ScaleY make "PointSelected :PointSelected + 1]] circle 2 ;skrijemo zelvico penup setxy -500 -500 end to drawAxis make "ArrowLength 8 setxy -50 0 pendown right 90 forward (:AxisXLength + 50) label :AxisXName left 135 forward :ArrowLength penup right 180 forward :ArrowLength pendown right 90 forward :ArrowLength penup left 90 setxy (2/3 * :AxisXLength) /4 0 label :MaxXValue / 4 setxy (2/3 * :AxisXLength) /4 -3 pendown setxy (2/3 * :AxisXLength) /4 3 penup setxy (2/3 * :AxisXLength) /2 0 label :MaxXValue / 2 setxy (2/3 * :AxisXLength) /2 -3 pendown setxy (2/3 * :AxisXLength) /2 3 penup setxy (2/3 * :AxisXLength * 3) /4 0 label (:MaxXValue * 3 / 4) setxy (2/3 * :AxisXLength*3) /4 -3 pendown setxy (2/3 * :AxisXLength*3) /4 3 penup setxy (2/3 * :AxisXLength ) 0 label :MaxXValue setxy (2/3 * :AxisXLength) -3 pendown setxy (2/3 * :AxisXLength) 3 penup penup right 90 setxy 0 -50 right 135 pendown forward (:AxisYLength + 50) label :AxisYName left 135 forward :ArrowLength penup right 180 forward :ArrowLength pendown right 90 forward :ArrowLength penup left 90 setxy -50 (2/3 * :AxisYLength) /4 label :MaxYValue / 4 setxy -3 (2/3 * :AxisYLength) /4 pendown setxy 3 (2/3 * :AxisYLength) /4 penup setxy -50 (2/3 * :AxisYLength) /2 label :MaxYValue / 2 setxy -3 (2/3 * :AxisYLength) /2 pendown setxy 3 (2/3 * :AxisYLength) /2 penup setxy -50 (2/3 * :AxisYLength * 3) /4 label (:MaxYValue * 3 / 4) setxy -3 (2/3 * :AxisYLength*3) /4 pendown setxy 3 (2/3 * :AxisYLength*3) /4 penup setxy -50 (2/3 * :AxisYLength ) label :MaxYValue setxy -3 (2/3 * :AxisYLength) pendown setxy 3 (2/3 * :AxisYLength) penup setxy 0 0 left 135 end to deleteOptionWindow home clean pendown buttondelete "buttonRun buttondelete "buttonInfo windowdelete "MainWindow end to InsertAxisNamesWindow deleteOptionWindow windowcreate "main "LineGraphWindow2 [Crtni diagram] 200 150 140 135[] Staticcreate "LineGraphWindow2 "textline1 [ Spremenjlivkama doloci imeni:] 10 10 100 100 Staticcreate "LineGraphWindow2 "textline11 [ 1. spremenljivka:] 10 25 100 100 comboboxcreate "LineGraphWindow2 "NameX 70 25 50 20 Staticcreate "LineGraphWindow2 "textline22 [ 2. spremenljivka:] 10 50 100 100 comboboxcreate "LineGraphWindow2 "NameY 70 50 50 20 comboboxsettext "NameX [x] comboboxsettext "NameY [y] buttoncreate "LineGraphWindow2 "ProceedLineChart [Vnesi!] 30 70 80 20 [runLineGraph] buttoncreate "LineGraphWindow2 "LoadFIleX [Iz datoteke] 30 92 80 20 [InsertFileNameWindow 0] end to DeleteInsertAxisNames comboboxdelete "NameX comboboxdelete "NameY buttondelete "ProceedLineChart windowdelete "LineGraphWindow2 end to runLineGraph if :FromFile < 1 [ ifelse EMPTYP comboboxgettext "NameX [make "AxisXName "x][ make "AxisXName first comboboxgettext "NameX] ifelse EMPTYP comboboxgettext "NameY [make "AxisYName "y][ make "AxisYName first comboboxgettext "NameY] ] DeleteInsertAxisNames windowcreate "main "LineGraphWindow [Crtni diagram] 0 0 160 140[] Staticcreate "LineGraphWindow "textline1 [ Vnesi pare vrednosti:] 10 10 100 100 Staticcreate "LineGraphWindow "textline11 :AxisXName 10 25 100 100 comboboxcreate "LineGraphWindow "Value1 50 25 30 20 Staticcreate "LineGraphWindow "textline22 :AxisYName 10 50 100 100 comboboxcreate "LineGraphWindow "Value2 50 50 30 20 listboxcreate "LineGraphWindow "ListX 100 20 20 70 listboxcreate "LineGraphWindow "ListY 130 20 20 70 buttoncreate "LineGraphWindow "buttonInsertValue [Vnesi vpisani vrednosti!] 10 70 85 18 [ insertLineGraphValue -1 -1 ] buttoncreate "LineGraphWindow "buttonClear [Pocisti vse vnose!] 10 92 85 18 [ clearAllInputs ] buttoncreate "LineGraphWindow "buttondrawLineGraph [Narisi graf!] 100 92 50 18 [ drawLineGraph ] buttoncreate "LineGraphWindow "buttonsavetofile [Shrani v datoteko!] 10 115 85 12 [ InsertFileNameWindow 1] buttoncreate "LineGraphWindow "restartbutton [Na zacetek!] 100 115 50 12 [ Restart] end to deletelinegraphwindow comboboxdelete "Value1 comboboxdelete "Value2 buttondelete "buttonInsertValue buttondelete "buttonClear buttondelete "buttondrawLineGraph buttondelete "buttonsavetofile buttondelete "restartbutton listboxdelete "ListX listboxdelete "ListY windowdelete "LineGraphWindow end to Restart clearAllInputs deletelinegraphwindow MainWindow end to clearAllInputs make "Temp 1 repeat :NumOfListBoxInputs [ listboxdeletestring "ListX 0 listboxdeletestring "ListY 0 make "Temp :Temp + 1] make "NumOfInputValues 0 make "MaxXValue 0 make "MaxYValue 0 make "MinXValue 0 make "MinYValue 0 end to infoX buttondelete "buttonRun buttondelete "buttonInfo windowdelete "MainWindow windowcreate "main "info [Informacije o aplikaciji] 100 100 160 120[] staticcreate "info "info1 [Program: Risanje crtnih diagramov] 10 10 150 10 staticcreate "info "info2 [Avtor: Miha Jelenc] 10 20 100 10 staticcreate "info "info3 [Datum: 20.12.2003] 10 30 100 10 staticcreate "info "info4 [Pedagoska fakulteta] 10 40 100 10 staticcreate "info "info5 [Smer: Matematika in Racunalnistvo] 10 50 150 10 staticcreate "info "info6 [Predmet: Didaktika racunalnistva] 10 60 150 10 buttoncreate "info "buttonText1 "Nazaj 60 85 40 20 [ gotomain ] end to Exit buttondelete "buttonRun buttondelete "buttonInfo buttondelete "buttonExit windowdelete "MainWindow end to gotomain buttondelete "buttonText1 staticdelete "info1 staticdelete "info2 staticdelete "info3 staticdelete "info4 staticdelete "info5 staticdelete "info6 windowdelete "info MainWindow end MainWindow