MESSAGE "Writing QDRO procedures to library..."
;	Off_Lib = "OFFICE"

PROC QDRO_Output()
  PRIVATE Temp_Array
  ECHO OFF
  COPYTOARRAY Temp_Array
  ;
  ; Added check for user and alternatives to "Q_Output"
  ;
  User = SUBSTR(USERNAME(), 1, 5)

  User = "JESSE"
  if (User = "JESSE") then
  	Subset_Table = "Q_Output"
  	
  else
  	Subset_Table = "Q_" + SUBSTR(USERNAME(), 1, 3) + "001"
  endif
  if ISTABLE(Subset_Table) then
  	DELETE Subset_Table
  endif  
  CREATE Subset_Table LIKE "Qdros"
  VIEW Subset_Table
  COEDITKEY
  COPYFROMARRAY Temp_Array
  [File_No] = [Qdros->File_No] + [Qdros->Version]
  DO_IT!
  FORMKEY
  Select_Forms()
  DELETE Subset_Table
  MOVETO Main_Table
  FORMKEY
ENDPROC;
WRITELIB Off_Lib QDRO_Output


PROC QDRO_Wait_Proc(TriggerType, EventInfo, CycleNumber)
  PRIVATE Key_Code, Menu_Pick
  if (EventInfo["TYPE"] = "KEY") then  
    Key_Code = EventInfo["KEYCODE"]
    SWITCH
      ; F9 - COEDIT
      CASE (Key_Code = -67) : RETURN Main_Table_Edit()
      ; F2 - DO_IT!
      CASE (Key_Code = -60) : if ISEMPTY(Main_Table) then
                                RETURN Main_Table_Clear()
                                else RETURN Main_Table_End_Edit()
                              endif    
      ; F8 - CLEAR
      CASE (Key_Code = -66) : RETURN Main_Table_Clear()
      ; DELETE
      CASE (Key_Code = -83) : if (SYSMODE() = "CoEdit") then
                                RETURN Display_Delete_Box()
                                else RETURN 1
                              endif
      ; + or - to change date by day
      CASE (Key_Code = 43) OR 
           (Key_Code = 45)   : RETURN Change_Date(Key_Code)
      OTHERWISE              : SOUND 400 100 RETURN 1             
    ENDSWITCH
  endif
  if (EventInfo["MESSAGE"] = "MENUSELECT") then 
    Menu_Pick = EventInfo["MENUTAG"]
    SWITCH
      CASE (Menu_Pick = "Edit\Mode")  : RETURN Main_Table_Edit()
      CASE (Menu_Pick = "Main\Mode")  : if ISEMPTY(Main_Table) then
                                          RETURN Main_Table_Clear()
                                          else RETURN Main_Table_End_Edit()
                                        endif    
      CASE (Menu_Pick = "Ask")        : QDRO_Output()
                                        RETURN 1
      CASE (Menu_Pick = "Close\Yes")  : RETURN Main_Table_Clear()
      CASE (Menu_Pick = "Close\No")   : RETURN 1
      OTHERWISE                       : SOUND 400 100 RETURN 1
    ENDSWITCH
  endif
  SOUND 400 100 RETURN 1  ; safety valve
ENDPROC
WRITELIB Off_Lib QDRO_Wait_Proc

PROC QDRO_Table_Wait()
  Main_Table = "Qdros"
  ECHO OFF
  Main_Table_View(Main_Table, 1, 0); place table on workspace in form view
  END; move to last record in table
  Main_Table_Edit()
  ECHO NORMAL
  WAIT WORKSPACE
    PROC    "QDRO_Wait_Proc"
    MESSAGE "MENUSELECT"              
;    TRIGGER "ARRIVEFIELD"
    KEY   -60,   -66,   -67,  -83,   43,   45
         ; DO_IT  Clear  Edit  Delete +    -
         ; F2     F8     F9    DEL    
  ENDWAIT
  ECHO OFF
  CLEARALL
  PROMPT ""
  MESSAGE ""
ENDPROC;
WRITELIB Off_Lib QDRO_Table_Wait

RELEASE PROCS ALL
