gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
kod za nizslog malo unapredjen
authorDoni Pracner <quinnuendo@gmail.com>
Sat, 15 Feb 2014 17:41:42 +0000 (18:41 +0100)
committerDoni Pracner <quinnuendo@gmail.com>
Sat, 15 Feb 2014 17:45:37 +0000 (18:45 +0100)
kodovi/fajlovi/nizslog.MOD

index 051680d..e427bfa 100644 (file)
@@ -1,12 +1,13 @@
 MODULE nizslog;\r
 FROM InOut IMPORT WriteString, WriteLn, WriteCard,\r
     ReadCard, ReadString;\r
-FROM FIO IMPORT File, Open, Create, Close, EOF,\r
+FROM FIO IMPORT File, Exists, Open, Create, Close, EOF,\r
     RdItem, RdCard, WrStr, WrCard, WrLn;\r
 FROM Str IMPORT Compare;\r
 \r
 CONST\r
     MaxStud = 100;\r
+    radnifajl = "studenti.txt";\r
 TYPE\r
     String = ARRAY[1..30] OF CHAR;\r
     Student = RECORD\r
@@ -21,15 +22,17 @@ VAR
     f:File;\r
 BEGIN\r
     n:=0;\r
-    f:= Open(fajl);\r
-    EOF := FALSE;\r
-    WHILE NOT EOF DO\r
-        INC(n);\r
-        RdItem(f, spisak[n].prez);\r
-        RdItem(f, spisak[n].ime);\r
-        spisak[n].god := RdCard(f);\r
+    IF Exists(fajl) THEN\r
+        f:= Open(fajl);\r
+        EOF := FALSE;\r
+        WHILE NOT EOF DO\r
+            INC(n);\r
+            RdItem(f, spisak[n].prez);\r
+            RdItem(f, spisak[n].ime);\r
+            spisak[n].god := RdCard(f);\r
+        END;\r
+        Close(f);\r
     END;\r
-    Close(f);\r
 END UcitajF;\r
 \r
 PROCEDURE Ispisi(spisak:Studenti; n:CARDINAL);\r
@@ -111,12 +114,10 @@ END NoviStudent;
 \r
 VAR\r
     spisak : Studenti;\r
-    fajl:String;\r
     n:CARDINAL;\r
 BEGIN\r
-    fajl:="studenti.txt";\r
-    UcitajF(fajl, spisak, n);\r
+    UcitajF(radnifajl, spisak, n);\r
     Ispisi(spisak, n);\r
     NoviStudent(spisak,n);\r
-    IspisiF(fajl, spisak, n);\r
+    IspisiF(radnifajl, spisak, n);\r
 END nizslog.
\ No newline at end of file
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner