From 745174300775ee6f9b04e8920df857dae68d9a26 Mon Sep 17 00:00:00 2001 From: Doni Pracner Date: Sat, 15 Feb 2014 18:41:42 +0100 Subject: [PATCH] kod za nizslog malo unapredjen --- kodovi/fajlovi/nizslog.MOD | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) 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 -- 2.17.1