home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
PASCAL
/
MADTRB21.ZIP
/
GENERIC.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-11-16
|
2KB
|
83 lines
PROGRAM GENERIC;
LABEL 100;
CONST ITERATIONS = 25;
TYPE INPUT_FILE = TEXT;
STRING80 = STRING[80];
VAR COUNTER : INTEGER;
OK : BOOLEAN;
LIMIT : INTEGER;
FOO_FACTOR : INTEGER;
BUFFER : STRING80;
DO_FILE : INPUT_FILE;
PROCEDURE OPEN_A_FILE(VAR OK : BOOLEAN);
VAR I : INTEGER;
BEGIN
ASSIGN(DO_FILE,'MYTEXT.TXT');
{$I-} RESET(DO_FILE); {$I+}
I := IORESULT;
IF I = 0 THEN OK := TRUE ELSE OK := FALSE;
END;
FUNCTION CRUNCH_LINE(BUFFER : STRING80) : INTEGER;
VAR I : INTEGER;
BUCKET : INTEGER;
BEGIN
CRUNCH_LINE := 0;
IF LENGTH(BUFFER) > 0 THEN
BEGIN
BUCKET := 0;
FOR I := 1 TO LENGTH(BUFFER) DO BUCKET := BUCKET +
ORD(BUFFER[I]);
BUCKET := BUCKET DIV LENGTH(BUFFER);
CRUNCH_LINE := BUCKET
END
END;
FUNCTION CRUNCH_FILE(VAR DO_FILE : INPUT_FILE) : INTEGER;
VAR PASSES : INTEGER;
TEMP : INTEGER;
BEGIN
TEMP := 0;
FOR PASSES := 1 TO ITERATIONS DO
BEGIN
RESET(DO_FILE);
WHILE NOT EOF(DO_FILE) DO
BEGIN
READLN(DO_FILE,BUFFER);
TEMP := TEMP+CRUNCH_LINE(BUFFER);
END
END;
CRUNCH_FILE := TEMP DIV ITERATIONS
END;
BEGIN { Main Program }
OPEN_A_FILE(OK);
IF NOT OK THEN
BEGIN
WRITELN('>>The file cannot be opened.');
GOTO 100
END;
FOO_FACTOR := CRUNCH_FILE(DO_FILE);
WRITELN('>>Foo Factor for Input File is ',FOO_FACTOR);
CLOSE(DO_FILE);
WRITELN('>>Processing completed.');
100:
END.