; clear workspace, procedures, variables, etc.
ECHO OFF
RELEASE VARS ALL
RELEASE PROCS ALL
ALTSPACE {Desktop} {Empty}
MOUSE HIDE
SHOWPULLDOWN
ENDMENU
PROMPT ""

PROC Show_Main_Menu()
SHOWPULLDOWN
  "Open"    : "Select area to work in" : "Open"
    SUBMENU
      "Rolodex"           : "Names, addresses and phone numbers of clients, etc."  : "Rolodex",
      "File Cabinet"      : "Client file and billing information"                  : "Files",
      "QDRO Screen"       : "Enter/edit information for drafting QDROs"            : "QDROs",
       SEPARATOR,
      "Plan Information"  : "Summary of Retirement Plan Particulars"               : "PlanInfo",
      "Annuity Evaluator" : "Calculate present value of an annuity"                : "Pensions",
      "Deposit Book"      : "Record bank deposits"                                 : "Deposits"
    ENDSUBMENU,
  "Utilities" : "System utilities" : "Utilities"
    SUBMENU
      "Basic Data" : "Enter and modify basic data"       : ""
        SUBMENU
          "Areas of Law"      : "File relate to a specific area of law (e.g. divorce)"                       : "FileType",
          "Employee Info"     : "Name, number & hourly rates of attorneys/employees"                         : "Employee",
          "Ledger Groupings"  : "Ledger transactions belong to groups (e.g. trust, credit, hourly charge)"   : "TrnsType",
          "Footers in Bills"  : "Text to print at bottom of statements for reminders/information"            : "Footers",
          "Rolodex Groups"    : "Rolodex members belong to groups (e.g. client, opposing counsel, personal)" : "GrupLkup",
          "Transaction Codes" : "Codes & descriptions of ledger transactions (e.g. PMT for payment)"         : "TrnsLkup",
          "Status of Files"   : "Designate files as open, closed, contingent, bankrupt, etc."                : "FileStat",
          "States"            : "Abbreviations & names of states"                                            : "States"
        ENDSUBMENU,
      "Tally Accounts" : "Total ledger entries for all files"   : "Tally_All"
    ENDSUBMENU,
  "System"       : "Customize program for your office" : ""
    SUBMENU
      "Customize"    : "Customize program for your office, letterhead, etc." : "Customize",
      "Printers"     : "Set up printers to use with application"             : "" 
         SUBMENU
           "Settings" : "Add, delete or change printer settings" : "Printers",
           "Default"  : "Select printer to use for output"       : "Printer_Default" 
         ENDSUBMENU
    ENDSUBMENU,
  "Exit"      : "Terminate application"             : "Exit"
    SUBMENU
      "No  " : "Do not exit - return to application"  : "Exit\No",
      "Yes " : "Exit application and return to DOS"   : "Exit\Yes"
    ENDSUBMENU
  ENDMENU    
ENDPROC; Show_Main_Menu

