Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
10 replies Latest Post - ‏2013-07-02T17:17:00Z by llandale
a.mansoor
a.mansoor
3 Posts
ACCEPTED ANSWER

Pinned topic DXL Script to open multiple modules and do a search and replace

‏2012-11-30T00:22:12Z |
Hi All,

I am trying to create a DXL script that will open multiple modules do modifications to each module (find and replace) and then close all the modules.

To open a module I plan to use the read() function call then do the find and replace on the open module then close it and then open the next module using read()

I will not use the built in DOORS search and replace because that opens the Search and replace dialogue which requires user input, whereas I want the search and replace item to be programmatically inserted before the DXL script is done. I am using a function posted here on the forum to do the search and replace on each object.

Does this sound right?
Updated on 2012-11-30T14:58:08Z at 2012-11-30T14:58:08Z by a.mansoor
  • SystemAdmin
    SystemAdmin
    3180 Posts
    ACCEPTED ANSWER

    Re: DXL Script to open multiple modules and do a search and replace

    ‏2012-11-30T06:45:59Z  in response to a.mansoor
    almost. You will need the "edit()" function to open the module in exclusive-edit mode.
    • a.mansoor
      a.mansoor
      3 Posts
      ACCEPTED ANSWER

      Re: DXL Script to open multiple modules and do a search and replace

      ‏2012-11-30T14:58:08Z  in response to SystemAdmin
      Thanks Mike,
    • llandale
      llandale
      2943 Posts
      ACCEPTED ANSWER

      Re: DXL Script to open multiple modules and do a search and replace

      ‏2013-06-27T20:27:26Z  in response to SystemAdmin

      ... should routinely [1] open invisibly, [2] do not prompt when someone else has it open, and [3] load the standard view:

      • Module mod = edit(NameModule, false, true, true)
      • if (null mod) then either you lack edit rights or someone else has it opened shared/edit.

      -Louie

      • sekrbo
        sekrbo
        41 Posts
        ACCEPTED ANSWER

        Re: DXL Script to open multiple modules and do a search and replace

        ‏2013-06-28T07:21:40Z  in response to llandale

        I was thinking... How about

        [1] open in read-only

        [2] set a filter attr1 contains string1 (or what ever you're looking for) -> Let DOORS do the work :)

        [3] if display set == empty close and take next module

        [4] open in edit

        [5] if not able to edit log module name to a file to fix later and take next module

        [6] for each object in display set replace

        [7] save and close

        [8] next module

        /sekrbo

         

        • llandale
          llandale
          2943 Posts
          ACCEPTED ANSWER

          Re: DXL Script to open multiple modules and do a search and replace

          ‏2013-06-28T20:20:28Z  in response to sekrbo

          I don't see the benefit of first opening read.  Buf it you feel the need to report that a module has needed changes but cannot be open edit; then perhaps you can do this:

          • Open Edit
          • if edit failed then open Read
          • set filter
          • if not empty results
            • for each objectin display
              • If isEdit then make the change
              • count the change
            • report count of changes, and whether changes were actually made (isEdit)
            • if (isEdit) save
          • else report no changes needed
          • close

          -Louie

  • kone1
    kone1
    1 Post
    ACCEPTED ANSWER

    Re: DXL Script to open multiple modules and do a search and replace

    ‏2013-06-27T14:58:13Z  in response to a.mansoor

    Hi, Do you recall where you found that search function you mentioned that doesn't require the search and replace dialogue? Thanks

  • adevicq
    adevicq
    154 Posts
    ACCEPTED ANSWER

    Re: DXL Script to open multiple modules and do a search and replace

    ‏2013-06-27T16:09:21Z  in response to a.mansoor

    Hi,

    I have created something that works on all modules of a project / folder. See attached zip.

    It works in two modes: simple find and find / replace. It searches int all kinds of attributes including DXL attributes.

    There is an include and a main DXL file. Change the include location in the DXL.

    A log file is created in yout "temp" directory.

    Tell me if it helps...

    Regards,

    Alain

    Attachments

    • kone11
      kone11
      1 Post
      ACCEPTED ANSWER

      Re: DXL Script to open multiple modules and do a search and replace

      ‏2013-06-28T20:58:15Z  in response to adevicq

      Thanks for the reply adevicq, however your code is really hard for me to understand because there are little to no comments.  Do you hapen to know 

      when Object o = object(5) instead of searching for the fifth element down.. how to make that search for a particular string of text? for example

      In the ID column, i have:

      Blue_shoe

      Red_shoe

      Green_shoe

      if i use the function Object o = object 2) then I will receive the output of Red_shoe.. what I am looking to do however is to search for the text Red_shoe.. so I assummed something like Object o = object ("Red_shoe") but that doesn't work.. Anyone have any ideas? Thanks so much

      • adevicq
        adevicq
        154 Posts
        ACCEPTED ANSWER

        Re: DXL Script to open multiple modules and do a search and replace

        ‏2013-07-01T07:28:19Z  in response to kone11

        Hi

        I agree: there may be more comments... I can add some if needed.

        FWI, object(i) will return the object wich identifier (number) is "i". therefore, object(5) returns object #5 according to the ids given by DOORS.

        Regards

        • llandale
          llandale
          2943 Posts
          ACCEPTED ANSWER

          Re: DXL Script to open multiple modules and do a search and replace

          ‏2013-07-02T17:17:00Z  in response to adevicq

          Object o = object(i)  ... so long as that object is accepted in the current view.