home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.wwiv.com
/
ftp.wwiv.com.zip
/
ftp.wwiv.com
/
pub
/
BBS
/
GWAR241.ZIP
/
MSGFILE.TXT
< prev
next >
Wrap
Text File
|
1990-05-08
|
3KB
|
96 lines
GLOBAL WAR MESSAGE FILE FORMAT (WARxx.MSG)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WARxx.MSG is a FILE OF MsgRec
MsgRec is defined as:
TYPE
MsgRec = RECORD
MsgFrom: 1..6; {player who sent this message}
MsgTo : SET OF 1..6; {player(s) this message was sent to}
MsgTxt : String[70]; {the text of the message}
END;
When a new message is entered, a new record is appended to the WARxx.MSG file.
Records are never deleted. The MsgTo Set keeps track of who the message is
to. If a player number is in the MsgTo set, the message is considered New,
(unread, undeleted, etc). When a player deletes a message, his player number
is removed from the MsgTo set.
Examples:
VAR
f : FILE OF MsgRec;
Rec : MsgRec;
s : STRING;
ch : CHAR;
RecNo: WORD;
BEGIN
Assign(f, 'WAR01.MSG');
{$I-} Reset(f); {$I+}
IF IOResult<>0 THEN ReWrite(f); {create file if it doesn't exist}
To read messages:
Reset(f); RecNo := 0;
WHILE NOT EOF(f) DO BEGIN
Inc(RecNo);
Seek(f, RecNo);
Read(f, Rec);
IF ThisPlayerNumber IN Rec.MsgTo THEN BEGIN
Writeln('This message is from player #',Rec.MsgFrom);
Writeln(Rec.MsgTxt);
Writeln;
END;
To delete messages:
Write('End of messages to you. Delete messages? ');
Read(ch);
IF UpCase(ch)='Y' THEN BEGIN
FOR RecNo:=1 TO FileSize(f)-1 DO BEGIN
Seek(f,RecNo);
Read(f, Rec);
{Now remove player number from MsgTo Set}
Rec.MsgTo := Rec.MsgTo - [ThisPlayerNumber];
Seek(f, RecNo);
Write(f, Rec);
END;
To send a messages:
Write('Send message to which player(s)? (!,",#,$,%,&) : ');
ReadLn(s);
IF Length(s)>0 THEN BEGIN
Rec.MsgTo := [];
FOR i:=1 TO Length(s) DO BEGIN
ch := s[i];
CASE ch OF
'!':Rec.MsgTo := Rec.MsgTo + [1];
'"':Rec.MsgTo := Rec.MsgTo + [2];
'#':Rec.MsgTo := Rec.MsgTo + [3];
'$':Rec.MsgTo := Rec.MsgTo + [4];
'%':Rec.MsgTo := Rec.MsgTo + [5];
'&':Rec.MsgTo := Rec.MsgTo + [6];
END;
END;
IF Rec.MsgTo <> [] THEN BEGIN
Writeln('Enter message now. Press [ENTER] on a blank line to end. ');
REPEAT
Write('Message:');
Readln(s);
IF s<>'' THEN BEGIN
Rec.MsgTxt := s;
Rec.MsgFrom := player;
RecNo := FileSize(f); {append record to end of file}
IF RecNo=0 THEN RecNo := 1;
Seek(f, RecNo);
Write(f, Rec);
END;
UNTIL s='';
Writeln('Message sent. ');
END;
END;
Close(f);