          SUBROUTINE (XDATA,V.ONLY)
** Version# 6.0001[6] - 05/15/2010 - 04:03pm - SMITJR - eclipse
*** V6.0001 Change - Custom Coding CUSTOM - 05/15/2010 - SMITJR - eclipse
*** Subroutine: PRD.XREF.DATA
*-------------------------------------------------------------------------*
*** This subroutine is used to set up external reference data.
*-------------------------------------------------------------------------*
*** XDATA    - Actual xref data                                    (IN/OUT)
*** V.ONLY   - The View only flag                                  (IN)
*-------------------------------------------------------------------------*
*** COMMON: NONE
*-------------------------------------------------------------------------*

          OPEN 'DDE.AGENTS' TO DDEFILE ELSE PRINT BELL:; RETURN
          READ DFLT.SUBR.ID FROM CTRLFILE,'DFLT.PRD.XREF.SUBR' ELSE
             DFLT.SUBR.ID = ''
          END
          VIEW.ONLY = V.ONLY

          SCREEN
          VSCROLL.DEFINE 1,1,2,78,5,'PRD.XREF.MAINT'
          VSCROLL.SET 1

          GOSUB LOAD.MENUS

          SV.XDATA = XDATA
          GOSUB DISPLAY

          IF VIEW.ONLY THEN
             PRINT @(2,0):BLINK$:'View Only':NORM$
          END

          LINE=1; COL=1; LASTKEY=0; MOVE=0; QUIT=0
