Tapatalk

Simple Macros - Need a little help

Simple Macros - Need a little help

4

    Apr 07, 2005#1

    Hi

    I have a number of variables in the procedure division in a large number of cobol programs which I want to find and replace. Some of the variables are in one or more programs and some do not occur in a program.

    Sample

    Top
    OverStrikeMode
    ColumnModeOff
    HexOff
    UnixReOff
    Find "PROCEDURE DIVISION"
    Replace "PROCEDURE DIVISION"
    Find "'ACC_AGGRBITS'"
    Replace "'FPR3UP46' USING"
    Find "'ACC_AGGT_TPR_BITS'"
    Replace "'FPR3UP66' USING"
    Find "'ACC_AJSTBITS'"
    Replace "'FPR3UP47' USING"
    ....
    Several thousand other Find and Replace combinations
    ....
    Find "'ACC_BCFLATRATES'"
    Replace "'FPR3UP44' USING"

    I am using the first Find "PROCEDURE DIVISION" to establish the point in the code from which all other Find and Replaces should start from. I want each Find and Replace to stop their search once they hit end of file after having started from the "PROCEDURE DIVISION" point. I do not want them to loop to the top and come back down thru.

    If any Find does not find what it is looking for I want the rest to continue.

    Thanks
    Dave

    21
    Basic UserBasic User
    21

      Apr 10, 2005#2

      Manually open all you files into UE.
      Alter your macro as indicated below. With each playing of macro it will process one file.
      you can play the macro a bunch of times via clicking "macro" "play macro multiple times"

      the changes I'm proposing to your code are simply to find your "procedure division" select
      everything from there to end of file and cut. open in new file paste. We have just eliminated the
      hassle of worrying about changing items outside of procedure division. WE are now free to perform
      your replaces on a global basis (add the modifyer "all" to your code). when were done we "select all" and cut.
      When the macro CLOSES this tab UE will automatically take you back to original file exactly where we left off.
      We paste our newly changed code, save your file and close it. When this close occurs UE will take us to your
      next tab (file). We play our macro over and over until we have no more tabs (files) to process.

      FYI, Before you use your macro make sure you set the attribute to continue when item not found...
      click "macro" "edit macro" "modify" and set the checkbox "continue if find with replace not found"

      Enjoy.
      ===============


      Code: Select all

      
         Find "PROCEDURE DIVISION"
      StartSelect
      SelectToBottom
      Key Ctrl+END
      Cut
      NewFile
      Paste
         Replace ALL "PROCEDURE DIVISION"
         Find "'ACC_AGGRBITS'"
         Replace ALL  "'FPR3UP46' USING"
         Find "'ACC_AGGT_TPR_BITS'"
         Replace ALL  "'FPR3UP66' USING"
         Find "'ACC_AJSTBITS'"
         Replace ALL  "'FPR3UP47' USING"
         ....
         Several thousand other Find and Replace combinations
         ....
         Find "'ACC_BCFLATRATES'"
         Replace  ALL "'FPR3UP44' USING"
      SelectAll
      Cut
      CloseFile NoSave
      Paste
      Save
      CloseFile
      
      
      

      4

        Apr 11, 2005#3

        Hi

        Nice solution. Pretty well what I came up with by researching the various commands.

        I have run across a new issue which is a by-product of the replace operation.

        All of the replacement items I want to replace are between a Call and a End-Call.

        Ie.

        Call
        'ACC_AGGT_TPR_BITS' USING
        record1(data1)
        outrec2(rec2data)
        End-Call

        ...... a number of different statements ......

        Move 'ACC_AGGT_TPR_BITS' to report-field1


        The positions where the code is on the line will change depending on how the programmer wrote the code and the amount of spacing he used between commands.

        I end up doing a replace on the line with the Move statement because the variable 'ACC_AGGT_TPR_BITS' on this line also meets the Find condition. I only want to do replacements within the Call .... End-Call sections of code. I only want to change the variable name for the call to it's program name and to keep everything else inbetween the Call ... End-Call the same.

        Call
        'FPR3UP46' USING
        record1(data1)
        outrec2(rec2data)
        End-Call

        This part worked ok

        ...... a number of different statements ......

        Move 'FPR3UP46' to report-field1

        This part I did not want to change

        Any ideas....




        21
        Basic UserBasic User
        21

          Apr 12, 2005#4

          what your asking for is easy. Simply
          - search for "call"
          - search for "end call" while holding down shift key

          A search while shift key is held down causes you highlighted all the text between "call" and "end call" inclusive.

          do your replace and specify to UE to ONLY operate on the selected text.
          (what this means is for every replace command you got in your existing macro code you need to add the keyword "selecttext" to each one.

          By doing this techinque you will NOT be affecting items outside of your "call" "end call"


          Here is what that macro code would look like.

          Code: Select all

          
          Find "call"
          StartSelect
          StartSelect
          Find Select "end call"
          Find "oldstr"
          Replace All SelectText "newstr"