Topic
  • 10 replies
  • Latest Post - ‏2013-07-02T17:17:00Z by llandale
a.mansoor
a.mansoor
3 Posts

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

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

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

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

    ‏2012-11-30T14:58:08Z  
    almost. You will need the "edit()" function to open the module in exclusive-edit mode.
    Thanks Mike,
  • kone1
    kone1
    1 Post

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

    ‏2013-06-27T14:58:13Z  

    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

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

    ‏2013-06-27T16:09:21Z  

    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

  • llandale
    llandale
    2986 Posts

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

    ‏2013-06-27T20:27:26Z  
    almost. You will need the "edit()" function to open the module in exclusive-edit mode.

    ... 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

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

    ‏2013-06-28T07:21:40Z  
    • llandale
    • ‏2013-06-27T20:27:26Z

    ... 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

    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
    2986 Posts

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

    ‏2013-06-28T20:20:28Z  
    • sekrbo
    • ‏2013-06-28T07:21:40Z

    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

     

    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

  • kone11
    kone11
    1 Post

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

    ‏2013-06-28T20:58:15Z  
    • adevicq
    • ‏2013-06-27T16:09:21Z

    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

    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

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

    ‏2013-07-01T07:28:19Z  
    • kone11
    • ‏2013-06-28T20:58:15Z

    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

    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
    2986 Posts

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

    ‏2013-07-02T17:17:00Z  
    • adevicq
    • ‏2013-07-01T07:28:19Z

    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

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