program backgd,1.0(10)          ! submits jobs to run in the background

!       John Baima
!       Eisenbrauns (NONA/AM)
!       PO Box, 275
!       Winona Lake, IN 46590
!       11/9/85


!       Submits a Job to run in the background and sends a message to the
!       terminal when the job is finnished.
!       Our background job name is NOONE. This could be changed to match your name

!       Uses the "xppn" .SBR    (Which is on the AMUS BB)


map1 ppn
       map2 project,B,2
       map2 programmer,B,2
map1 device,S,6
map1 jobnam,S,6
map1 trmnam,S,6

map1 misc
       map2 command,s,120
       map2 current'log,s,20

xcall xppn,ppn,device,jobnam,trmnam

current'log = device + project + "," + programmer

open #1, "back.cmd", output
print #1, "submit back"
close #1

open #2, "back.ctl", output

jobnam = lcs(jobnam)
jobnam[1,1] = ucs(jobnam[1,1])

print tab(-1,0);"Background Job Utility";tab(1,65);"Welcome ";jobnam;"!"
print
print
print "If the job needs to be logged in a particular account, do not forget"
print "        the login! The default login is ";current'log
print
print "The screen output for the background job will be saved in the file"
print "       ";device;"BACK.LOG[";project;",";programmer;"]."
print
print "The background job [Noone] will send your terminal a message when it"
print "        is finished"
print
print "The background job does not have any subroutines loaded. Therefore, e.g."
print "use 'LOE' rather than 'OE' to load the subroutines, if they are needed."
print "Type 'END' to back out of a program in which you would normally use the"
print "left arrow."
print
print "Enter the commands to be executed in the background with the final"
print "command 'LOGOFF'"
print
print "The first command is 'log ";current'log;"'"
print

print #2, "log ";current'log

top:
       input line "Enter the next command > ", command
       if ucs(command) = "LOGOFF" then goto finish'command'file
       print #2, command
       print
       goto top

finish'command'file:

       print #2, "send ";jobnam;" The background job is finished!"
       print #2, "logoff"

       close #2

       chain "back.cmd"