'SHUTFRAN - franchise shutdown routine

external   cpath sch scw $menu progress() remove() strcount() dpath vloadif()
external   messboxwait() messbox() chkstr() vunloadif() SetPRN_JNR() jobs[6]
external   arytostr() userid

' external   cpath sch scw $menu messbox() progress() remove() dpath jobs[6]
' external   arytostr() userid SetPRN_JNR()

' public     ptary[1] ptstr $jobstr
'
' global     x i

public $shop ptstr $br ptval ptary[1]

global    x i $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
  elseif $menu ! "offc"
    screen clear box 1 1 sch scw 0 0 no-border
    execute "offcmenu.pop" in-memory
    transfer cpath|"pm_menu.psl" in-memory
  else
    tools os "C:\aw\awlogoff /w"
    messbox(" #!EXIT!# ",0,1,1)
    screen clear box 1 1 sch scw 0 0 no-border
    repaint off
    progress(15,10," Deleting all local indices ",0)
    file unload all

    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

'     execute "logout.rf3" in-memory
    wait 3
    window border
    execute "entappl.rf3" in-memory
  end if
END MAIN

