'SHUTOFFC - shutdown routine - returns to BOSS menu if allowed

external   cpath sch scw $menu progress() remove() jobs[6] arytostr()
external   dpath userid SetPRN_JNR()

public     ptary[1] ptstr

global     i x $jobstr

MAIN
  if $menu ! "boss"
    screen clear box 1 1 sch scw 0 0 no-border
    execute "bossmenu.pop" in-memory
    transfer cpath|"pm_menu.psl" in-memory
  else
    screen clear box 1 1 sch scw 0 0 no-border
    repaint off
    progress(15,10," Deleting all local indices ",0)
    file unload all
'     remove("*.idx")

    redimension ptary[6]
    for i = 1 to 6
      ptary[i] = jobs[i]
    end for
    x = arytostr(6)
    $jobstr = ptstr                      'message "Job string to unload is:"&str($jobstr)

    if $jobstr <> 0
      fopen dpath|userid|".jnr" as 1
      fwrite 1 from $jobstr
      fclose 1
    end if

'     SetPRN_JNR()

'     execute "logout" in-memory
    quit quit
  end if
END MAIN
