home *** CD-ROM | disk | FTP | other *** search
- Program GRPTest;
- {───────────────────────────────────────────────────────────────────┐
-
- This is a Test for Group Files. It will take an ascii file of Names
- and phone numbers and convert it into a series of group files. Take
- out references to CAMPhone and USES statement to CFAX if you wish to
- make this work for CFAX.
-
- Turbo Pascal 5.5
- DOS 3.3
- September 28, 1990
- └───────────────────────────────────────────────────────────────────}
-
- Uses TPCRT,
- TPString,
- TPDate,
- CCom;
-
- Type
- FileName = String[12];
-
- VAR
- Ascii : Text;
- AsciiName : FileName;
- GroupID : String[5];
-
- Procedure ProcessError( error : integer;
- Locus : string);
- {───────────────────────────────────────────────────────────────────
- This procedure processes errors and halts the program. It should be
- beefed up quite a bit, but for the sake of brevity I've merely included
- it as a model upon which to build your own.
- ───────────────────────────────────────────────────────────────────}
-
- Begin
- WriteLn;
- Case error of
- 1..20 : WriteLn('Dos Error ', error:2, ', while ', Locus);
- Else
- Write('Problem ', error:4, ': ', Locus);
- End;
- Halt;
- End; { ProcessError }
-
- Function OpenAscii (AsciiName : FileName) : Boolean;
- {───────────────────────────────────────────────────────────────────
- This function opens the ascii file.
- ───────────────────────────────────────────────────────────────────}
- VAR
- err : integer;
-
- Begin
- OpenAscii := False;
- Assign(Ascii, AsciiName);
- {$I-}
- Reset(Ascii);
- {$I+}
- err := IoResult;
- If err > 0
- then ProcessError(err, 'Opening Ascii File.')
- else OpenAscii := True
- End; { OpenAscii }
-
- Procedure OpenGroup(var GrpF : GroupFile;
- GroupNum : Integer);
- {─────────────────────────────────────────────────────────────────────
- This Procedure creates a Group List file whose name will follow the
- following conventions: GroupID : 5 letter ID tag 0 - 999 : up to 3 digit
- group number .GRP : extension
- ─────────────────────────────────────────────────────────────────────}
- VAR GrpFName : FileName; S : String[3]; err : Integer;
-
- Begin
- Str(GroupNum, S);
- GrpFName := StUpCase(GroupID + S + '.GRP');
- WriteLn('Opening Group File Name: ', GrpFName);
- Assign(GrpF, GrpFName);
- {$I-}
- Rewrite(GrpF,1);
- {$I+}
- err := IoResult;
- If err > 0
- then ProcessError(err, 'Opening Group file ' + GrpFName);
-
- End; { OpenGroup }
-
-
- Procedure MakeGroups;
- Const
- CAMStr = ''; { blank CAMPhone }
- PollStr = ''; { blank Polling Password }
- MaxCount = 99; { Maximum records per group }
-
- VAR
- Group : GroupFile; { Group handle }
- OneRec : GrpRec; { One Group Record }
- GroupLst : Array[1..99] of GrpRec; { List of Group Members }
- Count : Word; { Count of Members }
- GroupNum : Integer; { number of groups processed }
- i : integer; { For loop counter }
- break : boolean;
-
- Begin
- GroupNum := 0;
- While Not EOF(Ascii) Do Begin
- OpenGroup(Group, GroupNum);
- WriteLn('Reading for ', StUpCase(GroupID), GroupNum);
- Count := 0;
- Break := False;
- FillChar(GroupLst, SizeOf(GroupLst), $0);
- While (Count < MaxCount) and not Break Do Begin
- { reading in the group }
- inc(Count);
- Read(Ascii, OneRec.Name);
- ReadLn(Ascii, OneRec.FAXPhone);
-
- OneRec.CAMPhone := CAMStr;
- OneRec.PollPWD := PollStr;
- GroupLst[Count] := OneRec;
- If EOF(Ascii) then Break := True;
- Write(Count:2, ^M);
- End; { reading in the group }
- WriteLn;
-
- If WriteGrpHdr(Group, Count) { Write the list out to the group file }
- then WriteLn('Writing ', StUpCase(GroupID), GroupNum)
- else ProcessError(1099, 'Writing Group Header');
- For i := 1 to Count do begin
- PutGrpRec(Group, GroupLst[i]);
- Write(i:2, ^M)
- End; {for}
- Close(Group);
- inc(GroupNum);
- WriteLn; WriteLn;
- End; { while not eof }
- End; { MakeGroups }
-
- Begin
- Write('ASCII input file name: ');
- ReadLn(AsciiName);
- Write('Group ID [up to 5 letters]: ');
- ReadLn(GroupID);
- If OpenAscii(AsciiName) then
- MakeGroups;
- Close(Ascii);
- WriteLn;
- WriteLn(' The Conversion program has ended succesfully. ')
- End.
-
-