home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 8 Other
/
08-Other.zip
/
last_m.zip
/
LAST_M.CMD
Wrap
OS/2 REXX Batch file
|
1993-08-28
|
3KB
|
131 lines
/* File: LAST_MSG.CMD */
/* Author: Brad Roberts */
/* Revised: 08/17/1993 */
/* GOAL: To display the last message(s) received on this workstation */
/* Setup */
msg_file='C:\IBMLAN\LOGS\MESSAGES.LOG' /* Message file for IBM LAN */
number=1 /* Number of messages desired */
one = 1 /* Value of 1 */
lines_in_file=1 /* Count all lines */
print_flag=0 /* Set to 1 when ready to display msgs */
pause_flag=0 /* Set to 1 to pause between messages */
/* Check for help request */
parse arg option
if option == '?'
then
do
/* Help */
say 'HELP: LAST_MSG [$NUMBER] [PAUSE] [?]'
say 'GOAL: To display the last $NUMBER messages received by this workstation'
say ' from the network, e.g. via NET SENDs.'
say ' '
say 'PARM: $NUMBER indicates the quantity of messages that you want to review.'
say ' By default, this is 1 for the last message received today. However,'
say ' it can be any number up to the total number of messages that have'
say ' been logged by this workstation.'
say ' PAUSE causes the display to pause after every message in the group.'
say ' Use this when you are running from an ICON or when you want to browse.'
say ' ? Redisplays this help screen.'
say ' '
say 'NOTE: This job will display the last message received by this workstation. It'
say ' simply accesses the MESSAGES.LOG file and displays the last entry. Each'
say ' message is separated by four asterisks (i.e ****) in the output. You'
say ' could print the last message by running the following command:'
say ' LAST_MSG >PRN:'
say ' '
exit(1)
end
/* Get value */
parse arg quantity pause
/* Check quantity */
if quantity > 0
then
number = quantity
/* Check pause flag */
if pause \== ''
then
do
pause=translate(space(pause))
if pause == 'PAUSE'
then
pause_flag=1
end
/* Check file */
extant1=stream(msg_file, 'c', 'query exists')
if extant1 == ''
then
do
say '*** File 'msg_file' does not exist! Check it. ***'
exit(1)
end
/* Open the file */
extant2=stream(msg_file, 'c', 'OPEN')
if extant2 \== 'READY:'
then
do
say '*** File 'msg_file' will not open! Check it. ***'
exit(1)
end
/* Read lines in file */
if number <= one
then
say 'Now scanning the network message file for the last message received...'
else
say 'Now scanning the network message file for the last 'number' messages received...'
/* Loop through the message file to determine the number of messages therein */
/* This is redundant, but necessary to identify where to start displaying */
count=1
tally=0
do while lines(msg_file)
lt=linein(msg_file)
if lt == '****'
then
tally = tally + one
end
lines_in_file=tally - one
rc=stream(msg_file, 'c', 'CLOSE')
/* Now display last $NUMBER of lines in file */
count=tally - number
/* Now reopen file */
extant3=stream(msg_file, 'c', 'OPEN')
tally=0
do while lines(msg_file)
lt=linein(msg_file)
if print_flag
then
do
say lt
if lt == '****' & tally >= count & pause_flag == 1
then
'@PAUSE'
end
if lt == '****'
then
do
tally = tally + one
if tally >= count
then
print_flag=1
end
end
rc=stream(msg_file, 'c', 'CLOSE')
/* All done */