Create links with a very simply script

Hello,

I am not a very good user in DXL. And I'like to create links running a very simply script

Actually, I have 3 modules Module, A and Module B, and a likModule "verifies" .

  • In Module X, I have Object A, Object B, Object C, and a LinkModule "verifies"

  • In Module Y, I have Object 1, Object 2, Object 3

(I could know all the identifiers of objects)

I imagine the script like that :

(no declaration)
"For Object A in Module X, create a link in module "verifies" to object 1 in Module Y
For Object B in Module X, create a link in module "verifies" to object 2 in Module Y
For Object C in Module X, create a link in module "verifies" to object 3 in Module Y..."

I hope to complete my Object A,B,C and object 1,2,3 in Excel, then to create a script in TXT and after to paste the script in DXL to run it. So each line is one link.

Could you help me ?
Thank's
JM
JeanMi - Mon Jul 19 05:20:58 EDT 2010

Re: Create links with a very simply script
Mathias Mamsch - Mon Jul 19 09:03:11 EDT 2010

Actually I have a similar script, which I run in conjunction with some other scripts to do link manipulations on a very low level. A nice idea (at least I think so), is that you just copy/paste the links from excel into a DXL dialog, and from there the script processes them. This way you don't have to put together some weird DXL from your Excel all the time (been there, done that).

Unfortunately this script uses the set.inc for splitting up the strings (by newline for the lines and then all the values by tabs). One line in the Excel is to have the following format:

Source_Module_Path | Source_Absolute_Number | Source Baseline | Direction (IN or OUT) | link_module_path | target_module_path | target_Absolute_Number | target_Baseline

Baselines are not yet implemented. All you would need to do is to replace the Set type by a function that will split up a string into a string array. Unfortunately I have no time to do it right now. Maybe someone else wants to do it?

Regards, Mathias

#include <../lib/std/set.inc>
 
DB x = centered "Links paste pls"
 
DBE txt = text (x, "Paste the links:", "", 300,300,false) 
 
block x
release x
 
Set lines = split(get txt, "\n")
 
string sLine 
 
for sLine in getSkip lines do {
    print "Processing line:" sLine "\n"
    Set val = split(sLine, "\t")
    if (count val > 6) {
        string dir = val[4]
        
        if (dir == "IN") { print "skipping in link.\n"; continue }
    
        string sSrc = val[0]
        int iNrSrc = intOf realOf (val[1] string)
        
        string linkMod = val[5]
        
        string sDst = val[6]
        int iNrDst = intOf realOf (val[7] string)
        
        print "Drawing link from " sSrc " object " iNrSrc " to " sDst " object " iNrDst "\n"
        Module mSrc = edit (sSrc, true)
        Module mDst = read (sDst, true)
        
        if (null mSrc || null mDst) {
           print "we are module seriously hosed ...."
           print "Source:" sSrc "\n"
           print "Dest:" sDst "\n"
           continue
        }
        
        Object oSrc = object(iNrSrc, mSrc)
        Object oDst = object(iNrDst, mDst)
        if (null oSrc || null oDst) {
            print "we are seriously hosed ...."
        } else {
            if (!null linkMod) 
                oSrc -> linkMod -> oDst
            else
                oSrc -> oDst
        }
    }
}

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: Create links with a very simply script
JeanMi - Mon Jul 19 12:05:42 EDT 2010

I am sorry, actually, it was not what I expected.

In fact I don't want to export a file.

I'd like to know syntaxe of the link creation :

Object source -> string linkModuleName -> Object target

How to write that ? How to write this "Object source" and Object Target : Folder/Module name/ Id of the object source ??

string linkModuleName -> is my link module "verifies". That I have to use with http://.... ?

Thank's for your help

JM

Re: Create links with a very simply script
adevicq - Mon Jul 19 12:24:06 EDT 2010

JeanMi - Mon Jul 19 12:05:42 EDT 2010
I am sorry, actually, it was not what I expected.

In fact I don't want to export a file.

I'd like to know syntaxe of the link creation :

Object source -> string linkModuleName -> Object target

How to write that ? How to write this "Object source" and Object Target : Folder/Module name/ Id of the object source ??

string linkModuleName -> is my link module "verifies". That I have to use with http://.... ?

Thank's for your help

JM

Bonjour Jean-Michel,

To link two objects o1 and o2 through the link module "My Link Module", you must write the following instruction:
 

o1->"My Link Module"->o2

 


Assuming that o1 is the source of the link and o2 is the target.
Alain

 

Re: Create links with a very simply script
rmoskwa - Mon Jul 19 12:28:26 EDT 2010

I have done this manually using "Linking by attribute". Go into DOORS Help Contents and Index. Search for "Linking by attribute"(without the quotes), and read the "Linking by attribute" topic title. What you need to do is have the target ID in the source module as a Text attribute. If you have your links in Excel, you are almost there.

In an Excel file, you would have column headings (aka attributes) similar to:
ObjectIdentifier(X) ObjectText(X) ObjectIdentifier(Y) ObjectText(Y)
where each line (aka object) represents a link from X to Y.

What you would do is rename ObjectIdentifier(Y) to "Relates to" (without the quotes) and format that column as text. Rename the ObjectIdentifier(X) column to "Object Identifier" (without the quotes). Hide the other two columns so you only have the "Object Identifier" and "Relates to" columns. Save that as a tab separated text file. Rename it as <filename>.tsv, then do File->Import->Spreadsheet... in DOORS to update the existing object. Once you have the "Relates to" field imported as Text, you can use Link->Advanced->Link by Attribute.. in DOORS to link you Source to the Target using the Relates to attribute to control the linking.