home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pds.zip / PDEDIT.CMD < prev    next >
OS/2 REXX Batch file  |  1994-03-01  |  35KB  |  1,408 lines

  1. /*REXX*/
  2.  
  3.   /***
  4.   signal on HALT    name HaltExit
  5.   signal on ERROR   name ErrorExit
  6.   signal on FAILURE name FailureExit
  7.   signal on SYNTAX  name SyntaxExit
  8.   ***/
  9.  
  10. main:
  11. parse arg p1
  12.   fDebug   = 'N'
  13.   fDispStax= 'N'
  14.   fDispHelp= 'N'
  15.   fFlSpecQ = 'N'
  16.   sFlSpec = ''
  17.   fIgnoreRXQ = 'N'
  18.  
  19.   CALL rParseParms p1
  20.  
  21.   rc = rLoadFuncs('SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs')
  22.   if rc <> 0 then
  23.    do
  24.     Call rSiren 8, 1
  25.     say 'PDEDIT - Error initializing System REXX routines'
  26.     if fIgnoreRXQ = 'Y' then
  27.      do
  28.       say 'PDEDIT - Ignoring error and will attempt to continue'
  29.      end
  30.     else
  31.      do
  32.       say 'PDEDIT - Quitting'
  33.       exit 8
  34.      end
  35.    end
  36.  
  37.   if fDebug = 'Y' then
  38.    do
  39.     trace ?r
  40.    end
  41.  
  42.   if fDispStax = 'Y' then
  43.    do
  44.     CALL rDispSyntax 0, 0
  45.    end
  46.  
  47.   if fDispHelp = 'Y' then
  48.    do
  49.     CALL rDispSyntax 1, 0
  50.    end
  51.  
  52.   /* Actual routine */
  53.   if fFlSpecQ = 'N' then
  54.    do
  55.     Call rSiren 1, 1
  56.     say 'PDEDIT - Missing file name'
  57.     CALL rDispSyntax 0, 8
  58.    end
  59.   rc   = rLoadFuncs('rxPDLoadFuncs', 'HSSPD', 'rxPDLoadFuncs')
  60.   if rc <> 0 then
  61.    do
  62.     Call rSiren 1, 1
  63.     say 'PDEDIT - Unable to initialize the "RXPD" subsystem'
  64.     exit 8
  65.    end
  66.  
  67.   sGlobal.iMaxRows = 22
  68.   sGlobal.fModifiedQ = 'N'
  69.   sGlobal.iCCBeg = 1
  70.   sGlobal.iCCEnd = 80
  71.   sGlobal.iCCMax = sGlobal.iCCEnd
  72.   sGlobal.sCursorFld='ZCMD'
  73.   sGlobal.iCursorNdx=0
  74.   sGlobal.fDebug=fDebug
  75.  
  76.   bid = rxPDInit('PDEDIT','GREENHI','RED','REDHI',,25,80)
  77.   if bid = x2c(00000000) then
  78.    do
  79.     Call rSiren 2, 3
  80.     say 'PDEDIT - Error to initializing the "RXPD" subsystem'
  81.     exit 8
  82.    end
  83.   Call rxPDZVarDefine
  84.   iNumAttr = ZVTYPE_LONG+ZVTYPE_RIGHTADJUST+ZVTYPE_LZEROFILL
  85.   rc = rxPDVarDefine(bid, 'sGlobal.iCCBeg', iNumAttr, 4)
  86.   rc = rxPDVarDefine(bid, 'sGlobal.iCCEnd', iNumAttr, 4)
  87.   do i = 1 to sGlobal.iMaxRows
  88.    sPDRow.i  = 0
  89.    sPDRec.i  = ''
  90.   end /* do i = 1 to sGlobal.iMaxRows */
  91.  
  92.   akey = rxPDDisplay(bid,'PANEL000')
  93.   do while 0 = rDoEdit(bid)
  94.   end /* do while 0 = rDoEdit() */
  95.  
  96.   /* Save the file */
  97.   Call rDoSAVE
  98.  
  99.   rc = rxPDTerm(bid)
  100.  
  101.   exit 0
  102.  
  103. /**********************************************************************\
  104.  rDoEdit:
  105.   This routine displays a dialog panel for the file.
  106. \**********************************************************************/
  107. rDoEdit:
  108. parse arg bid
  109.   DROP sFlRecs.
  110.   Call rLoadFileStem
  111.   sGlobal.iNdx = 1
  112.   Call rLoadPDStem sGlobal.iNdx
  113.  
  114.   do FOREVER
  115.  
  116.    akey = ZESC
  117.    ZCMD = ''
  118.    ZAMT = 'CSR'
  119.  
  120.    do while akey = ZESC
  121.     akey = rxPDDisplay(bid, 'PANEL001', sGlobal.sCursorFld, sGlobal.iCursorNdx)
  122.     parse var ZCurVar ziCol zFld
  123.     sGlobal.sCursorFld = zFld
  124.     sGlobal.iCursorNdx = ziCol
  125.     if aKey = ZESC then
  126.      do
  127.       Call rLoadPDStem sGlobal.iNdx
  128.      end
  129.    end /*do while akey = ZESC*/
  130.  
  131.    parse var zFld sFld '.' iPDRow
  132.  
  133.  /*if akey = ZHOME then */
  134.  /* do                  */
  135.  /*  Call rDoHOME       */
  136.  /*  iterate            */
  137.  /* end                 */
  138.  /*if akey = ZARRWUP then    */
  139.  /* do                       */
  140.  /*  Call rDoARRWUP          */
  141.  /*  iterate                 */
  142.  /* end                      */
  143.  /*if akey = ZARRWDOWN then  */
  144.  /* do                       */
  145.  /*  Call rDoARRWDOWN        */
  146.  /*  iterate                 */
  147.  /* end                      */
  148.  
  149.    Call rxPDDisplay bid, 'PANELXSYSTEM'
  150.  
  151.    sGlobal.iMDTCnt = rxPDQueryMDT(bid,'PANEL001')
  152.    if sGlobal.iMDTCnt > 0 then
  153.     do
  154.      if sGlobal.iMDTCnt <> 1 | \rxPDQueryMDT(bid,'PANEL001','ZCMD') then
  155.       do
  156.        rc = rDoUpdateRows()
  157.        if rc <> 0 then                 /* Possible line command error */
  158.         do
  159.          iterate
  160.         end
  161.       end
  162.     end
  163.  
  164.    select
  165.     when akey = ZARRWUP then
  166.      do
  167.       Call rDoARRWUP
  168.      end
  169.     when akey = ZARRWDOWN then
  170.      do
  171.       Call rDoARRWDOWN
  172.      end
  173.     when akey = ZPGUP then
  174.      do
  175.       Call rDoPGUP
  176.      end
  177.     when akey = ZPGDW then
  178.      do
  179.       Call rDoPGDW
  180.      end
  181.     when akey = ZENTER then
  182.      do
  183.       Call rDoENTER
  184.      end
  185.     when akey = ZHOME then
  186.      do
  187.       Call rDoHOME
  188.      end
  189.     when akey = Z_D_A then
  190.      do
  191.       Call rDoDELETE
  192.      end
  193.     when akey = Z_T_A | akey = ZF2 then
  194.      do
  195.       Call rDoSPLIT
  196.      end
  197.     when akey = Z_J_A then
  198.      do
  199.       Call rDoJOIN
  200.      end
  201.     when akey = Z_I_A | akey = ZF3 then
  202.      do
  203.       Call rDoINSERT
  204.      end
  205.     when akey = Z_R_A | akey = ZF4 then
  206.      do
  207.       Call rDoREPEAT
  208.      end
  209.     when akey = Z_S_A then
  210.      do
  211.       Call rDoSAVE
  212.      end
  213.     when akey = ZPGUP_C then
  214.      do
  215.       Call rDoPGUP_C
  216.      end
  217.     when akey = ZPGDW_C then
  218.      do
  219.       Call rDoPGDW_C
  220.      end
  221.     when akey = ZF10 then
  222.      do
  223.       Call rDoLSCROLL
  224.      end
  225.     when akey = ZF11 then
  226.      do
  227.       Call rDoRSCROLL
  228.      end
  229.     when akey = ZF3_A | akey = ZF4_A then
  230.      do
  231.       return 8
  232.      end
  233.     otherwise
  234.      do
  235.       Call rSiren 4,3
  236.       sGlobal.sCursorFld='ZCMD'
  237.       sGlobal.iCursorNdx=0
  238.      end
  239.    end /* select */
  240.  
  241.   if sGlobal.iMDTCnt <> 0 & rxPDQueryMDT(bid,'PANEL001','ZCMD') then
  242.    do
  243.     rc = rDoPrimaryCMDS()
  244.     if rc > 4 then
  245.      do
  246.       return rc
  247.      end
  248.    end
  249.  
  250.   end /*do FOREVER */
  251.  
  252.   return 0;
  253.  
  254. /**********************************************************************\
  255.  rDoPrimaryCMDS:
  256.   Routine to test the ZCMD field for possible primary command
  257. \**********************************************************************/
  258. rDoPrimaryCMDS:
  259.   if sGlobal.fDebug = 'RDOPRIMARYCMDS' then
  260.    do
  261.     Call Trace ?r
  262.    end
  263.  
  264.   svZCMD = ZCMD
  265.   parse var ZCMD ZCMD ZCMDTRLR
  266.   select
  267.    when '' = ZCMD then
  268.     do
  269.     end
  270.    when 'CAN' = TRANSLATE(ZCMD) | 'CANCEL' = TRANSLATE(ZCMD) then
  271.     do
  272.      sGlobal.fModifiedQ = 'N'
  273.      return 8
  274.     end
  275.    when 'D' = TRANSLATE(ZCMD) | 'DEL' = TRANSLATE(ZCMD) then
  276.     do
  277.      ZCMDTRLR = STRIP(ZCMDTRLR)
  278.      if ZCMDTRLR = '' then
  279.       do
  280.        ZCMDTRLR = 1
  281.       end
  282.      if DATATYPE(ZCMDTRLR) <> 'NUM' then
  283.       do
  284.        sGlobal.sCursorFld = 'ZCMD'
  285.        sGlobal.iCursorNdx=0
  286.        sShortMsg = ''
  287.        sLongMsg = '"'ZCMDTRLR'" IS NOT A VALID DELETE OPERAND.'
  288.        rc = rxPDSetMsgText(bid,sShortMsg,sLongMsg,,ZALARM_ERROR)
  289.        return 0
  290.       end
  291.      iPCRow = 1
  292.      if ABBREV(sGlobal.sCursorFld,'sPDRec.') then
  293.       do
  294.        iPCRow = iPDRow
  295.       end
  296.      rc = rDeleteRow(iPCRow,ZCMDTRLR);
  297.      if rc <> 0 then
  298.       do
  299.        sGlobal.sCursorFld = 'ZCMD'
  300.        sGlobal.iCursorNdx=0
  301.        return 0
  302.       end
  303.      Call rLoadPDStem sGlobal.iNdx
  304.     end
  305.    when 'I' = TRANSLATE(ZCMD) | 'INSERT' = TRANSLATE(ZCMD) then
  306.     do
  307.      ZCMDTRLR = STRIP(ZCMDTRLR)
  308.      if ZCMDTRLR = '' then
  309.       do
  310.        ZCMDTRLR = 1
  311.       end
  312.      if DATATYPE(ZCMDTRLR) <> 'NUM' then
  313.       do
  314.        sGlobal.sCursorFld = 'ZCMD'
  315.        sGlobal.iCursorNdx=0
  316.        sShortMsg = ''
  317.        sLongMsg = '"'ZCMDTRLR'" IS NOT A VALID INSERT OPERAND.'
  318.        rc = rxPDSetMsgText(bid,sShortMsg,sLongMsg,,ZALARM_ERROR)
  319.        return 0
  320.       end
  321.      iPCRow = 1
  322.      if ABBREV(sGlobal.sCursorFld,'sPDRec.') then
  323.       do
  324.        iPCRow = iPDRow
  325.       end
  326.      rc = rInsertRow(iPCRow,ZCMDTRLR);
  327.      if rc <> 0 then
  328.       do
  329.        sGlobal.sCursorFld = 'ZCMD'
  330.        sGlobal.iCursorNdx=0
  331.        return 0
  332.       end
  333.      Call rLoadPDStem sGlobal.iNdx
  334.     end
  335.    when 'R' = TRANSLATE(ZCMD) | 'REPEAT' = TRANSLATE(ZCMD) then
  336.     do
  337.      ZCMDTRLR = STRIP(ZCMDTRLR)
  338.      if ZCMDTRLR = '' then
  339.       do
  340.        ZCMDTRLR = 1
  341.       end
  342.      if DATATYPE(ZCMDTRLR) <> 'NUM' then
  343.       do
  344.        sGlobal.sCursorFld = 'ZCMD'
  345.        sGlobal.iCursorNdx=0
  346.        sShortMsg = ''
  347.        sLongMsg = '"'ZCMDTRLR'" IS NOT A VALID INSERT OPERAND.'
  348.        rc = rxPDSetMsgText(bid,sShortMsg,sLongMsg,,ZALARM_ERROR)
  349.        return 0
  350.       end
  351.      iPCRow = 1
  352.      if ABBREV(sGlobal.sCursorFld,'sPDRec.') then
  353.       do
  354.        iPCRow = iPDRow
  355.       end
  356.      rc = rRepeatRow(iPCRow,ZCMDTRLR);
  357.      if rc <> 0 then
  358.       do
  359.        sGlobal.sCursorFld = 'ZCMD'
  360.        sGlobal.iCursorNdx=0
  361.        return 0
  362.       end
  363.      Call rLoadPDStem sGlobal.iNdx
  364.     end
  365.    when 'F' = TRANSLATE(ZCMD) | 'FIND' = TRANSLATE(ZCMD) then
  366.     do
  367.     end
  368.    when 'C' = TRANSLATE(ZCMD) | 'CHANGE' = TRANSLATE(ZCMD) then
  369.     do
  370.     end
  371.    when 'L' = TRANSLATE(ZCMD) | 'LOCATE' = TRANSLATE(ZCMD) then
  372.     do
  373.      if ZCMDTRLR = '' | DATATYPE(ZCMDTRLR) <> 'NUM' then
  374.       do
  375.        sGlobal.sCursorFld = 'ZCMD'
  376.        sGlobal.iCursorNdx=WORDINDEX(svZCMD,2)
  377.        sShortMsg = ''
  378.        sLongMsg = '"'svZCMD'" IS NOT A VALID LOCATE REQUEST.'
  379.        rc = rxPDSetMsgText(bid,sShortMsg,sLongMsg,,ZALARM_ERROR)
  380.        return 0
  381.       end
  382.      sGlobal.iCursorFld = 'ZCMD'
  383.      sGlobal.iCursorNdx = 0
  384.      sGlobal.iNdx = ZCMDTRLR+1
  385.      Call rLoadPDStem sGlobal.iNdx
  386.     end
  387.    otherwise
  388.     do
  389.      sGlobal.sCursorFld = 'ZCMD'
  390.      sGlobal.iCursorNdx=0
  391.      sShortMsg = 'UNKNOWN'
  392.      sLongMsg = '"'ZCMD'" IS NOT A VALID PRIMARY COMAND.'
  393.      rc = rxPDSetMsgText(bid,sShortMsg,sLongMsg,,ZALARM_ERROR)
  394.     end
  395.   end /*select*/
  396.  
  397.   return 0;
  398.  
  399. /**********************************************************************\
  400.  rDoUpdateRows:
  401.   Routine to test all fields' MDT state and act accordingly
  402. \**********************************************************************/
  403. rDoUpdateRows:
  404.   /* First, test all rows */
  405.   iUpdState = 0
  406.  
  407.   do i = 1 to sGlobal.iMDTCnt          /* Test only MDTd fields */
  408.    sUPFld = rxPDQueryMDTFld(bid,'PANEL001',i) /* Retrieve MDTd FldName*/
  409.    parse var sUPFld sUPFld '.' iUPPDRow /* Parse it out */
  410.    select
  411.     when 'sPDRec'  = sUPFld then       /* Data field */
  412.      do
  413.       Call rUpdateRow iUPPDRow         /* Yep, update the file stem */
  414.       iUpdState = 1                    /* Remember we touched one */
  415.      end
  416.     otherwise
  417.      do
  418.      end
  419.    end /*select*/
  420.   end /*do i = 1 to sGlobal.iMDTCnt*/  /* Test only MDTd fields */
  421.  
  422.   /* 2nd, test for any updated rows */
  423.   if iUpdState = 1 then
  424.    do
  425.     Call rLoadPDStem sGlobal.iNdx
  426.    end
  427.  
  428.   return 0
  429.  
  430. /**********************************************************************\
  431.  rDoARRWUP:
  432.   Routine to handle the simple Arrow_Up key
  433. \**********************************************************************/
  434. rDoARRWUP:
  435.  
  436.   if sFld = 'sPDRec' then
  437.    do
  438.     if iPDRow = 1 then
  439.      do
  440.       sGlobal.sCursorFld = 'ZCMD'
  441.       sGlobal.iCursorNdx = 0
  442.       return 0
  443.      end
  444.     sGlobal.sCursorFld = 'sPDRec.'iPDRow-1
  445.     return 0
  446.    end
  447.  
  448.   i = sGlobal.iMaxRows
  449.   sGlobal.sCursorFld = 'sPDRec.'i
  450.   sGlobal.iCursorNdx = 0
  451.  
  452.   return 0
  453.  
  454. /**********************************************************************\
  455.  rDoARRWDOWN:
  456.   Routine to handle the simple Arrow_DOWN key
  457. \**********************************************************************/
  458. rDoARRWDOWN:
  459.  
  460.   if sFld = 'sPDRec' then
  461.    do
  462.     if iPDRow = sGlobal.iMaxRows then
  463.      do
  464.       sGlobal.sCursorFld = 'ZCMD'
  465.       sGlobal.iCursorNdx = 0
  466.       return 0
  467.      end
  468.     sGlobal.sCursorFld = 'sPDRec.'iPDRow+1
  469.     return 0
  470.    end
  471.  
  472.   sGlobal.sCursorFld = 'sPDRec.'1
  473.   sGlobal.iCursorNdx = 0
  474.  
  475.   return 0
  476.  
  477. /**********************************************************************\
  478.  rDoPGUP:
  479.   Routine to handle the simple Page_Up key
  480. \**********************************************************************/
  481. rDoPGUP:
  482.   select
  483.    when sFld = 'sPDRec' then
  484.     do
  485.      if iPDRow<>sGlobal.iMaxRows then
  486.       do
  487.        iDelta = sGlobal.iMaxRows - iPDRow
  488.        iNRow = iPDRow + iDelta      /* I.E. iNRow = sGlobal.iMaxRows */
  489.        sGlobal.iNdx = sGlobal.iNdx - iDelta /* Data row to display */
  490.        if sGlobal.iNdx <= 0 then
  491.         do
  492.          iNRow = iNRow + sGlobal.iNdx - 1 /* Back it up */
  493.          sGlobal.iNdx = 1
  494.         end
  495.        sGlobal.sCursorFld=sFld'.'iNRow
  496.       end
  497.      else
  498.       do
  499.        sGlobal.sCursorFld='ZCMD'
  500.        sGlobal.iCursorNdx=0
  501.        sGlobal.iNdx = sGlobal.iNdx - sGlobal.iMaxRows
  502.       end
  503.     end
  504.    otherwise
  505.     do
  506.      sGlobal.sCursorFld='ZCMD'
  507.      sGlobal.iCursorNdx=0
  508.      select
  509.       when ZCMD = '' then
  510.        do
  511.         sGlobal.iNdx = sGlobal.iNdx - sGlobal.iMaxRows
  512.        end
  513.       when DATATYPE(ZCMD) = 'NUM' then
  514.        do
  515.         sGlobal.iNdx = sGlobal.iNdx - ZCMD
  516.         ZCMD = ''
  517.        end
  518.       when TRANSLATE(ZCMD) = 'M' then
  519.        do
  520.         sGlobal.iNdx = 1
  521.         ZCMD = ''
  522.        end
  523.       when TRANSLATE(ZCMD) = 'H' then
  524.        do
  525.         sGlobal.iNdx = sGlobal.iNdx - FORMAT(sGlobal.iMaxRows/2,,0)
  526.         ZCMD = ''
  527.        end
  528.       otherwise
  529.        do
  530.         sGlobal.iNdx = sGlobal.iNdx - sGlobal.iMaxRows
  531.        end
  532.      end /* select */
  533.     end
  534.   end /* select */
  535.   Call rLoadPDStem sGlobal.iNdx
  536.  
  537.   return 0
  538.  
  539. /**********************************************************************\
  540.  rDoPGDW:
  541.   Routine to handle the simple Page_Down key
  542. \**********************************************************************/
  543. rDoPGDW:
  544.   select
  545.    when sFld = 'sPDRec' then
  546.     do
  547.      if iPDRow<>1 then
  548.       do
  549.        iDelta = iPDRow - 1
  550.        iNRow = iPDRow - iDelta      /* I.E. iNRow = 1 */
  551.        sGlobal.iNdx = sGlobal.iNdx + iDelta /* Data row to display */
  552.        if sGlobal.iNdx > sFlRecs.0+1 then /* Beyond end of table + EYEC */
  553.         do
  554.          iNRow = (sGlobal.iNdx-sFlRecs.0) /* Move it down */
  555.          sGlobal.iNdx = sFlRecs.0+1
  556.         end
  557.        sGlobal.sCursorFld=sFld'.'iNRow
  558.       end
  559.      else
  560.       do
  561.        sGlobal.sCursorFld='ZCMD'
  562.        sGlobal.iCursorNdx=0
  563.        sGlobal.iNdx = sGlobal.iNdx + sGlobal.iMaxRows
  564.       end
  565.     end
  566.    otherwise
  567.     do
  568.      sGlobal.sCursorFld='ZCMD'
  569.      sGlobal.iCursorNdx=0
  570.      select
  571.       when ZCMD = '' then
  572.        do
  573.         sGlobal.iNdx = sGlobal.iNdx + sGlobal.iMaxRows
  574.        end
  575.       when DATATYPE(ZCMD) = 'NUM' then
  576.        do
  577.         sGlobal.iNdx = sGlobal.iNdx + ZCMD
  578.         ZCMD = ''
  579.        end
  580.       when TRANSLATE(ZCMD) = 'M' then
  581.        do
  582.         sGlobal.iNdx = sFlRecs.0 - sGlobal.iMaxRows + 1
  583.         ZCMD = ''
  584.        end
  585.       when TRANSLATE(ZCMD) = 'H' then
  586.        do
  587.         sGlobal.iNdx = sGlobal.iNdx + FORMAT(sGlobal.iMaxRows/2,,0)
  588.         ZCMD = ''
  589.        end
  590.       otherwise
  591.        do
  592.         sGlobal.iNdx = sGlobal.iNdx + sGlobal.iMaxRows
  593.        end
  594.      end /* select */
  595.     end
  596.   end /* select */
  597.   Call rLoadPDStem sGlobal.iNdx
  598.  
  599.   return 0
  600.  
  601. /**********************************************************************\
  602.  rDoLSCROLL:
  603.   Routine to handle the F10 key
  604. \**********************************************************************/
  605. rDoLSCROLL:
  606.  
  607.   if sFld = 'ZCMD' then
  608.    do
  609.     iShift = sGlobal.iCCMax
  610.    end
  611.  
  612.   if sFld = 'sPDRec' then
  613.    do
  614.     iShift = sGlobal.iCCMax - sGlobal.iCursorNdx + 1
  615.     if iShift > sGlobal.iCCBeg then
  616.      do
  617.       iShift = sGlobal.iCCBeg - 1
  618.      end
  619.     sGlobal.iCursorNdx = sGlobal.iCursorNdx + iShift
  620.     if iShift >= sGlobal.iCCMax then
  621.      do
  622.       iShift = sGlobal.iCCMax
  623.      end
  624.    end
  625.  
  626.   sGlobal.iCCBeg = sGlobal.iCCBeg - iShift
  627.   sGlobal.iCCEnd = sGlobal.iCCEnd - iShift
  628.  
  629.   if sGlobal.iCCBeg <= 0 then
  630.    do
  631.     sGlobal.iCCBeg = 1
  632.     sGlobal.iCCEnd = sGlobal.iCCMax
  633.    end
  634.  
  635.   Call rLoadPDStem sGlobal.iNdx
  636.  
  637.   return 0
  638.  
  639. /**********************************************************************\
  640.  rDoRSCROLL:
  641.   Routine to handle the F11 key
  642. \**********************************************************************/
  643. rDoRSCROLL:
  644.  
  645.   if sFld = 'ZCMD' then
  646.    do
  647.     iShift = sGlobal.iCCMax
  648.    end
  649.  
  650.   if sFld = 'sPDRec' then
  651.    do
  652.     iShift = sGlobal.iCursorNdx - 1
  653.     sGlobal.iCursorNdx = 1
  654.     if iShift <= 0 then
  655.      do
  656.       iShift = sGlobal.iCCMax
  657.      end
  658.    end
  659.  
  660.   sGlobal.iCCBeg = sGlobal.iCCBeg + iShift
  661.   sGlobal.iCCEnd = sGlobal.iCCEnd + iShift
  662.  
  663.   Call rLoadPDStem sGlobal.iNdx
  664.  
  665.   return 0
  666.  
  667. /**********************************************************************\
  668.  rDoENTER:
  669.   Routine to handle ENTER
  670. \**********************************************************************/
  671. rDoENTER:
  672.  
  673.   if sGlobal.iMDTCnt = 0 then
  674.    do
  675.     if zFld = 'ZCMD' then
  676.      do
  677.       sGlobal.sCursorFld='sPDRec.1'
  678.       sGlobal.iCursorNdx=0
  679.      end
  680.     else
  681.      do
  682.       if iPDRow = sGlobal.iMaxRows then
  683.        do
  684.         sGlobal.sCursorFld = 'ZCMD'
  685.         sGlobal.iCursorNdx = 0
  686.        end
  687.       else
  688.        do
  689.         sGlobal.sCursorFld = 'sPDRec.'iPDRow+1
  690.         INTERPRET 'sTst =sPDRec.'iPDRow+1
  691.         sGlobal.iCursorNdx = WORDINDEX(sTst,1)
  692.        end
  693.      end
  694.    end
  695.  
  696.   return 0
  697.  
  698. /**********************************************************************\
  699.  rDoHOME:
  700.   Routine to handle HOME
  701. \**********************************************************************/
  702. rDoHOME:
  703.   if ziCol = 1 then
  704.    do
  705.     sGlobal.sCursorFld='ZCMD'
  706.    end
  707.   else
  708.    do
  709.     sGlobal.sCursorFld=zFld
  710.    end
  711.   sGlobal.iCursorNdx=0
  712.  
  713.   return 0
  714.  
  715. /**********************************************************************\
  716.  rDoSAVE
  717.   Routine to handle SAVE
  718. \**********************************************************************/
  719. rDoSAVE:
  720.   if sGlobal.fModifiedQ <> 'Y' then
  721.    do
  722.     return 0
  723.    end
  724.   sGlobal.fModifiedQ = 'N'
  725.   return rStoreFileStem()
  726.  
  727. /**********************************************************************\
  728.  rDoDELETE:
  729.   Routine to handle DELETE
  730. \**********************************************************************/
  731. rDoDELETE:
  732.   if sFld <> 'sPDRec' then
  733.    do
  734.     return 0
  735.    end
  736.   sGlobal.sCursorFld=zFld
  737.   sGlobal.iCursorNdx=0
  738.   rc = rDeleteRow(iPDRow,1);
  739.   if rc <> 0 then
  740.    do
  741.     return 0
  742.    end
  743.   Call rLoadPDStem sGlobal.iNdx
  744.  
  745.   return 0
  746.  
  747. /**********************************************************************\
  748.  rDoSPLIT:
  749.   Routine to handle SPLIT
  750. \**********************************************************************/
  751. rDoSPLIT:
  752.   if sFld <> 'sPDRec' then
  753.    do
  754.     return 0
  755.    end
  756. /*sGlobal.sCursorFld=zFld*/
  757. /*sGlobal.iCursorNdx=0   */
  758.   rc = rSplitRow(iPDRow,1);
  759.   if rc <> 0 then
  760.    do
  761.     return 0
  762.    end
  763.   Call rLoadPDStem sGlobal.iNdx
  764.  
  765.   return 0
  766.  
  767. /**********************************************************************\
  768.  rDoJOIN:
  769.   Routine to handle JOIN
  770. \**********************************************************************/
  771. rDoJOIN:
  772.   if sFld <> 'sPDRec' then
  773.    do
  774.     return 0
  775.    end
  776.   rc = rJoinRow(iPDRow,1);
  777.   if rc <> 0 then
  778.    do
  779.     return 0
  780.    end
  781.   Call rLoadPDStem sGlobal.iNdx
  782.  
  783.   return 0
  784.  
  785. /**********************************************************************\
  786.  rDoINSERT:
  787.   Routine to handle INSERT
  788. \**********************************************************************/
  789. rDoINSERT:
  790.   if sFld <> 'sPDRec' then
  791.    do
  792.     return 0
  793.    end
  794.   sGlobal.sCursorFld=zFld
  795.   sGlobal.iCursorNdx=0
  796.   rc = rInsertRow(iPDRow,1);
  797.   if rc <> 0 then
  798.    do
  799.     return 0
  800.    end
  801.   Call rLoadPDStem sGlobal.iNdx
  802.  
  803.   return 0
  804.  
  805. /**********************************************************************\
  806.  rDoREPEAT:
  807.   Routine to handle REPEAT
  808. \**********************************************************************/
  809. rDoREPEAT:
  810.   if sFld <> 'sPDRec' then
  811.    do
  812.     return 0
  813.    end
  814.   sGlobal.sCursorFld=zFld
  815.   sGlobal.iCursorNdx=0
  816.   rc = rRepeatRow(iPDRow,1);
  817.   if rc <> 0 then
  818.    do
  819.     return 0
  820.    end
  821.   Call rLoadPDStem sGlobal.iNdx
  822.  
  823.   return 0
  824.  
  825. /**********************************************************************\
  826.  rDoPGUP_C:
  827.   Routine to handle Ctrl+PAGEUP
  828. \**********************************************************************/
  829. rDoPGUP_C:
  830.   sGlobal.sCursorFld='sPDRec.1'
  831.   sGlobal.iCursorNdx=0
  832.   sGlobal.iNdx = 1
  833.   Call rLoadPDStem sGlobal.iNdx
  834.  
  835.   return 0
  836.  
  837. /**********************************************************************\
  838.  rDoPGDW_C:
  839.   Routine to handle Ctrl+PAGEDOWN
  840. \**********************************************************************/
  841. rDoPGDW_C:
  842.   sGlobal.sCursorFld='sPDRec.1'
  843.   sGlobal.iCursorNdx=0
  844.   sGlobal.iNdx = sFlRecs.0
  845.   Call rLoadPDStem sGlobal.iNdx
  846.  
  847.   return 0
  848.  
  849. /**********************************************************************\
  850.  rUpdateRow:
  851.   This routine updates a row in the TSD (maybe)
  852. \**********************************************************************/
  853. rUpdateRow: Procedure Expose sPDRow. sPDRec. sFlRecs. sGlobal.
  854. parse arg iUpdRow
  855.   iRow = sPDRow.iUpdRow
  856.   if iRow = 1 | iRow >= sFlRecs.0 then
  857.    do
  858.     return 4
  859.    end
  860.   if sGlobal.iCCBeg > 1 then
  861.    do
  862.     sFrst = SUBSTR(sFlRecs.iRow,1,sGlobal.iCCBeg-1,' ')
  863.    end
  864.   else
  865.    do
  866.     sFrst = ''
  867.    end
  868.   sMddl = sPDRec.iUpdRow
  869. /*sMddl = SUBSTR(sFlRecs.iRow,sGlobal.iCCBeg,(sGlobal.iCCEnd-sGlobal.iCCBeg+1),' ')*/
  870.   if LENGTH(sFlRecs.iRow) > sGlobal.iCCEnd then
  871.    do
  872.     sLast = STRIP(SUBSTR(sFlRecs.iRow,sGlobal.iCCEnd))
  873.    end
  874.   else
  875.    do
  876.     sLast = ''
  877.    end
  878.  
  879.   sFlRecs.iRow = sFrst||sMddl||sLast
  880.  
  881.   if iUpdRow < sGlobal.iMaxRows then
  882.    do
  883.     sGlobal.sCursorFld = 'sPDRec.'iUpdRow+1
  884.     INTERPRET 'sTst =sPDRec.'iUpdRow
  885.     sGlobal.iCursorNdx = WORDINDEX(sTst,1)
  886.    end
  887.   else
  888.    do
  889.     sGlobal.sCursorFld = 'ZCMD'
  890.     sGlobal.iCursorNdx=0
  891.    end
  892.   sGlobal.fModifiedQ = 'Y'
  893.   return 0
  894.  
  895. /**********************************************************************\
  896.  rDeleteRow:
  897.   This routine deletes a record
  898. \**********************************************************************/
  899. rDeleteRow:
  900. parse arg iDelRow, iCnt
  901.   iRow = sPDRow.iDelRow
  902.   if iRow = 1 | iRow >= sFlRecs.0 then
  903.    do
  904.     return 4
  905.    end
  906.  
  907.   /* Let Someone else do the dirty work */
  908.   Call rDeleteRowNum iRow, iCnt
  909.  
  910.   /* Where to position cursor */
  911.   sGlobal.sCursorFld = 'sPDRec.'iDelRow
  912.   sGlobal.iCursorNdx=0
  913.  
  914.   sGlobal.fModifiedQ = 'Y'
  915.   return 0
  916.  
  917. /**********************************************************************\
  918.  rDeleteRowNum:
  919.   This routine deletes a specific record
  920. \**********************************************************************/
  921. rDeleteRowNum:
  922. parse arg iRowNum, iCnt
  923.   if iRowNum = 1 | iRowNum >= sFlRecs.0 then
  924.    do
  925.     return 4
  926.    end
  927.  
  928.   /* First see if we are deleting too many */
  929.   if iRowNum + iCnt > sFlRecs.0 then
  930.    do
  931.     iCnt = sFlRecs.0 - iRowNum         /* Max to Delete */
  932.    end
  933.  
  934.   iTRow = iRowNum                      /* Target row number */
  935.   iSRow = iRowNum + iCnt               /* Source row Number */
  936.   iLoop = sFlRecs.0 - iRowNum - iCnt + 1 /* Number of rows to move */
  937.   do iLoop
  938.    sFlRecs.iTRow = sFlRecs.iSRow       /* Copy source to target */
  939.    iTRow = iTRow + 1                   /* Next target */
  940.    iSRow = iSRow + 1                   /* Next source */
  941.   end /*do iLoop*/
  942.   sFlRecs.0 = sFlRecs.0 - iCnt
  943.  
  944.   sGlobal.fModifiedQ = 'Y'
  945.   return 0
  946.  
  947. /**********************************************************************\
  948.  rSplitRow:
  949.   This routine Splits a row in the TSD (maybe)
  950. \**********************************************************************/
  951. rSplitRow:
  952. parse arg iSpltRow, iCnt
  953.   iRow = sPDRow.iSpltRow
  954.   if iRow = 1 | iRow >= sFlRecs.0 then
  955.    do
  956.     return 4
  957.    end
  958.  
  959.   /* Save the current cursor position */
  960.   sSpltCFld = sGlobal.sCursorFld
  961.   iSpltCNdx = sGlobal.iCursorNdx
  962.  
  963.   /* Split the record into pieces parts */
  964.   iSplit = sGlobal.iCCBeg + sGlobal.iCursorNdx - 1
  965.   if iSplit = 1 then
  966.    do
  967.     sLHalf = ''
  968.     sRHalf = sFlRecs.iRow
  969.    end
  970.   else
  971.    do
  972.     sLHalf = SUBSTR(sFlRecs.iRow,1,iSplit-1)
  973.     sRHalf = SUBSTR(sFlRecs.iRow,iSplit)
  974.    end
  975.  
  976.   /* Insert a blank line after the current row */
  977.   rc = rInsertRow(iSpltRow,1)
  978.  
  979.   /* Update the two rows */
  980.   sFlRecs.iRow = sLHalf
  981.   iRow=iRow+1
  982.   sFlRecs.iRow = sRHalf
  983.  
  984.   /* Restore the current cursor position */
  985.   sGlobal.sCursorFld = sSpltCFld
  986.   sGlobal.iCursorNdx = iSpltCNdx
  987.  
  988.   sGlobal.fModifiedQ = 'Y'
  989.   return 0
  990.  
  991. /**********************************************************************\
  992.  rJoinRow:
  993.   This routine Joins a row in the TSD (maybe)
  994. \**********************************************************************/
  995. rJoinRow:
  996. parse arg iJoinRow, iCnt
  997.   iRow = sPDRow.iJoinRow
  998.   /* Note special test for last row */
  999.   if iRow = 1 | iRow+1 >= sFlRecs.0 then
  1000.    do
  1001.     return 4
  1002.    end
  1003.  
  1004.   /* Save the current cursor position */
  1005.   sJoinCFld = sGlobal.sCursorFld
  1006.   iJoinCNdx = sGlobal.iCursorNdx
  1007.  
  1008.   /* Join the records */
  1009.   iNextRow = iRow+1
  1010.   sNewRec=STRIP(sFlRecs.iRow)||sFlRecs.iNextRow
  1011.   sFlRecs.iRow=sNewRec
  1012.  
  1013.   /* Delete the row after the current row */
  1014.   rc = rDeleteRowNum(iNextRow,1)
  1015.  
  1016.   /* Restore the current cursor position */
  1017.   sGlobal.sCursorFld = sJoinCFld
  1018.   sGlobal.iCursorNdx = iJoinCNdx
  1019.  
  1020.   sGlobal.fModifiedQ = 'Y'
  1021.   return 0
  1022.  
  1023. /**********************************************************************\
  1024.  rInsertRow:
  1025.   This routine Inserts a row in the TSD (maybe)
  1026. \**********************************************************************/
  1027. rInsertRow:
  1028. parse arg iInsRow, iCnt
  1029.   iRow = sPDRow.iInsRow
  1030.   if iRow >= sFlRecs.0 then
  1031.    do
  1032.     return 4
  1033.    end
  1034.  
  1035.   /* Shift the file stem */
  1036.   iTRow = sFlRecs.0+iCnt               /* Target row number */
  1037.   iSRow = sFlRecs.0                    /* Source row Number */
  1038.   iLoop = sFlRecs.0 - iRow             /* Number of rows to move */
  1039.   do iLoop
  1040.    sFlRecs.iTRow = sFlRecs.iSRow       /* Copy source to target */
  1041.    iTRow = iTRow - 1                   /* Next target */
  1042.    iSRow = iSRow - 1                   /* Next source */
  1043.   end /*do iLoop*/
  1044.  
  1045.   /* Blank new rows */
  1046.   do iCnt
  1047.    sFlRecs.iTRow = ''                  /* Blank new target */
  1048.    iTRow = iTRow - 1                   /* Next target */
  1049.   end /*do iCnt*/
  1050.  
  1051.   /* Account for new rows */
  1052.   sFlRecs.0 = sFlRecs.0 + iCnt
  1053.  
  1054.   /* Where to position cursor */
  1055.   if iInsRow < sGlobal.iMaxRows then
  1056.    do
  1057.     sGlobal.sCursorFld = 'sPDRec.'iInsRow+1
  1058.    end
  1059.   else
  1060.    do
  1061.     sGlobal.sCursorFld = 'sPDRec.'iInsRow
  1062.     sGlobal.iNdx = sGlobal.iNdx + 1
  1063.    end
  1064.   INTERPRET 'sTst =sPDRec.'iInsRow
  1065.   sGlobal.iCursorNdx = WORDINDEX(sTst,1)
  1066.  
  1067.   sGlobal.fModifiedQ = 'Y'
  1068.   return 0
  1069.  
  1070. /**********************************************************************\
  1071.  rRepeatRow:
  1072.   This routine repeats a row in the TSD (maybe)
  1073. \**********************************************************************/
  1074. rRepeatRow:
  1075. parse arg iRptRow, iCnt
  1076.   iRow = sPDRow.iRptRow
  1077.   if iRow = 1 | iRow >= sFlRecs.0 then
  1078.    do
  1079.     return 4
  1080.    end
  1081.  
  1082.   /* Shift the file stem */
  1083.   iTRow = sFlRecs.0+iCnt               /* Target row number */
  1084.   iSRow = sFlRecs.0                    /* Source row Number */
  1085.   iLoop = sFlRecs.0 - iRow             /* Number of rows to move */
  1086.   do iLoop
  1087.    sFlRecs.iTRow = sFlRecs.iSRow       /* Copy source to target */
  1088.    iTRow = iTRow - 1                   /* Next target */
  1089.    iSRow = iSRow - 1                   /* Next source */
  1090.   end /*do iLoop*/
  1091.  
  1092.   /* Init new rows with old row */
  1093.   do iCnt
  1094.    sFlRecs.iTRow = sFlRecs.iRow        /* Copy it */
  1095.    iTRow = iTRow - 1                   /* Next target */
  1096.   end /*do iCnt*/
  1097.  
  1098.   /* Account for new rows */
  1099.   sFlRecs.0 = sFlRecs.0 + iCnt
  1100.  
  1101.   /* Where to position cursor */
  1102.   if iRptRow < sGlobal.iMaxRows then
  1103.    sGlobal.sCursorFld = 'sPDRec.'iRptRow+1
  1104.   else
  1105.    do
  1106.     sGlobal.sCursorFld = 'sPDRec.'iRptRow
  1107.     sGlobal.iNdx = sGlobal.iNdx + 1
  1108.    end
  1109.   sGlobal.iCursorNdx=0
  1110.  
  1111.   sGlobal.fModifiedQ = 'Y'
  1112.   return 0
  1113.  
  1114. /**********************************************************************\
  1115.  rLoadPDStem:
  1116.   This routine loads the display stem variables beginning with the
  1117.   specified index.
  1118. \**********************************************************************/
  1119. rLoadPDStem:
  1120. parse arg iLNdx
  1121.   if iLNdx > sFlRecs.0 then
  1122.    do
  1123.     iLNdx = sFlRecs.0
  1124.    end
  1125.   if iLNdx < 1 then
  1126.    do
  1127.     iLNdx = 1
  1128.    end
  1129.   j = iLNdx
  1130.   do i = 1 to sGlobal.iMaxRows
  1131.    select
  1132.     when j = 1 then
  1133.      do
  1134.       sPDRow.i    = j
  1135.       sPDRec.i    = CENTER(' TOP OF DATA ',sGlobal.iCCMax,'*')
  1136.      end
  1137.     when j < sFlRecs.0 then
  1138.      do
  1139.       sPDRow.i    = j
  1140.       sPDRec.i    = SUBSTR(sFlRecs.j,sGlobal.iCCBeg,sGlobal.iCCMax,' ')
  1141.     /*sPDRec.i    = sFlRecs.j*/
  1142.      end
  1143.     when j = sFlRecs.0 then
  1144.      do
  1145.       sPDRow.i    = j
  1146.       sPDRec.i    = CENTER(' BOTTOM OF DATA ',sGlobal.iCCMax,'*')
  1147.      end
  1148.     otherwise
  1149.      do
  1150.       sPDRow.i    = j
  1151.       sPDRec.i    = ''
  1152.      end
  1153.    end /* select */
  1154.    j = j + 1
  1155.   end /* do i = 1 to sGlobal.iMaxRows */
  1156.   sGlobal.iNdx = iLNdx
  1157.   return 0;
  1158.  
  1159. /**********************************************************************\
  1160.  rLoadFileStem:
  1161.   This routine loads the file stem variable.
  1162. \**********************************************************************/
  1163. rLoadFileStem:
  1164.   Call Trace 'Off'
  1165.   DROP sFlRecs.
  1166.   i = 1
  1167.   sFlRecs.0 = i
  1168.   sFlRecs.i = ''
  1169.   if sFlSpec <> '' then
  1170.    do
  1171.     state = stream(sFlSpec,'c','query exists')
  1172.     if state <> '' then
  1173.      do
  1174.       rc = rOpenFlSpec(sFlSpec)
  1175.       if rc <> 0 then
  1176.        do
  1177.         sFlRecs.0 = 0
  1178.         return 8
  1179.        end
  1180.       do while 0 < LINES(sFlSpec)
  1181.        i = i + 1
  1182.        sFlRecs.i = LINEIN(sFlSpec)
  1183.       end /*do while 0 < LINES(sFlSpec)*/
  1184.       sFlRecs.0 = i
  1185.       rc = rCloseFlSpec(sFlSpec)
  1186.      end
  1187.    end
  1188.   i = i + 1
  1189.   sFlRecs.0 = i
  1190.   sFlRecs.i = ''
  1191.   return 0
  1192.  
  1193. /**********************************************************************\
  1194.  rStoreFileStem:
  1195.   This routine store the file stem variable.
  1196. \**********************************************************************/
  1197. rStoreFileStem:
  1198.   i = 1
  1199.   if sFlSpec = '' then
  1200.    do
  1201.     Call BEEP 882, 40
  1202.     return 4
  1203.    end
  1204.   rc = rOpenFlSpec(sFlSpec,'REPL')
  1205.   if rc <> 0 then
  1206.    do
  1207.     return 8
  1208.    end
  1209.   if sFlRecs.0 > 2 then
  1210.    do
  1211.     do i = 2 to sFlRecs.0 - 1
  1212.      Call rWriteFlSpec sFlSpec, sFlRecs.i
  1213.     end /*do i = 2 to sFlRecs.0 - 1 */
  1214.    end
  1215.   rc = rCloseFlSpec(sFlSpec)
  1216.   return 0
  1217.  
  1218. /**********************************************************************\
  1219.  rOpenFlSpec:
  1220.   This routine opens the TSD for output processing and inits the pointer
  1221. \**********************************************************************/
  1222. rOpenFlSpec:
  1223. parse arg sFlSpec, sRepl
  1224.   if TRANSLATE(sRepl) = 'REPL' then
  1225.    do
  1226.     rc = SysFileDelete(sFlSpec)
  1227.     if rc > 2 then
  1228.      do
  1229.       svid = rxPDSaveScreen(bid)
  1230.       rc = rxPDDisplay(bid,'PUPDELETEERR')
  1231.       rc = rxPDRestoreScreen(bid,svid)
  1232.       rc = rxPDTerm(bid)
  1233.       exit 256
  1234.      end
  1235.    end
  1236.   state = stream(sFlSpec,'c','open')
  1237.   if state <> 'READY:' then
  1238.    do
  1239.     svid = rxPDSaveScreen(bid)
  1240.     rc = rxPDDisplay(bid,'PUPOPENERR')
  1241.     rc = rxPDRestoreScreen(bid,svid)
  1242.     return 8
  1243.    end
  1244.   return 0
  1245.  
  1246. /**********************************************************************\
  1247.  rCloseFlSpec:
  1248.   This routine closes the TSD
  1249. \**********************************************************************/
  1250. rCloseFlSpec:
  1251. parse arg sFlSpec
  1252.   state = stream(sFlSpec,'c','close')
  1253.   return 0
  1254.  
  1255. /**********************************************************************\
  1256.  rWriteFlSpec:
  1257.   This routine sequentially writes the TSD
  1258. \**********************************************************************/
  1259. rWriteFlSpec:
  1260. parse arg sFlSpec, sRec
  1261.   err = lineout(sFlSpec,sRec)
  1262.   if err <> 0 then
  1263.    do
  1264.     svid = rxPDSaveScreen(bid)
  1265.     rc = rxPDDisplay(bid,'PUPWRITEERR')
  1266.     rc = rxPDRestoreScreen(bid,svid)
  1267.     rc = rxPDTerm(bid)
  1268.     exit 256
  1269.    end
  1270.   return 0
  1271.  
  1272. HaltExit:
  1273.   Call BEEP 882, 40
  1274.   Call BEEP 882, 40
  1275.   say 'PDEDIT processing halted by request;'
  1276.   exit 0
  1277.  
  1278. ErrorExit:
  1279.   Call BEEP 882, 40
  1280.   Call BEEP 882, 40
  1281.   say 'PDEDIT processing failed due to unknown error;'
  1282.   exit 24
  1283.  
  1284. FailureExit:
  1285.   Call BEEP 882, 40
  1286.   Call BEEP 882, 40
  1287.   say 'PDEDIT processing failed due to unknown failure;'
  1288.   exit 32
  1289.  
  1290. SyntaxExit:
  1291.   Call BEEP 882, 40
  1292.   Call BEEP 882, 40
  1293.   say 'PDEDIT processing failed due to syntax error;'
  1294.   exit 64
  1295.  
  1296. rParseParms:
  1297. parse arg p1
  1298.  
  1299.   do Forever
  1300.    w1 = word(p1,1)
  1301.    parse var w1 with "/" f1 ":" v1
  1302.    select
  1303.     when (w1 = '') then
  1304.      do
  1305.       return 0
  1306.      end
  1307.     when TRANSLATE(w1) = '/IRX' then
  1308.      do
  1309.       fIgnoreRXQ='Y'
  1310.       p1 = SUBWORD(p1,2)
  1311.      end
  1312.     when TRANSLATE(w1) = '/DEBUG' then
  1313.      do
  1314.       fDebug='Y'
  1315.       p1 = SUBWORD(p1,2)
  1316.      end
  1317.     when TRANSLATE(f1) = 'D' then
  1318.      do
  1319.       fDebug = TRANSLATE(v1)
  1320.       p1 = SUBWORD(p1,2)
  1321.      end
  1322.     when TRANSLATE(f1) = '?' then
  1323.      do
  1324.       fDispStax='Y'
  1325.       fDispHelp='N'
  1326.       p1 = SUBWORD(p1,2)
  1327.      end
  1328.     when TRANSLATE(f1) = 'H' then
  1329.      do
  1330.       fDispStax='N'
  1331.       fDispHelp='Y'
  1332.       p1 = SUBWORD(p1,2)
  1333.      end
  1334.     otherwise
  1335.      do
  1336.       select
  1337.        when fFlSpecQ <> 'Y' then
  1338.         do
  1339.          fFlSpecQ = 'Y'
  1340.          sFlSpec = w1
  1341.          p1 = SUBWORD(p1,2)
  1342.         end
  1343.        otherwise
  1344.         do
  1345.          Call rSiren 8, 1
  1346.          say 'PDEDIT - Too many parms specified; Parm "'w1'" unknown;'
  1347.          CALL rDispSyntax 0 8
  1348.         end
  1349.       end /* select */
  1350.      end
  1351.    end
  1352.   end
  1353.  
  1354.   return 0
  1355.  
  1356. rDispSyntax: Procedure
  1357. parse upper arg iHelp iExit
  1358.  
  1359.   say ' Syntax  : PDEDIT {<options>} {filespec}'
  1360.   say '           PDEDIT {/?|/h}'
  1361.   if iHelp > 0 then
  1362.    do
  1363.     CALL rDispHelp
  1364.    end
  1365.  
  1366.   exit iExit
  1367.  
  1368. rDispHelp: Procedure
  1369.  
  1370.   say ' Parms   : filespec   - File name to edit.'
  1371.   say ''
  1372.   say ' Options : /?         - Display command syntax.'
  1373.   say '           /h         - Display this help info.'
  1374.   say ' Examples:'
  1375.   say '    PDEDIT /h'
  1376.   say ' '
  1377.   say '    PDEDIT config.sys'
  1378.  
  1379.   return ''
  1380.  
  1381. /* rSiren: does the siren bit by running the scale based upon a       */
  1382. /*    frequency specified by the caller.                              */
  1383. rSiren: Procedure
  1384.    Parse Arg freq, cycle
  1385.    note.1 = 262 * freq /* middle C */
  1386.    note.2 = 294 * freq /* D */
  1387.    note.3 = 330 * freq /* E */
  1388.    note.4 = 349 * freq /* F */
  1389.    note.5 = 392 * freq /* G */
  1390.    note.6 = 440 * freq /* A */
  1391.    note.7 = 494 * freq /* B */
  1392.    note.8 = 524 * freq /* C */
  1393.    do j = 1 to cycle
  1394.     call beep note.8,250 /* hold each note for a 1/4 second */
  1395.     call beep note.1,250 /* hold each note for a 1/4 second */
  1396.    end j
  1397.    Return
  1398.  
  1399. rLoadFuncs:
  1400. parse arg sREP, sDll, sRtn
  1401.   rxrc = RxFuncAdd(sREP, sDll, sRtn)
  1402.   signal on syntax name xLoadFuncs
  1403.   interpret 'Call 'sRtn
  1404.   return 0
  1405.  
  1406. xLoadFuncs:
  1407.   return 127
  1408.