$! +JMJ
$!
$! grffti.com - Graffiti wall access
$!
$! Copyright 2017 David Meyer <
[email protected]>
$!
$! Copying and distribution of this file, with or without
$! modification, are permitted in any medium without royalty
$! provided the copyright notice and this notice are preserved.
$! This file is offered as-is, without any warranty.
$! (GNU All-Permissive License)
$!
$! (taken from the LCM's VAX system)
$ delim = " "
$ grffti_f = "sys$sysdevice:[user.papa.share.grffti]grffti.dat"
$ grfftibm_f = f$trnlnm("sys$login")+"GRFFTI.BM"
$ listitle = "*** LCM+L VAX780 Graffiti Wall ***"
$!
$ cmd_l = "/ALL/NEW/HELP/WRITE/"
$ if p1 .eqs. ""
$ then cmd = "WRITE"
$ else cmd = p1
$ endif
$ if f$locate ("/"+cmd+"/", cmd_l) .eq. f$length (cmd_l)
$ then gosub CMD_NG
$ else gosub 'cmd'
$ endif
$ exit
$!
$! Subroutine ALL - List all records from Graffiti Wall file
$ALL:
$ open/read infile 'grffti_f'
$ write sys$output listitle
$ since = 0
$A_DO: ! while data in graffiti file
$ read/end_of_file=A_DONE infile record
$ if since .eq. 0
$ then
$ sincedt = f$extract(0, 22, record)
$ write sys$output "Since: "+sincedt
$ write sys$output " "
$ since = 1
$ endif
$ grffto = f$extract(23, f$length(record), record)
$ write sys$output grffto
$ goto A_DO
$A_DONE:
$ close infile
$ return
$!
$! Subroutine CMD_NG - Error for invalid GRFFTI subcommand
$CMD_NG:
$ write sys$error "GRFFTI: invalid command: "+p1
$ write sys$error "GRFFTI: Syntax: GRFFTI ALL|HELP|NEW|[WRITE]"
$ return
$!
$! Subroutine HELP - Print GRFFTI help text
$help:
$ type sys$input
$ DECK
GRFFTI
The GRFFTI command procedure provides access to the LCM+L VAX780
Graffii Wall for communication, socialization, and entertainment.
o Print all contents from the Graffiti Wall (GRFFTI ALL)
o Print new content from the Graffiti Wall (GRFFTI NEW)
o Post new graffito on the Graffiti Wall (GRFFTI [WRITE])
(Wait for GRFFTI> prompt.)
o Print this help text (GRFFTI HELP)
SET-UP
To use the GRFFTI command procedure, and check for new graffito at each
log-in, users should add the following lines to their LOGIN.COM file:
$ grffti :== @sys$sysdevice:[user.papa.share.grffti]grffti
$ grffti new
$ EOD
$ return
$!
$! Subroutine NEW - List Graffiti Wall records written on or after user's
$! bookmark timestamp
$NEW:
$ if f$search("''grfftibm_f'") .eqs. ""
$ then
$ type sys$input
You do not have a Graffiti bookmark file (GRFFTI.BM), which is required to
use the GRFFTI NEW subcommand.
$ yes_l = "/YES/Y//"
$ no_l = "/NO/N/"
$B_DO: ! until valid Y/N input
$ inquire createbm "OK to create ''grfftibm_f'? ([Y]/N)"
$ if f$locate("/"+createbm+"/", no_l) .lt. f$length(no_l) then return
$ if f$locate("/"+createbm+"/", yes_l) .lt. f$length(yes_l)
$ then goto B_DONE
$ else goto B_DO
$ endif
$B_DONE:
$ gosub ALL
$ else
$ open/read bmfile 'grfftibm_f'
$ read bmfile bookmark
$ close bmfile
$ open/read infile 'grffti_f'
$ write sys$output listitle
$ write sys$output "Since: "+bookmark
$ write sys$output " "
$C_DO: ! while data in graffiti file
$ read/end_of_file=C_DONE infile record
$ timestamp = f$extract(0, 22, record)
$ if timestamp .ges. bookmark
$ then
$ grffto = f$extract(23, f$length(record), record)
$ write sys$output grffto
$ endif
$ goto C_DO
$C_DONE:
$ close infile
$ endif
$ gosub SET_BM
$ return
$!
$! Subroutine SET_BM - Create/overwrite user Graffiti bookmark with
$! current timestamp
$SET_BM:
$ time = f$time()
$ newbm = f$cvtime(time)
$ open/write bmfile 'grfftibm_f'
$ write bmfile ''newbm''
$ close bmfile
$ return
$!
$! Subroutine WRITE - Read user graffito and append to Graffiti file
$WRITE:
$ time = f$time()
$ cvtime = f$cvtime(time)
$ read sys$command /prompt="GRFFTI>" grffto
$ open/append outfile 'grffti_f'
$ write outfile ''cvtime+delim+grffto''
$ close outfile
$ return