! Program to log what's happening.
! Modem Job should run this program when system boots up.
!
! Should get the following from AMUS and load them into user memory.
! AMOS.SBR
! AMOSQ.SBR
! DSKPPN.SBR
!
map1 command'string,s,100               ! Incoming command line.
map1 logaccount,s,20,"DSK1:[1,2]"       ! Device and account where log file is.
map1 filename,s,34,"TEST.LOG"           ! Logfile name.
map1 curdev,s,5                         ! Current logged in device.
map1 curact,s,7                         ! Current logged in account.
map1 password, s, 6, "EXTKEP"           ! Password to exit this program.
map1 found,f                            ! Log found flag.
map1 prompt,s,5,".> "                   ! KEPLOG Prompt.
map1 CR$,s,1,chr$(13)
map1 LF$,s,1,chr$(10)

on error goto no'exit

top:
       ? prompt;                       ! Output a prompt.
       input line "",command'string    ! Get command.
       if command'string=password : goto out'of
       call save'command               ! Save what's happening.
       command'string=ucs(command'string)+CR$+LF$

! xcall AMOS if using AMOS's BASIC
!
       xcall AMOS, command'string      ! Do the command.

! Rundos if using d/SOFT's BASIC
!!!     rundos command'string           ! Do the command.

       goto top                        ! And do it again.

out'of:
       ? "Finished"
       end

no'exit:
       ? "^C"
       resume top

! ************
! Save command in log file.
! ************
!
save'command:

! Store current login.
!
       xcall DSKPPN,curdev,curact

! Log to where log file is.
!
       xcall AMOSQ,"LOG "+logaccount
!!!!    rundos "LOG "+logaccount

! Find log file.
!
       lookup filename,found

! Create filename if it is not found.
!
       if found < 1 then open #1,filename,output : close #1

! Open file for output in append mode.
!
       open #1,filename,append
       ? #1,command'string
       close #1

! Log back to account we were in.
!
       xcall AMOSQ,"LOG "+curdev+":["+curact+"]"
!!!!    rundos "LOG "+curdev+":["+curact+"]"

! Return to caller.
!
       return