'SHUTBOSS - shutdown routine for BOSS menu

external   messbox() sch scw cpath remove() progress() jobs[6] dpath userid
external   arytostr() SetPRN_JNR()

public     ptstr ptary[1]

global     i x $newjobs $jobstr  ReturnToMenu()

MAIN
  messbox(" Are you sure you want to exit? (y/n) ",1,0,1)
  if ptstr == "y"
    screen clear box 1 1 sch scw 0 0 no-border
    repaint off
    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

    progress(15,10," Deleting all local indices ",0)
    file unload all
'     SetPRN_JNR()
    execute "logout" in-memory
    quit quit
  else
      ReturnToMenu()

'     tools os "C:\aw\awlogoff /w"
' '     messbox(" FINISHED ",0,1,1)
'     if $jobstr <> 0
'       fopen dpath|userid|".jnr" as 1
'       fwrite 1 from $jobstr
'       fclose 1
'     end if
'     file unload all
'     SetPRN_JNR()
' '     execute "logout.rf3" in-memory
' '     wait 3
'     window border
'     execute "entappl.rf3" in-memory
  end if
END MAIN


FUNCTION ReturnToMenu()
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  file unload all
  fopen dpath|userid|".jnr" as 1
  fwrite 1 from $jobstr
  fclose 1
  transfer cpath|"pm_menu.psl" in-memory
END FUNCTION ' ReturnToMenu()

