   Dim FileName$/"1234567890123456"/,JobControlSysInterlock$(16),Temp$(16)
   Dim JobName$(16),JobCapability$(16)/"0123456789abcdef"/

   Dim ICCreateInterlock$/:1b,14,0,0/
   Dim ICTestInterlock$/:1b,14,0,5/
   Dim ICReleaseInterlock$/:1b,14,0,4/

   Dim JCTestDone$/:1f,14,0,1/,JCDestroy$/:1f,14,0,2/
   Dim JCCreate$/:1f,30,0,0,...
&                 0,0,0,0,0,0,0,0,0,0,...
&                 0,0,0,0,0,0,0,0,0,0,...
&                 0,0,0,0,0,0,0,0/

   Print "Job Control, V1.0a"
   Print "Copyright (C) 1984 Software Dynamics, Inc."
   If Error When Open #1,"JOBCONTROL.SYS"
   Then
       Print "No JOBCONTROL.SYS file exists."
       Input "Create it ? " Temp$
       If Find(UpperCase$(Temp$),"Y")=1
       Then
           Create #1,"JOBCONTROL.SYS"
           Syscall ICCreateInterlock$,JobCapability$,Temp$
           Write #1,Temp$
           Restore #1,0
       Else
           Error 104
       Fi
   Fi
   Read #1,JobControlSysInterlock$
   ! for i=1 to 16 do print hex$(JobControlSysInterlock$[i])[4,2];
   print
GrabIt:
   If Error When
         Syscall ICTestInterlock$,JobControlSysInterlock$
   Then
       Print "JobControl.Sys busy now..."
       Goto GrabIt
   Fi
   ! Now, I own the the interlock file
   If Error When Call DoJobFunctions
   Then
        ! Print "releasing interlock"
        Syscall ICReleaseInterlock$,JobControlSysInterlock$
   Fi
   If Err=1 Then Exit Else Error

Subroutine DoJobFunctions
   Repeat
       Input "0) Exit 1) List Jobs 2) Create Job 3) Abort Job " i
       if i<0 or i>3
       then Print "?? Illegal Job control function."
       else on i+1 gosub jobexit,joblist,jobcreate,jobabort
   End

JobExit: Error 1

JobCreate:
       Input "Name of Job File: " Temp$
       FileName$[1,16]=lowercase$(Temp$)
       JobSlot=16
       Restore #1,16
JobCreateFindOldJobBySameName:...
&      Repeat
             Read #1,JobName$,JobCapability$
             If EOF(1) Then Exit JobCreateFindOldJobBySameName
             If JobName$=FileName$
             Then
                 If Error When Syscall JCTestDone$,JobCapability$
                 Then
                     ! Dead job, say nada
                     Exit JobCreateFindOldJobBySameName
                 Else
                     Print "That job is busy now."
                     Return
                 Fi
             Fi
             JobSlot=JobSlot+32
       End
       JCCreate$[15,16]=Temp$ cat ".log"
       Syscall JCCreate$,FileName$,JobCapability$
       Write #1@JobSlot,FileName$,JobCapability$
       Return

JobAbort:
       Input "Name of Job to abort: " Temp$
       FileName$[1,16]=lowercase$(Temp$)
       Restore #1,16
       Repeat
             Read #1,JobName$,JobCapability$
             If Eof(1)
             Then
                 Print "?? No such job."
                 Return
             Fi
             If JobName$=FileName$
             Then
                 If Error When Syscall JCTestDone$,JobCapability$
                 Then
                     Print "Job already stopped."
                 Else
                     Syscall JCDestroy$,JobCapability$
                     Print "...aborted..."
                 Fi
                 Return
             Fi
       End

JobList:
       Print "JOB Status at ";Time$
       Restore #1,16
       Repeat
             Read #1,JobName$,JobCapability$
             If EOF(1) Then Return
             Print JobName$;
             If Error When Syscall JCTestDone$,JobCapability$
             Then Print "...completed"
             Else Print "...running"
       End

End

END
