home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Jason Aller Floppy Collection
/
199.img
/
HYPE4.ZIP
/
CHKMAIL.HP
< prev
next >
Wrap
Text File
|
1990-05-08
|
7KB
|
247 lines
; chkmail.hp
;
; This module uses <NAME> which is passed to it from the HA5 host, as an
; index to the file USERS. USERS contains the callers name and the last
; message number (LAST-MSG) that <NAME> has read. The file USERS has the
; format of:
;
; John Doe~#10
;
; The tilde simply seperates <NAME> from the LAST-MSG.
;
; If <NAME> is not found in the USERS file, it is added to that file, and
; given a LAST-MSG value of 0.
;
; Once the LAST-MSG has been determined, this number is used as an index
; into the file named MSGIDX. This is the message index file. This file is
; used to determine if there are any new messages (messages numbers greater
; than LAST-MSG) for <NAME>. The file MSGIDX has the format of:
;
; #1 TO:users name FROM:senders name SUBJECT:subject DATE:date PUB:y-or-n
;
; The messages are of three types, designating a priority of importance to
; the caller.
;
; Type 1: Private messages sent directly to the callers name
;
; Type 2: Messages left by others as a "To All" message
;
; Type 3: Messages left by others, for others, but are public
;
; Note that while all three types of messages are located, this
; module will only notify the caller of messages sent to their
; name (Message Type 1). The others (type 2 and 3) are maintained
; for subsequent read commands that may be issued at a later time.
;
; Get the directory for email files from the environment varialbe HA5_EMAIL
; if it exists, otherwise use the same location as the file HA5.CFG.
;
set flag(F(9),false)
ifnot get environment(S(0),"HA5_TRACE") set flag(F(9),false)
if string match(S(0),"true") set flag(F(9),true)
if flag(F(9)) print("Chkmail has been entered")
label(10)
if flag(F(9)) print("label(10)")
set flag(F(1),false)
if get environment(S(0),"HA5BBS") set flag(F(1),true)
ifnot get environment(S(0),"HA5_EMAIL") branch(15)
set string(S(0),"/S(0)")
branch(20)
label(15)
if flag(F(9)) print("label(15)")
full filename(S(0),"HA5.CFG")
truncate(S(0),"\HA5.CFG")
label(20)
if flag(F(9)) print("label(20)")
put environment("HA5_EMAIL","/S(0)")
get environment(S(6),"HA5_EMAIL")
label(25)
if flag(F(9)) print("label(25)")
option("ignore case",yes)
option("blank",yes)
key string(S(0),"")
option("blank",no)
uppercase(S(0),"/S(0)")
put environment("NAME","/S(0)")
put environment("MSGS","")
put envoronment("LAST_MSG_NO","")
; Read record 1 of MSGIDX to get the next message record number.
; Put this number into the environment variable NEXT_MSG_NO. This
; variable will be used by sendmail.hp when a new message is generated.
;
; If MSGIDX file does not exist, put #1 into NEXT_MSG_NO environment
; variable.
;
ifnot read from("/S(6)\msgidx",no) branch(600)
label(30)
if flag(F(9)) print("label(30)")
ifnot read string(S(1),"NEXT_MSG_NO:") branch(600)
cut(S(1),"NEXT_MSG_NO:")
get integer(I(1),"/S(1)")
put environment("NEXT_MSG_NO","#/I(1)")
read from("")
;Read <NAME> from USERS and get LAST-MSG read, or ADD <NAME> to USERS
;if <NAME> is new. S(0) is <NAME>.
;
label(40)
if flag(F(9)) print("label(40)")
ifnot read from("/S(6)\USERS",no) branch(55)
ifnot read string(S(4),"/S(0)") branch(50)
cut(S(4),"~")
read from("")
branch(90)
label(50)
if flag(F(9)) print("label(50)")
read from("")
label(55)
if flag(F(9)) print("label(55)")
write to("/S(6)\USERS")
write("/S(0)~#0")
write to("")
set string(S(4),"#0")
label(90)
if flag(F(9)) print("label(90)")
put environment("LAST_MSG_NO","/S(4)")
set string(S(7),"")
set string(S(8),"")
set string(S(9),"")
set integer(I(7),0)
set integer(I(8),0)
set integer(I(9),0)
type("/rChecking your mail...",0)
; Use LAST-MSG read # to find unread personal mail
;
;Label(100)
if flag(F(9)) print("label(100)")
get integer(I(1),"/S(4)")
add(I(1),1)
ifnot read from("/S(6)\msgidx",no) branch(150)
ifnot read string(S(2),"") branch(150)
; There are messages greater than LAST-MSG, are there any for this caller?
;
label(110)
if flag(F(9)) print("label(110)")
type(".",0)
branch subroutine(500)
if read string(S(2),"") branch(110)
read from("")
if equal(I(7),1) type("/r/rThere is 1 piece of mail for you today./r/r",0)
if greater(I(7),1) type("/r/rThere are /I(7) pieces of mail for you today./r/r",0)
set string(S(9),"/S(7)/S(8)/S(9)")
put environment("MSGS", "/S(9)")
ifnot greater(I(7),0) branch(150)
branch(160)
; There are no message numbers greater than S(1).
;
label(150)
if flag(F(9)) print("label(150)")
ifnot truncate(S(0)," ") branch(155)
label(155)
if flag(F(9)) print("label(155)")
type("/r/rSorry /S(0), there is no new mail for you today./r/r",0)
label(160)
if flag(F(9)) print("label(160)")
if flag(F(1)) fetch character(S(0),"Press any key to continue...")
end()
;***************************************************************************
;Subroutine to find correct mail from msgidx file, called from label(110)
;
; Expects: S(2) contains the record from MSGIDX
;
; Uses: S(7) contains numbers matching <users name>
; S(8) contains numbers matching <*>
; S(9) contains numbers matching <public>
;
;***************************************************************************
label(500)
if flag(F(9)) print("label(500)")
get integer(I(2),"/S(2)")
if less(I(2),I(1)) return()
if string match(S(2),"TO:/S(0)") branch(505)
if string match(S(2),"TO:*") branch(510)
if string match(S(2),"PUB:Y") branch(515)
label(501)
if flag(F(9)) print("label(501)")
return()
label(505)
if flag(F(9)) print("label(505)")
truncate(S(2)," TO:")
set string(S(7),"/S(7)/S(2):")
add(I(7),1)
branch(501)
label(510)
if flag(F(9)) print("label(510)")
truncate(S(2)," TO:")
set string(S(8),"/S(8)/S(2):")
add(I(8),1)
branch(501)
label(515)
if flag(F(9)) print("label(515)")
if string match(S(2),"FROM:/S(0)") branch(501)
truncate(S(2)," TO:")
set string(S(9),"/S(9)/S(2):")
add(I(9),1)
branch(501)
; MSGIDX does exist. Put #1 into NEXT_MSG_NO in both MSGIDX header and
; the environment variable.
;
label(600)
if flag(F(9)) print("label(600)")
read from("")
wrtie to("/S(6)\msgidx")
write("NEXT_MSG_NO:#1")
write to("")
put environment("NEXT_MSG_NO","#1")
put environment("LAST_MSG_NO","#0")
branch(40)
label(900)
if flag(F(9)) print("label(900)")
set string(S(9), "Could not open file:USERS")
branch(990)
label(905)
if flag(F(9)) print("label(905)")
set string(S(9), "Could not close file:USERS")
branch(990)
label(910)
if flag(F(9)) print("label(910)")
set string(S(9), "Could not open file:MSGIDX")
branch(990)
label(980)
if flag(F(9)) print("label(980)")
set string(S(9), "Error not trapped")
label(990)
if flag(F(9)) print("label(990)")
ifnot write to("answer.log") branch(995)
ifnot write("ERROR:/S(9)/n") branch(995)
ifnot write to("") branch(995)
label(995)
if flag(F(9)) print("label(995)")
end()