make "InputValues (array 300 0) make "InputValuesSorted (array 300 0) make "NumOfInputValues 0 ;Pomoč za izračun mediane in modusa make "AllFrequnces (array 200 0) make "AllValuesSingle (array 200 0) make "NumOfDiffValues 0 make "VariableName "V1" make "should_draw 1 make "TheoryWindowOn 0 make "FileOpen 0 make "InsertFileWindowOpen 0 make "CurrentFileName "Podatki.txt make "DefaultFileName "Podatki.txt make "CakeCenterX 100 make "CakeCenterY -80 make "CakeRadius 70 make "LastAngle 0 to draw_cake_circle penup setxy :CakeCenterX :CakeCentery pendown circle :CakeRadius penup end make "cake_first_time 0 make "LastCakeAngle 0 to draw_cake :freq :value if :cake_first_time < 1 [draw_cake_circle make "cake_first_time 1] make "angle_diff 360 * (:freq/:NumOfInputValues) penup setxy :CakeCenterX :CakeCentery left :LastCakeAngle pendown forward :CakeRadius penup right :LastCakeAngle setxy :CakeCenterX :CakeCentery pendown make "LastCakeAngle :LastCakeAngle + :angle_diff left :LastCakeAngle forward :CakeRadius penup ;label setxy :CakeCenterX :CakeCentery right :angle_diff / 2 forward 3 * :CakeRadius/2 right :LastCakeAngle - :angle_diff / 2 label :value forward 30 label "- forward 10 label int (:freq * 100/:NumOfInputValues) forward 30 label "% 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 "VariableName readlist SetValuesWindow make "FromFile 1 repeat :NumOfInputValuesTEMP [InsertValue readword 1] setread [] close :CurrentFileName make "FileOpen 0 end to SaveToFile openwrite :CurrentFileName setwrite :CurrentFileName print :NumOfInputValues print :VariableName repeat :NumOfInputValues[print item repcount - 1 :InputValues ] setwrite [] close :CurrentFileName end to deleteOptionWindow home clean pendown buttondelete "buttonRun buttondelete "buttonInfo windowdelete "MainWindow end to gotomain buttondelete "buttonText1 staticdelete "info1 staticdelete "info2 staticdelete "info3 staticdelete "info4 staticdelete "info5 staticdelete "info6 windowdelete "info MainWindow end to infowindow buttondelete "buttonRun buttondelete "buttonInfo windowdelete "MainWindow windowcreate "main "info [Informacije o programu] 100 100 160 120[] staticcreate "info "info1 [Program: Statistična obdelava podatkov] 10 10 150 10 staticcreate "info "info2 [Avtor: Aleš Jagodnik] 10 20 100 10 staticcreate "info "info3 [Datum: 20.12.2003] 10 30 100 10 staticcreate "info "info4 [Pedagoška fakulteta] 10 40 100 10 staticcreate "info "info5 [Smer: Matematika in računalništvo] 10 50 150 10 staticcreate "info "info6 [Predmet: Didaktika računalništva] 10 60 150 10 buttoncreate "info "buttonText1 "Ok 60 85 40 20 [ gotomain ] end to CloseTheoryWindow staticdelete "t_info1 staticdelete "t_info2 staticdelete "t_info3 staticdelete "t_info4 staticdelete "t_info5 staticdelete "t_info6 staticdelete "t_info7 buttondelete "buttonHideTheory windowdelete "TheoryWindowXXX make "TheoryWindowOn 0 end to TheoryWindow if :TheoryWindowOn = 0[ windowcreate "main "TheoryWindowXXX [Pojmi] 0 200 200 140[] staticcreate "TheoryWindowXXX "t_info1 [POJMI] 80 10 100 10 staticcreate "TheoryWindowXXX "t_info4 [Povprečna vrednost:] 10 40 100 10 staticcreate "TheoryWindowXXX "t_info5 [Aritmetična sredina vseh elementov ( (E1 + E2 + ... + En ) / n )] 80 40 120 40 staticcreate "TheoryWindowXXX "t_info2 [Modus:] 10 60 100 10 staticcreate "TheoryWindowXXX "t_info3 [Vrednost, ki se največkrat ponovi (ima največjo frekvenco).] 50 60 150 40 staticcreate "TheoryWindowXXX "t_info6 [Mediana:] 10 80 100 10 staticcreate "TheoryWindowXXX "t_info7 [Sredinska vrednost (glede na pozicijo elementa v vrsti)] 50 80 150 40 buttoncreate "TheoryWindowXXX "buttonHideTheory [Zapri] 70 110 70 12 [ CloseTheoryWindow ] make "TheoryWindowOn 1 ] end to sort make "MarkValuesList (array :NumOfInputValues + 1 0) make "i 0 repeat :NumOfInputValues[ setitem :i :MarkValuesList 0 make "i :i +1] make "MinimumIndex -1 make "NextSorted 0 ;Iteriramo cez vse v listi in poiscemo najmanjsega ;Ko ga najdemo ga oznacimo make "j 0 repeat :NumOfInputValues [ make "i 0 make "Minimum 10000 repeat :NumOfInputValues [ make "CurrentValue item :i :InputValues 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 :InputValuesSorted item :MinimumIndex :InputValues make "NextSorted :NextSorted + 1 make "j :j + 1 ] end to print_all_sorted :x :y right 90 penup make "i 0 repeat :NumOfInputValues[ setxy 100*:i 100 label item :i :InputValuesSorted make "i :i + 1] end to draw_column :x :y :height :value penup setxy :x + 40 :y - 10 label :value penup setxy :x :y pendown forward 25 left 90 forward :height * 20 right 90 forward 15 label :height forward 15 right 90 forward :height * 20 end to draw_cols_sorted_freq :x :y penup make "CurrentValue -1 make "PrevValue item 0 :InputValuesSorted make "RowNum 0 make "Freq 0 setxy :x :y + 30 label "Frekvence" setxy :x :y - 10 label "Vrednosti" make "x :x + 100 make "i 0 repeat :NumOfInputValues + 1[ make "CurrentValue item :i :InputValuesSorted ifelse :CurrentValue = :PrevValue [ make "Freq :Freq + 1 ] [ draw_cake :Freq :PrevValue draw_column :x + :RowNum*55 :y :Freq :PrevValue left 90 setitem :RowNum :AllFrequnces :Freq setitem :RowNum :AllValuesSingle :PrevValue make "RowNum :RowNum + 1 make "PrevValue :CurrentValue make "Freq 1 make "NumOfDiffValues :RowNum ] make "i :i + 1] penup end to print_all_sorted :x :y penup setxy :x :y label "Razvrščene_vrednosti:" make "x :x + 240 make "i 0 make "index 0 repeat :NumOfInputValues[ if :i > 10 [ make "y :y - 20 make "i 0] setxy :x + :i*40 :y label item :index :InputValuesSorted make "i :i + 1 make "index :index + 1 ] end to print_min_max :x :y setxy :x :y label "Minimalna_vrednost:" setxy :x + 240 :y label item 0 :InputValuesSorted setxy :x :y - 20 label "Maksimalna_vrednost:" setxy :x + 240 :y - 20 label item :NumOfInputValues-1 :InputValuesSorted end to print_avarage_value :x :y make "i 0 make "Suma 0 repeat :NumOfInputValues[ make "Suma :Suma + item :i :InputValuesSorted make "i :i + 1] make "Avarage :Suma/:NumOfInputValues setxy :x :y label "Povprečna_vrednost:" setxy :x + 240 :y label :Avarage end to print_mediana :x :y setxy :x :y label "Mediana:" make "is_odd modulo :NumOfInputValues 2 ;pogledamo ce imamo sodo ali liho stevilo vrednosti if :is_odd = 0 [ make "center_index :NumOfInputValues / 2 make "First item :center_index - 1 :InputValuesSorted make "Second item :center_index :InputValuesSorted make "Mediana (:First + :Second) / 2 ] if :is_odd = 1 [ make "center_index (:NumOfInputValues + 1) / 2 make "Mediana item :center_index :InputValuesSorted ] setxy :x +240 :y label :Mediana end to print_modus :x :y setxy :x :y label "Modus:" make "MaxFreq 0 make "MaxFreqIndex 0 make "i 0 repeat :NumOfDiffValues[ make "CurrFreq item :i :AllFrequnces if :CurrFreq > :MaxFreq [ make "MaxFreq :CurrFreq make "MaxFreqIndex :i ] make "i :i + 1 ] setxy :x +240 :y label item :MaxFreqIndex :AllValuesSingle make "x :x + 250 make "modus_num 0 make "i 0 repeat :NumOfDiffValues[ make "CurrFreq item :i :AllFrequnces if :CurrFreq = :MaxFreq [ ifelse :i = :MaxFreqIndex [][ make "modus_num :modus_num + 1 setxy :x + :modus_num * 20 :y label item :i :AllValuesSingle ] ] make "i :i + 1 ] end to clear_all repeat :NumOfInputValues [listboxdeletestring "ValueList_BoX 0] make "NumOfInputValues 0 make "NumOfDiffValues 0 make "should_draw 0 make "cake_first_time 0 clearscreen end to Calculate if :should_draw = 1[ clearscreen sort right 90 penup print_min_max -150 500 print_avarage_value -150 430 print_all_sorted -150 350 draw_cols_sorted_freq -150 100 print_mediana -150 400 print_modus -150 380 setxy -500 -500 ] make "should_draw 0 make "cake_first_time 0 end to DeleteInsertVarNameWindow comboboxdelete "NameX buttondelete "AddName windowdelete "WINDOW_VALUE_NAME end to SetValuesWindow make "bad_value 0 make "NumOfInputValues 0 if :FileOpen < 1[ifelse EMPTYP comboboxgettext "NameX [make "bad_value 1][make "VariableName first comboboxgettext "NameX]] if :bad_value < 1[ DeleteInsertVarNameWindow windowcreate "main "InputWindow [Vnos vrednosti] 0 0 140 140[] Staticcreate "InputWindow "textline1 [ Vnesi vrednosti:] 30 0 100 100 Staticcreate "InputWindow "textline11 :VariableName 10 15 100 100 comboboxcreate "InputWindow "VariableValue 10 25 40 20 listboxcreate "InputWindow "ValueList_BoX 100 10 30 100 buttoncreate "InputWindow "buttonInsertValue [Vnesi!] 60 25 30 13 [ InsertValue -1 0] buttoncreate "InputWindow "buttonCalculate [Izračunaj!] 5 50 70 18 [ Calculate ] buttoncreate "InputWindow "buttonClearAll [Pobriši vse!] 5 70 70 18 [ clear_all] buttoncreate "InputWindow "Pojmi [Pojmi] 5 90 70 12 [ TheoryWindow ] buttoncreate "InputWindow "ShraniX [Shrani v datoteko] 5 110 70 12 [ InsertFileNameWindow 1] buttoncreate "InputWindow "RestartX [Znova] 75 110 30 12 [ Restart] buttoncreate "InputWindow "VenX [Izhod] 105 110 30 12 [ Exit2] ] end to InsertValue :value :fromfile make "bad_value 0 ifelse :fromfile < 1 [ ifelse EMPTYP comboboxgettext "VariableValue [ make "bad_value 1 ] [ ifelse numberp first comboboxgettext "VariableValue [ setitem :NumOfInputValues :InputValues first comboboxgettext "VariableValue ] [ make "bad_value 1 ] ] ][setitem :NumOfInputValues :InputValues :value] if :bad_value < 1[ listboxaddstring "ValueList_BoX item :NumOfInputValues :InputValues make "NumOfInputValues :NumOfInputValues + 1 comboboxsettext "VariableValue[] make "should_draw 1 ] end to InsertVariableNameWindow deleteOptionWindow windowcreate "main "WINDOW_VALUE_NAME [Statistika] 200 150 150 115[] Staticcreate "WINDOW_VALUE_NAME "textline1 [Vnesite ime spremenljivke, oziroma preberite podatke iz datoteke.] 10 10 130 130 Staticcreate "WINDOW_VALUE_NAME "textline2 [Spremenljivka:] 10 40 100 100 comboboxcreate "WINDOW_VALUE_NAME "NameX 70 40 50 20 buttoncreate "WINDOW_VALUE_NAME "AddName [Vnesi!] 30 55 80 15 [SetValuesWindow] buttoncreate "WINDOW_VALUE_NAME "LoadFileButton[Preberi iz datoteke] 30 80 80 15 [InsertFileNameWindow 0] end to restart clear_all buttondelete "buttonInsertValue buttondelete "buttonCalculate buttondelete "buttonClearAll buttondelete "Pojmi buttondelete "ShraniX buttondelete "RestartX listboxdelete "ValueList_BoX comboboxdelete "VariableValue windowdelete "InputWindow MainWindow end to Exit buttondelete "buttonRun buttondelete "buttonInfo buttondelete "buttonExit windowdelete "MainWindow end to Exit2 windowdelete "InputWindow end to Exit3 windowdelete "InputWindow end to MainWindow clean windowcreate "main "MainWindow [Statistika] 200 150 100 100[] buttoncreate "MainWindow "buttonRun [Začni] 15 15 70 20 [ InsertVariableNameWindow] buttoncreate "MainWindow "buttonInfo [O programu] 15 35 70 20 [ infowindow] buttoncreate "MainWindow "buttonExit [Izhod] 15 55 70 20 [ Exit] end MainWindow