home *** CD-ROM | disk | FTP | other *** search
Modula Implementation | 1990-04-11 | 2.9 KB | 135 lines |
- (* Copyright 1988 Michal Todorovic *)
- (* For non-commercial use only. *)
-
- IMPLEMENTATION MODULE DosStuff;
-
- FROM System IMPORT argc, argv;
- FROM FileSystem IMPORT ReadChar, Lookup, Close, File,
- done;
- FROM TermInOut IMPORT WriteString;
-
-
-
-
- (**********************************************************)
- (* Gets the next string from the file. *)
- (**********************************************************)
- PROCEDURE GetNext(VAR InFile : File;
- VAR Info : ARRAY OF CHAR;
- Num : CARDINAL) : BOOLEAN;
-
- VAR
- Counter : CARDINAL;
- C : CHAR;
- Done : BOOLEAN;
-
- BEGIN
- Counter := 0;
- Done := TRUE;
-
- REPEAT
- ReadChar(InFile, C)
- UNTIL (((ORD(C) <> 10)AND(ORD(C) <> 32)) OR InFile.eof);
-
- IF InFile.eof THEN
- RETURN FALSE
- END;
-
- WHILE (NOT(InFile.eof) AND Done) DO
- IF (ORD(C) = 10) OR (ORD(C) = 32) THEN
- Done := FALSE
- ELSE
- IF Counter < Num THEN
- Info[Counter] := C;
- INC(Counter);
- ReadChar(InFile, C)
- ELSE
- RETURN FALSE
- END
- END
- END;
- RETURN TRUE
- END GetNext;
-
-
-
-
-
- (**********************************************************)
- (* Gets the single character 'C' or 'R' or 'Q' (upper or *)
- (* lower case) *)
- (**********************************************************)
- PROCEDURE GetNextChar (VAR InFile : File; VAR C : CHAR)
- : BOOLEAN;
-
- BEGIN
- REPEAT
- ReadChar(InFile, C)
- UNTIL (((ORD(C) <> 10)AND(ORD(C) <> 32)) OR InFile.eof);
- IF InFile.eof THEN
- RETURN FALSE
- END;
- C := CAP(C);
- RETURN ((C = 'C') OR (C = 'R') OR (C = 'Q'))
- END GetNextChar;
-
-
-
-
-
-
- (**********************************************************)
- (* Gets all the information from the configuration file. *)
- (**********************************************************)
- PROCEDURE GetInfo(VAR Paths : ARRAY OF LongString;
- VAR Name : ARRAY OF ShortString;
- VAR Memory : ARRAY OF CHAR;
- VAR Num : CARDINAL) : BOOLEAN;
-
- VAR
- Counter : CARDINAL;
- InFile : File;
- Check1,
- Check2,
- Check3 : BOOLEAN;
-
- BEGIN
- Check1 := TRUE;
- Check2 := TRUE;
- Check3 := TRUE;
- Counter := 0;
-
- IF (argc > 1) THEN
- (* Find user specified file *)
- Lookup(InFile,argv^[1]^, FALSE)
- ELSE
- (* Find default file *)
- Lookup(InFile,"S:Batchman.dat", FALSE)
- END;
-
- IF (InFile.res = done) THEN
- WHILE Check1 AND Check2 AND Check3
- AND (Counter <= MaxGadgets) DO
- Check1 := GetNext(InFile, Paths[Counter], 100);
- Check2 := GetNext(InFile, Name[Counter], 15);
- Check3 := GetNextChar(InFile, Memory[Counter]);
- INC(Counter)
- END;
-
- Close(InFile);
-
- Num := Counter - 1;
- RETURN (Check1 = Check2) AND (Check1 = Check3)
-
- ELSE
- WriteString("\n\nI couldn't open your input file\n\n");
- RETURN FALSE
- END
- END GetInfo;
-
-
-
-
-
- END DosStuff.
-