Topic
  • 8 replies
  • Latest Post - ‏2014-04-03T10:49:59Z by KBSri
mwilliamson
mwilliamson
42 Posts

Pinned topic Copy module between folders

‏2010-06-16T16:15:21Z |
Hi,

Is anyone one aware of an undocumented feature to enable the copy of a module from one folder to another? I have no problem copying an existing module within the same folder and renaming, but need to copy a template module to another folder.

I've toyed with copying, renaming, moving and renaming again but this is extremely clumsy.

Mark
Updated on 2010-06-18T08:49:04Z at 2010-06-18T08:49:04Z by mwilliamson
  • llandale
    llandale
    3035 Posts

    Re: Copy module between folders

    ‏2010-06-17T01:36:57Z  
    You can copy it, change to the new folder, then paste it. Use the right-mouse click menu. You can also paste-special it as a way to 'clone' it.

    When you copy, you don't get Baselines and you don't get embedded Module Triggers. If you want an exact copy you should archive and restore it.

    • Louie
  • mwilliamson
    mwilliamson
    42 Posts

    Re: Copy module between folders

    ‏2010-06-17T06:58:36Z  
    • llandale
    • ‏2010-06-17T01:36:57Z
    You can copy it, change to the new folder, then paste it. Use the right-mouse click menu. You can also paste-special it as a way to 'clone' it.

    When you copy, you don't get Baselines and you don't get embedded Module Triggers. If you want an exact copy you should archive and restore it.

    • Louie
    Hi Louie,

    Thanks for the reply. I probably didn't explain myself very well. I know how to copy and paste / clone within the DOORS client. I need to carry out the same copy functionality using DXL. The scenario is that the user can create a new 'implementation' through a dialog box, providing the details to create a new 'implementation' folder at the appropriate place in the database. Once this is created, reference modules are copied to the new folder for further specification.

    I was just having an issue copying the reference modules in the dxl. I have since discovered clipCopy(Item) and clipPaste(Folder) and think that they may do the job once I've figured out how to specify the folder handle.

    Thanks

    Mark
  • llandale
    llandale
    3035 Posts

    Re: Copy module between folders

    ‏2010-06-17T15:59:30Z  
    Hi Louie,

    Thanks for the reply. I probably didn't explain myself very well. I know how to copy and paste / clone within the DOORS client. I need to carry out the same copy functionality using DXL. The scenario is that the user can create a new 'implementation' through a dialog box, providing the details to create a new 'implementation' folder at the appropriate place in the database. Once this is created, reference modules are copied to the new folder for further specification.

    I was just having an issue copying the reference modules in the dxl. I have since discovered clipCopy(Item) and clipPaste(Folder) and think that they may do the job once I've figured out how to specify the folder handle.

    Thanks

    Mark

    I don't seem to have an example of it, but

    ModName_ mnFrom = module(NameFromFull)
    string  Description = description(mnFrom)
    bool      OK      = copy(ModName_,string NameToBase, string Description)
    ModName  mnTo   = module(full name of NameToBase)
    string  ErrMess = move(ModName_,Folder)
    string  ErrMess = rename(ModName_,string NameToBase,string Description)
    


    These commands in that order should do it. Copy module "/MyProj/MyFolder/A" to "A1". Move module "/MyProj/MyFolder/A1" to destination Folder "/MyProj/MyOtherFolder". Rename "/MyProj/MyOtherFolder/A1" back to "A", preserving the Descrition of A1.

     

     

    • Louie

     

     

    Updated on 2013-12-19T18:42:17Z at 2013-12-19T18:42:17Z by iron-man
  • mwilliamson
    mwilliamson
    42 Posts

    Re: Copy module between folders

    ‏2010-06-17T16:17:30Z  
    • llandale
    • ‏2010-06-17T15:59:30Z

    I don't seem to have an example of it, but

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">ModName_ mnFrom = module(NameFromFull) string Description = description(mnFrom) bool OK = copy(ModName_,string NameToBase, string Description) ModName mnTo = module(full name of NameToBase) string ErrMess = move(ModName_,Folder) string ErrMess = rename(ModName_,string NameToBase,string Description) </pre>


    These commands in that order should do it. Copy module "/MyProj/MyFolder/A" to "A1". Move module "/MyProj/MyFolder/A1" to destination Folder "/MyProj/MyOtherFolder". Rename "/MyProj/MyOtherFolder/A1" back to "A", preserving the Descrition of A1.

     

     

    • Louie

     

     

    Hi Louie, I fixed it with the following code:

    void copyTemplates(Folder f)
    {
        string new = get(newImp)//get new folder name from dialog
            string x = "Parent folder location"
            string y = new
            string z = x y //concat parent and new folder for full path
            Item itemRef
            int i = 0
            for itemRef in (current Folder) do
            {     
                    i++          
                    clipCopy(itemRef)//copy reference modules. 
                    clipPaste( folder z ) //Paste in designated implementation folder
                    clipClear()           // Clear clipboard
            }
    }
    

     


    Many thanks for your replies.

    Mark

     

    Updated on 2013-12-19T18:43:04Z at 2013-12-19T18:43:04Z by iron-man
  • llandale
    llandale
    3035 Posts

    Re: Copy module between folders

    ‏2010-06-17T16:56:47Z  

    Hi Louie, I fixed it with the following code:

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">void copyTemplates(Folder f) { string new = get(newImp)//get new folder name from dialog string x = "Parent folder location" string y = new string z = x y //concat parent and new folder for full path Item itemRef int i = 0 for itemRef in (current Folder) do { i++ clipCopy(itemRef)//copy reference modules. clipPaste( folder z ) //Paste in designated implementation folder clipClear() // Clear clipboard } } </pre>

     


    Many thanks for your replies.

    Mark

     

    Let us know exactly what indeed gets copied using the Clipboard. Objects and Attributes and module/object attr values of course, but what about Baselines and Triggers and Views and outgoing links and all access rights?
  • mwilliamson
    mwilliamson
    42 Posts

    Re: Copy module between folders

    ‏2010-06-18T08:49:04Z  
    • llandale
    • ‏2010-06-17T16:56:47Z
    Let us know exactly what indeed gets copied using the Clipboard. Objects and Attributes and module/object attr values of course, but what about Baselines and Triggers and Views and outgoing links and all access rights?
    Louie,

    Views and access rights get copied but baselines don't. Not sure about triggers as I tend to avoid them wherever possible!

    Mark
  • ThomasD.
    ThomasD.
    1 Post

    Re: Copy module between folders

    ‏2014-03-20T18:51:41Z  
    • llandale
    • ‏2010-06-17T15:59:30Z

    I don't seem to have an example of it, but

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">ModName_ mnFrom = module(NameFromFull) string Description = description(mnFrom) bool OK = copy(ModName_,string NameToBase, string Description) ModName mnTo = module(full name of NameToBase) string ErrMess = move(ModName_,Folder) string ErrMess = rename(ModName_,string NameToBase,string Description) </pre>


    These commands in that order should do it. Copy module "/MyProj/MyFolder/A" to "A1". Move module "/MyProj/MyFolder/A1" to destination Folder "/MyProj/MyOtherFolder". Rename "/MyProj/MyOtherFolder/A1" back to "A", preserving the Descrition of A1.

     

     

    • Louie

     

     

    Hi Louie,

    What if the user doesn't have the right to create a module in the current Folder but only in the target Folder ?

    The only solution I have found so far (except Mark's solution with the clipboard) is to use a script from the Kitchen ("duplicate.dxl", which also uses other functions from other Kitchen files) and adapt it a little for my needs.

    FYI, that script creates an empty module at the target location, then copies every object from the old module depending on its absolute number, then moves every object using the "Object Number" information from the old module, and finally sets the correct level for every object, and I'm skipping the details about tables and deleted objects! As it appears it doesn't even copy module attributes nor views (these aspects can be easily fixed using other Kitchen functions, though).

    That seems pretty complicated compared to the "copy" function, therefore I just can't believe that there is no easier way than that... I guess the clipboard will be my friend for that matter if you don't know of any better solution...

    Thanks,

    Thomas

     

  • KBSri
    KBSri
    104 Posts

    Re: Copy module between folders

    ‏2014-04-03T10:49:59Z  

    Hi Louie, I fixed it with the following code:

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">void copyTemplates(Folder f) { string new = get(newImp)//get new folder name from dialog string x = "Parent folder location" string y = new string z = x y //concat parent and new folder for full path Item itemRef int i = 0 for itemRef in (current Folder) do { i++ clipCopy(itemRef)//copy reference modules. clipPaste( folder z ) //Paste in designated implementation folder clipClear() // Clear clipboard } } </pre>

     


    Many thanks for your replies.

    Mark

     

    Hello Mark,

    I tried the following code. But could not copy the module between the folders.

    Thanks & Regards.