PROC CLOSED Main_Menu()
  USEVARS Form_Dir, Main_Dir, Off_Lib, Autolib, Ltr_Hd, Appl_Title, Default_Printer
  ; disable some paradox keys
  KEYDISABLE "DOS", "DOSBIG", "MINIEDIT", "ORDERTABLE", "WINNEXT"
  ; define report strings and read from disk
  DYNARRAY Rpt_St[]
  Rpt_St["Port"]         = ""
  Rpt_St["Page_Break"]   = ""
  Rpt_St["Setup_St"]     = ""
  Rpt_St["Reset_St"]     = ""
  Rpt_St["Phone_Book"]   = ""
  Rpt_St["Rolodex_Info"] = ""
  Rpt_St["Envelope"]     = ""
  Rpt_St["File_Cabinet"] = ""
  Rpt_St["Accounts"]     = ""
  Rpt_St["Statements"]   = ""
  Rpt_St["Calendar"]     = ""
  Rpt_St["B_Underline"]  = ""
  Rpt_St["E_Underline"]  = ""
  Rpt_St["B_Bold"]       = ""
  Rpt_St["E_Bold"]       = ""
  if NOT ISBLANK(Default_Printer) then
    Setup_Printer(Default_Printer)
  endif
  Answer_Table = ""
  WHILE TRUE
    Show_Main_Menu()
    GETMENUSELECTION TO Choice
    Main_Table = Choice
    SWITCH
      CASE (Choice = "Rolodex")        : Rolodex_Wait("Rolodex")
      CASE (Choice = "Files")          : File_Cabinet_Wait("Files", "Ledger")
      CASE (Choice = "Pensions")       : ECHO OFF
                                         SETDIR "PENSIONS"
                                         Pension_Table_Wait()      
                                         ECHO OFF
                                         SETDIR Main_Dir
      CASE (Choice = "QDROs")          : Qdro_Table_Wait()      
      CASE (Choice = "Deposits")       : Setup_Table_Wait(Choice, 2, 1, "1")
      CASE (Choice = "PlanInfo")       : Setup_Table_Wait(Choice, 1, 0, "1")
      CASE (Choice = "Employee")       : Setup_Table_Wait(Choice, 4, 14, "1")
      CASE (Choice = "TrnsType")       : Setup_Table_Wait(Choice, 6, 1, "1")
      CASE (Choice = "Footers")        : Setup_Table_Wait(Choice, 2, 0, "1")
      CASE (Choice = "GrupLkup")       : Setup_Table_Wait(Choice, 3, 1, "1")
      CASE (Choice = "TrnsLkup")       : Setup_Table_Wait(Choice, 2, 2, "1")
      CASE (Choice = "FileStat")       : Setup_Table_Wait(Choice, 4, 2, "1")
      CASE (Choice = "FileType")       : Setup_Table_Wait(Choice, 4, 23, "1")
      CASE (Choice = "States")         : Setup_Table_Wait(Choice, 3, 18, "1")
      CASE (Choice = "Printers")       : Setup_Table_Wait(Choice, 1, 2, "1")
                                         ; reset default printer values
                                         if NOT Setup_Printer(Default_Printer) then
                                           Select_Printer()
                                         endif
      CASE (Choice = "Printer_Default"): Select_Printer()
      CASE (Choice = "Customize")      : Customize_Setup()
      CASE (Choice = "Tally_All")      : Tally_All("Files", "Ledger")
      CASE (Choice = "Exit\Yes")       : QUITLOOP
    ENDSWITCH
  ENDWHILE
  CLEARPULLDOWN
ENDPROC; Main_Menu

; =========== MAIN SCRIPT BEGINS HERE =======
; define subdirectory and library file where application is located
  Form_Dir = "R:\\DOCUMENT\\WPDOCS\\FORMS\\"
  Main_Dir = "R:\\PDOXDATA\\OFFICE\\"    ; location of data files
  Off_Lib  = "OFFICE"                    ; name of procedure library
  if ISFILE(Off_Lib + ".LIB") then       ; look for procedure library
    Autolib = SDIR() + Off_Lib           ; autoload library
    else Quit "Cannot locate library, please recreate."
  endif
  SETDIR Main_Dir
; define letterhead array/application title and read from disk
  ARRAY Ltr_Hd[10]
; assign default printer & read in system variables
  Default_Printer = Get_Custom_Setup_Variables()
; show splash screen
  ECHO NORMAL ; display empty desktop
  DYNARRAY Att[]
  Att["HASFRAME"]  = False
  Att["CANMOVE"]   = False
  Att["CANRESIZE"] = False
  Att["Style"]     = 116
  WINDOW CREATE ATTRIBUTES Att HEIGHT 13 WIDTH 52 @6,14 TO Splash_Screen
  PAINTCANVAS BORDER ATTRIBUTE 16 0, 0, 12, 51
  @5,1 ?? FORMAT("W50,AC", Appl_Title)
  @7,1 ?? FORMAT("W50,AC","CLIENT AND BILLING DATABASE")
  SLEEP 1000
  FOR I FROM 6 TO 23
    SLEEP 10
    WINDOW MOVE Splash_Screen TO I,14
  ENDFOR
  WINDOW CLOSE
; execute top level procedure
  Main_Menu()
  ECHO OFF
  SETDIR SDIR()
; clean up before exiting
  RESET
  RELEASE PROCS ALL
  RELEASE VARS ALL
