begin ! Fil: ~in105/wndstudbase.sim; external class Windowtools; inspect new SimpleWindow(" Student data-base ") do begin % Datastruktur : integer maks_ant = 200, antall; text array navn(1 : maks_ant); real array karakter(1 : maks_ant); % Kommandoprosedyrer : procedure UtforOrdre; begin text kommando; kommando :- ButtonChoice; while not kommando = "Avslutt" do begin if kommando = "Ny" then NyStudent else if kommando = "Vis alle" then VisAlle else if kommando = "Fjern" then Fjern else if kommando = "Til fil" then TilFil else if kommando = "Fra fil" then FraFil; kommando :- ButtonChoice; end; end; procedure NyStudent; if antall = maks_ant then outline("Databasen er full!") else begin antall := antall + 1; navn(antall) :- ask_for_text("Navn? "); karakter(antall) := ask_for_real("Karakter til " & navn(antall) & ": "); end; procedure VisAlle; begin integer i; MakeEmpty; outline("Data er lagret om følgende studenter:"); for i:= 1 step 1 until antall do begin outtext(" " & navn(i)); setpos(20); outfix(karakter(i), 1, 12); outimage; end; end; procedure Fjern; outline("Fjern: ikke implementert"); procedure FraFil; inspect new infile(ask_for_text("Fil navn?")) do if open(blanks(80)) then begin inimage; while not endfile do begin antall := antall + 1; karakter(antall) := inreal; inchar; navn(antall) :- intext(50).strip; inimage; end; close; end; procedure TilFil; inspect new outfile(ask_for_text("Fil navn?")) do begin integer i; open(blanks(80)); for i := 1 step 1 until antall do begin outfix(karakter(i), 1, 10); outchar(' '); outtext(navn(i)); outimage; end; close; end; MakeButton("Ny"); MakeButton("Vis alle"); MakeButton("Fjern"); MakeButton("Til fil"); MakeButton("Fra fil"); MakeButton("Avslutt"); UtforOrdre; end inspect SimpleWindow; end