From: Doni Pracner Date: Sat, 15 Feb 2014 17:41:42 +0000 (+0100) Subject: kod za nizslog malo unapredjen X-Git-Tag: v14a~8^2~4 X-Git-Url: https://svarog.pmf.uns.ac.rs/gitweb/?a=commitdiff_plain;h=745174300775ee6f9b04e8920df857dae68d9a26;p=spa1skripta-public.git kod za nizslog malo unapredjen --- diff --git a/kodovi/fajlovi/nizslog.MOD b/kodovi/fajlovi/nizslog.MOD index 051680d..e427bfa 100644 --- a/kodovi/fajlovi/nizslog.MOD +++ b/kodovi/fajlovi/nizslog.MOD @@ -1,12 +1,13 @@ MODULE nizslog; FROM InOut IMPORT WriteString, WriteLn, WriteCard, ReadCard, ReadString; -FROM FIO IMPORT File, Open, Create, Close, EOF, +FROM FIO IMPORT File, Exists, Open, Create, Close, EOF, RdItem, RdCard, WrStr, WrCard, WrLn; FROM Str IMPORT Compare; CONST MaxStud = 100; + radnifajl = "studenti.txt"; TYPE String = ARRAY[1..30] OF CHAR; Student = RECORD @@ -21,15 +22,17 @@ 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); + IF Exists(fajl) THEN + 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; - Close(f); END UcitajF; PROCEDURE Ispisi(spisak:Studenti; n:CARDINAL); @@ -111,12 +114,10 @@ END NoviStudent; VAR spisak : Studenti; - fajl:String; n:CARDINAL; BEGIN - fajl:="studenti.txt"; - UcitajF(fajl, spisak, n); + UcitajF(radnifajl, spisak, n); Ispisi(spisak, n); NoviStudent(spisak,n); - IspisiF(fajl, spisak, n); + IspisiF(radnifajl, spisak, n); END nizslog. \ No newline at end of file