MESSAGE "Writing setup table procedures to library..."

PROC CLOSED Setup_Table_Wait(Tbl, R, C, F_Num)
  USEVARS Autolib, Main_Table, Rpt_St
  PRIVATE Fld_Prompt
  DYNARRAY Fld_Prompt[]

  PROC Setup_Speedbar()
    SPEEDBAR "~F10~ Menu":-68
    if ISASSIGNED(Fld_Prompt[FIELD()]) then
      PROMPT Fld_Prompt[FIELD()]
      else PROMPT
    endif  
  ENDPROC; 
  
  PROC Setup_Table_Menu()
    SHOWPULLDOWN
      "Modify"    : "Toggle between edit and main mode"               : "Modify"
        SUBMENU
          "Edit Mode - F9" : "Allow data to be edited, deleted, etc." : "Edit\Mode",
          "Main Mode - F2" : "Discontinue editing"                    : "Main\Mode"
        ENDSUBMENU,
      "Reports"          : "Choose report to generate"               : "Reports"
        SUBMENU
          "Print All"    : "Report on all records in this table"   : "R_Standard",
          "Cancel"       : "Do not print any report"               : "R_Cancel"
        ENDSUBMENU,
      "Return"       : "Return to previous menu"     : ""
        SUBMENU
          "No      " : "Continue working with this data"  : "Return\No",
          "Yes - F8" : "Return to main menu"              : "Return\Yes"
        ENDSUBMENU
    ENDMENU    
    if ISEMPTY(Tbl) then
      Edit_Mode()
      else MENUDISABLE "Main\Mode"
    endif
  ENDPROC

  PROC Setup_Table_Wait_Proc(TriggerType, EventInfo, CycleNumber)
    PRIVATE Key_Code, Menu_Pick
    if (TriggerType = "ARRIVEFIELD") then
      Setup_Speedbar()
      RETURN 1
    endif
    if (EventInfo["TYPE"] = "MESSAGE") then
      Menu_Pick = EventInfo["MENUTAG"]
      SWITCH
        CASE (Menu_Pick = "Edit\Mode")  : RETURN Edit_Mode()
        CASE (Menu_Pick = "Main\Mode")  : if ISEMPTY(Tbl) then
                                            RETURN Clear_Table()
                                            else RETURN Main_Mode()
                                          endif  
        CASE (Menu_Pick = "R_Standard") : ECHO OFF
                                          Print_Report(Main_Table, "1", "")
                                          Setup_Table_Menu()
                                          Setup_Speedbar()
                                          RETURN 1
        CASE (Menu_Pick = "R_Cancel") :   RETURN 1
        CASE (Menu_Pick = "Return\Yes") : RETURN Clear_Table()
        CASE (Menu_Pick = "Return\No")  : RETURN 1
        OTHERWISE : SOUND 400 100 RETURN 1
      ENDSWITCH
    endif
    if (EventInfo["TYPE"] = "KEY") then
      Key_Code = EventInfo["KEYCODE"]
      SWITCH
        ; F3 or F4 UPIMAGE, DOWNIMAGE
        CASE (Key_Code = -61) OR
             (Key_Code = -62) : if (NIMAGES() > 1) then
                                  RETURN 0
                                  else RETURN 1
                                endif  
        ; F9 - COEDIT
        CASE (Key_Code = -67) : RETURN Edit_Mode()
        ; F2 - DO_IT!
        CASE (Key_Code = -60) : if (SYSMODE() = "CoEdit") and (Tbl = "Deposits") then
                                  ECHO OFF
                                  MOVETO "Payments"
                                  MOVETO FIELD "Amount"
                                  Balance = IMAGECSUM()
                                  MOVETO "Deposits"
                                  [Total] = Balance
                                  ECHO NORMAL
                                endif
                                if ISEMPTY(Tbl) then
                                  RETURN Clear_Table()
                                  else RETURN Main_Mode()
                                endif  
        ; + to add one day to current date
        CASE (Key_Code = 43) : RETURN Change_Date(43)
        ; - to subtract one day from current date
        CASE (Key_Code = 45) : RETURN Change_Date(45)
        ; DELETE
        CASE (Key_Code = -83) : if (SYSMODE() = "CoEdit") then
                                  RETURN Display_Delete_Box()
                                  else RETURN 1
                                endif    
        ; F8 - CLEAR
        CASE (Key_Code = -66) : RETURN Clear_Table()
        OTHERWISE             : SOUND 400 100 RETURN 1             
      ENDSWITCH
    endif
    SOUND 400 100 RETURN 1
  ENDPROC; 

  ; main body of procedure follows
  SWITCH
    CASE (Tbl = "PlanInfo") : 
      Fld_Prompt["Plan_Name"] = "Full name of plan:"
      Fld_Prompt["Plan_Id"]   = "Unique plan ID code:"
      Fld_Prompt["Plan_Type"] = "Type of plan (DB,DC):"
      Fld_Prompt["Divisible"] = "Means by which this Plan may be divided, if any?"
      Fld_Prompt["Drafted"]   = "Has a QDRO been drafted for this Plan?"
      Fld_Prompt["Memo"]      = "Description of plan particulars:"
    CASE (Tbl = "Inx_Lkup") : 
      Fld_Prompt["Keyword"] = "Unique keyword to index form"
    CASE (Tbl = "RVarLkup") OR (Tbl = "FVarLkup"): 
      Fld_Prompt["Identifier"] = "Name of variable as placed in forms"   
      Fld_Prompt["Query"]      = "Query used to solicit response"
    CASE (Tbl = "Deposits") : 
      Fld_Prompt["Deposit_Date"]  = "Enter date of deposit"
      Fld_Prompt["Total"]         = "Enter total amount of deposit"
      Fld_Prompt["File_No"]       = "File number related to this payment"
      Fld_Prompt["Id"]            = "Id of file owner from rolodex"   
      Fld_Prompt["Regarding"]     = "Description of pertinent matter"
      Fld_Prompt["Amount"]        = "Amount of payment to this account"
      Fld_Prompt["Note"]          = "Additional notation for this payment"
    CASE (Tbl = "FileType") : 
      Fld_Prompt["File_Type"] = "Unique area of law"
    CASE (Tbl = "Employee") : 
      Fld_Prompt["Empl_Num"]       = "Unique employee number"
      Fld_Prompt["Empl_Id"]        = "Employee ID from Rolodex"
      Fld_Prompt["Rate_Per_Hour"]  = "Default billing rate"
    CASE (Tbl = "TrnsType") : 
      Fld_Prompt["T_Type"]   = "Unique code to group transactions"
      Fld_Prompt["T_Type_L"] = "Letter describing transaction group"
      Fld_Prompt["Header"]   = "Header in statement for this group"
      Fld_Prompt["Footer"]   = "Footer in statement for this group"
    CASE (Tbl = "Footers")  : 
      Fld_Prompt["F_Code"] = "Unique code for this footer"
      Fld_Prompt["F_Footer"] = "Text of footer at end of statement"
    CASE (Tbl = "GrupLkup") : 
      Fld_Prompt["Code"]        = "Unique code for this rolodex group"
      Fld_Prompt["Description"] = "Description of this rolodex group"
      Fld_Prompt["Title"]       = "Default title to fill in in rolodex"
    CASE (Tbl = "TrnsLkup") : 
      Fld_Prompt["T_Code"]      = "Unique code for this transaction"
      Fld_Prompt["T_Type"]      = "Accounting group for this transaction"
      Fld_Prompt["T_Type_L"]    = "Letter describing transaction's group"
      Fld_Prompt["Description"] = "Description of transaction in statement"
      Fld_Prompt["Amount"]      = "Default amount for this transaction type"      
    CASE (Tbl = "FileStat") : 
      Fld_Prompt["Status"]      = "Unique status to assign files"
      Fld_Prompt["Definition"]  = "Definition for files of this status"
      Fld_Prompt["Send"]        = "Should these statements be printed normally?"
      Fld_Prompt["Footer_Code"] = "Default statement footer for these files"
    CASE (Tbl = "States")   : 
      Fld_Prompt["Abrev"] = "Two letter state abbreviation"
      Fld_Prompt["St"]    = "Full name of state"
    CASE (Tbl = "Printers") : 
      Fld_Prompt["Number"]       = "Unique number for this printer setup"
      Fld_Prompt["Name"]         = "Name of this printer or setup"
      Fld_Prompt["Page_Break"]   = "Page break method"
      Fld_Prompt["Port"]         = "Direct output to this port"
      Fld_Prompt["Phone_Book"]   = "Setup string for phone book report"
      Fld_Prompt["Rolodex_Info"] = "Setup string for rolodex report"
      Fld_Prompt["Envelope"]     = "Setup string for envelope report"
      Fld_Prompt["File_Cabinet"] = "Setup string for file cabinet report"
      Fld_Prompt["Accounts"]     = "Setup string for account summary reports"
      Fld_Prompt["Statements"]   = "Setup string for all statements"
      Fld_Prompt["Calendar"]     = "Setup string for calendar report"
      Fld_Prompt["Setup_St"]     = "Generic setup string for all reports"
      Fld_Prompt["Reset_St"]     = "Printer Reset string"
      Fld_Prompt["B_Underline"]  = "Begin underlining"
      Fld_Prompt["E_Underline"]  = "Terminate underlining"
      Fld_Prompt["B_Bold"]       = "Begin bold"
      Fld_Prompt["E_Bold"]       = "Terminate bold"
  ENDSWITCH
  ECHO OFF
  VIEW Tbl
  if (Tbl = "Deposits") then
    END
  endif
  Setup_Table_Menu()  
  WINDOW MOVE GETWINDOW() TO -100, -100
  PICKFORM F_Num
  WINDOW HANDLE CURRENT TO Form_Win
  DYNARRAY Win_Atts[]
  Win_Atts["ORIGINROW"] = R
  Win_Atts["ORIGINCOL"] = C
  Win_Atts["CANMOVE"]   = False
  Win_Atts["CANRESIZE"] = False
  Win_Atts["CANCLOSE"]  = False
  WINDOW SETATTRIBUTES Form_Win FROM Win_Atts
  ECHO NORMAL
  Setup_Speedbar()
  WAIT WORKSPACE
    PROC    "Setup_Table_Wait_Proc"
    MESSAGE "MENUSELECT"
    TRIGGER "ARRIVEFIELD"
    KEY   -60,   -66,   -83,   -67,  -61,   -62,    43,   45
         ; DO_IT  Clear  Delete Edit  UpIm   DwnIm   +    -
         ; F2     F8     DEL    F9    F3     F4     Next  Prev day
  ENDWAIT
  CLEARSPEEDBAR
  MESSAGE ""
  PROMPT  ""
ENDPROC
WRITELIB Off_Lib Setup_Table_Wait

RELEASE PROCS ALL