*-------------------------------------------------------------------------*
MOVENEXT: IF QUIT THEN GOTO FILEIT
          NEWOK = (XDATA<1,1,LINE>#'') OR (XDATA<1,3,LINE> # '')
          PARSEMOVE COL,LINE,3,ICT,5,YES,NEWOK

          IF VIEW.ONLY THEN
IN$$1:       INPV X,0,LINE,0
             GOTO MOVENEXT
          END

          ON COL GOTO IN.CID,IN.NAME,IN.CERT
*-------------------------------------------------------------------------*
*** Input for the agent ID.
IN.CID:   INPV XDATA<1,1,LINE>,0,LINE,5,V_'DDE.AGENTS'
          IF XDATA<1,2,LINE>='' THEN
             READV DESC FROM DDEFILE,XDATA<1,1,LINE>,1 ELSE DESC = ''
             XDATA<1,2,LINE> = DESC
             VPRINT 8,LINE,XDATA<1,2,LINE> "L#23"
          END
          GOTO MOVENEXT
*-------------------------------------------------------------------------*
*** Input for the description
IN.NAME:  INPV XDATA<1,2,LINE>,6,LINE,23
          GOTO MOVENEXT
*-------------------------------------------------------------------------*
*** Input for the Parameter Data. This field uses the Expand hotkey..
IN.CERT:  MENU.LOAD 9,8,6,1,'E'
          *** If there is more info than the screen can display, disable
          *** input for this line.
          IF LEN(XDATA<1,3,LINE>) > 46 THEN
             PRINT @(10,8):BLINK$:'xpand':NORM$
IN$$4:       INPV A,32,LINE,0
          END ELSE
             PRINT @(10,8):'xpand'
IN$$5:       INPV XDATA<1,3,LINE>,32,LINE,46
          END

          *** Reload menu's here so there is no expand hotkey if you're
          *** not on the parameter data field.
          GOSUB LOAD.MENUS

          GOTO MOVENEXT
*-------------------------------------------------------------------------*
LOAD.MENUS: *** Loads the Curent hotkeys
          MENU.CLEAR
          MENU.LOAD ,,,,INSERT.KEY
          MENU.LOAD ,,,,DELETE.KEY
          MENU.LOAD 2,8,4,1,'T'

          RETURN
*-------------------------------------------------------------------------*
DISPLAY:  *** Displays the screen...
          ICT = DCOUNT(XDATA<1,1>,SVM)
          IF NOT(ICT) THEN
             ICT = DCOUNT(XDATA<1,3>,SVM)
          END
          FOR LINE = 1 TO ICT
             GOSUB DISP.LN
          NEXT LINE

          RETURN
*-------------------------------------------------------------------------*
DISP.LN:  *** Displays one single line of the vscroll region.
          VPRINT  0,LINE,XDATA<1,1,LINE>                  "L#6"
          VPRINT  9,LINE,XDATA<1,2,LINE>                  "L#23"
          *** If the data is longer than the diplay length, print asterix
          *** to show that.
          IF LEN(XDATA<1,3,LINE>) > 46 THEN
             VPRINT 32,LINE,XDATA<1,3,LINE>[1,45]:BLINK$:'*':NORM$
          END ELSE
             VPRINT 32,LINE,XDATA<1,3,LINE> 'L#46'
          END

          RETURN
*-------------------------------------------------------------------------*
SUBS:     ON OPTION GOTO INS.LN, DEL.LN, TESTIT, EXPAND
*-------------------------------------------------------------------------*
INS.LN:   VINS LINE
          XDATA = INSERT(XDATA,1,1,LINE;'')
          XDATA = INSERT(XDATA,1,2,LINE;'')
          XDATA = INSERT(XDATA,1,3,LINE;'')
          RETURN
*-------------------------------------------------------------------------*
DEL.LN:   VDEL LINE
          XDATA = DELETE(XDATA,1,1,LINE)
          XDATA = DELETE(XDATA,1,2,LINE)
          XDATA = DELETE(XDATA,1,3,LINE)
          RETURN
*-------------------------------------------------------------------------*
TESTIT:   DDE.AGENT = XDATA<1,1,LINE>
          DDE.DATA  = XDATA<1,3,LINE>
          IF TRIM(DDE.AGENT) = '' THEN
             IF DFLT.SUBR.ID = '' THEN
                MSG = 'No Default Prd Xref Subroutine Defined.'
                MSG<-1> = 'Cannot continue.  <Return> '
                RESP = ''
IN$$3:          INP.PROMPT RESP,MSG,,0
                RETURN
             END
          END
          DDE.EXECUTE DDE.AGENT,DDE.DATA,RESULTS
          IF RESULTS THEN
             PRINT BELL:
IN$$2:       INP.PROMPT RESULTS,,,LEN(RESULTS)
          END
          RETURN
*-------------------------------------------------------------------------*
EXPAND:   *** This subroutine enables the user to enter values longer than
          *** the screen width for the parameter data. All lines in the
          *** input window are concatenated to form one data line.
          TMPDATA = XDATA<1,3,LINE>
          TMPDATA = CONVERT(AM,VM,FOLD(TMPDATA,65))
IN$$6:    INPWP.WINDOW TMPDATA,6,2,65,3,10,,"Parameter Data",,VIEW.ONLY
          XDATA<1,3,LINE> = CONVERT(VM,'',TMPDATA)
          *** If the data is longer than the diplay length, print asterix
          *** to show that.
          IF LEN(XDATA<1,3,LINE>) > 46 THEN
             VPRINT 32,LINE,XDATA<1,3,LINE>[1,45]:BLINK$:'*':NORM$
          END ELSE
             VPRINT 32,LINE,XDATA<1,3,LINE> 'L#46'
          END

          RETURN TO IN.CERT
*-------------------------------------------------------------------------*
FILEIT:   IF F12 THEN
             CONFIRM.ABORT SURE
             IF NOT(SURE) THEN GOTO IN.NAME
             XDATA = SV.XDATA
          END
          ICT = DCOUNT(XDATA<1,1>,SVM)
          IF NOT(ICT) THEN ICT = DCOUNT(XDATA<1,3>,SVM)
          IF ICT = 0 THEN XDATA = ''
          IF ICT GT 0 THEN
             IF XDATA<1,1,ICT> = '' AND XDATA<1,3,ICT> = '' THEN
                XDATA = DELETE(XDATA,1,1,ICT)
                XDATA = DELETE(XDATA,1,2,ICT)
                XDATA = DELETE(XDATA,1,3,ICT)
             END
          END
*-------------------------------------------------------------------------*
FINISH:   WINDOW.CLOSE
          RETURN
!SMITJR~05/15/10~16:03
