From: Doni Pracner Date: Sat, 15 Feb 2014 17:32:01 +0000 (+0100) Subject: premestanje kodova u folder 'fajlovi' X-Git-Tag: v14a~8^2~5 X-Git-Url: https://svarog.pmf.uns.ac.rs/gitweb/?a=commitdiff_plain;h=d5fffd8a3f9caeb6ac3e446a7ea7a25499bf7404;p=spa1skripta-public.git premestanje kodova u folder 'fajlovi' --- diff --git a/kodovi/fajlovi/nizslog.MOD b/kodovi/fajlovi/nizslog.MOD new file mode 100644 index 0000000..051680d --- /dev/null +++ b/kodovi/fajlovi/nizslog.MOD @@ -0,0 +1,122 @@ +MODULE nizslog; +FROM InOut IMPORT WriteString, WriteLn, WriteCard, + ReadCard, ReadString; +FROM FIO IMPORT File, Open, Create, Close, EOF, + RdItem, RdCard, WrStr, WrCard, WrLn; +FROM Str IMPORT Compare; + +CONST + MaxStud = 100; +TYPE + String = ARRAY[1..30] OF CHAR; + Student = RECORD + ime, prez: String; + god: CARDINAL; + END; + Studenti = ARRAY[1..MaxStud] OF Student; + +PROCEDURE UcitajF(fajl:String; + VAR spisak: Studenti; VAR n:CARDINAL); +VAR + f:File; +BEGIN + n:=0; + f:= Open(fajl); + EOF := FALSE; + WHILE NOT EOF DO + INC(n); + RdItem(f, spisak[n].prez); + RdItem(f, spisak[n].ime); + spisak[n].god := RdCard(f); + END; + Close(f); +END UcitajF; + +PROCEDURE Ispisi(spisak:Studenti; n:CARDINAL); +VAR + i: CARDINAL; +BEGIN + FOR i:=1 TO n DO + WriteString(spisak[i].prez); + WriteString(" "); + WriteString(spisak[i].ime); + WriteString(" "); + WriteCard(spisak[i].god,1); + WriteLn; + END; +END Ispisi; + +PROCEDURE IspisiF(fajl:String; + spisak:Studenti; n:CARDINAL); +VAR + f:File; + i: CARDINAL; +BEGIN + IF (n>0) AND (n<=MaxStud) THEN + f:=Create(fajl); + (* pravimo takav fajl da ne + postoji zadnji prazan red *) + FOR i:=1 TO n-1 DO + WrStr(f,spisak[i].prez); + WrStr(f," "); + WrStr(f,spisak[i].ime); + WrStr(f," "); + WrCard(f,spisak[i].god,1); + WrLn(f); + END; + WrStr(f,spisak[n].prez); + WrStr(f," "); + WrStr(f,spisak[n].ime); + WrStr(f," "); + WrCard(f,spisak[n].god,1); + Close(f); + END; +END IspisiF; + +PROCEDURE NoviStudent(VAR spisak:Studenti; VAR n:CARDINAL); +VAR + stud,temp:Student; + i:CARDINAL; + dodaj:BOOLEAN; +BEGIN + IF n0) AND (n<=MaxStud) THEN - f:=Create(fajl); - (* pravimo takav fajl da ne - postoji zadnji prazan red *) - FOR i:=1 TO n-1 DO - WrStr(f,spisak[i].prez); - WrStr(f," "); - WrStr(f,spisak[i].ime); - WrStr(f," "); - WrCard(f,spisak[i].god,1); - WrLn(f); - END; - WrStr(f,spisak[n].prez); - WrStr(f," "); - WrStr(f,spisak[n].ime); - WrStr(f," "); - WrCard(f,spisak[n].god,1); - Close(f); - END; -END IspisiF; - -PROCEDURE NoviStudent(VAR spisak:Studenti; VAR n:CARDINAL); -VAR - stud,temp:Student; - i:CARDINAL; - dodaj:BOOLEAN; -BEGIN - IF n