Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Problem with parent(Object o) function
Topic Summary:
Created On: 27-Mar-2008 08:10
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by Guillaume Rosetti, on Thursday, March 27, 2008 1:07 PM

Answer:
Kevin,

Thanks for your explanations. I followed your suggestions and I found my (huge) error.
I created an object named "parent", so it was in conflict with the parent function.

I am sorry to have polluted this forum with this stupid error, but I am an inexperienced trainee...
 27-Mar-2008 08:10
User is offline View Users Profile Print this message


Guillaume Rosetti

Posts: 13
Joined: 4-Mar-2008

Hello

I have a problem with the parent(Object o) function and I don't understand why.

I just want to get the parent object of an object defined as a link target but when I want to run this script, an "incorrectly concatenated tokens" compilation error occurs.

Maybe the error comes from the fact that I call twice the target(lnk) function, first to get the target module name, and then to get the target object ?

Thank you for your answers


Guillaume Rosetti
Report this to a Moderator Report this to a Moderator
 27-Mar-2008 12:02
User is offline View Users Profile Print this message


Kevin Murphy

Posts: 120
Joined: 16-Jan-2008

Guillaume,

Ignore my first response to this--it's early in the morning here so I edited myself after the fact.

One thing I would do is find the level of the target object, and if it isn't 1, then invoke the parent call.

Your code is very specific, so I couldn't run a quick test. But the fact that you call the target() function for different types is not causing the problem.

"Incorrectly Concatenated Tokens" almost always means "syntax error"...try commenting out some other lines and you should be able to find the problem.

-------------------------
Kevin Murphy
http://www.baselinesinc.com

Edited: 27-Mar-2008 at 12:11 by Kevin Murphy
Report this to a Moderator Report this to a Moderator
 27-Mar-2008 12:15
User is offline View Users Profile Print this message


Kevin Murphy

Posts: 120
Joined: 16-Jan-2008

Another quick look shows this line:

if (getParentProject(mn) != current Project && path(mn) != "/DXL Common Files")

You need more parenthesis.

if ((getParentProject(mn) != current Project ) && (path(mn) != "/DXL Common Files"))

If this doesn't solve the "parent" error I'd be surprised, but if it doesn't, try removing everything except closing brackets after the parent statement. This will narrow down your problem considerably.

The DXL Interaction Window does not always give the correct line of the error, especially if there is an if statement involved. That's what I think is going on here.

-------------------------
Kevin Murphy
http://www.baselinesinc.com
Report this to a Moderator Report this to a Moderator
 27-Mar-2008 13:07
User is offline View Users Profile Print this message


Guillaume Rosetti

Posts: 13
Joined: 4-Mar-2008

Answer Answer
Kevin,

Thanks for your explanations. I followed your suggestions and I found my (huge) error.
I created an object named "parent", so it was in conflict with the parent function.

I am sorry to have polluted this forum with this stupid error, but I am an inexperienced trainee...
Report this to a Moderator Report this to a Moderator
 27-Mar-2008 13:12
User is offline View Users Profile Print this message


Kevin Murphy

Posts: 120
Joined: 16-Jan-2008

Don't worry about it...it would have taken you longer to get help if you didn't write about your "stupid error" here. Besides, I made a stupid error when I responded to you the very first time.

-------------------------
Kevin Murphy
http://www.baselinesinc.com
Report this to a Moderator Report this to a Moderator
 27-Mar-2008 18:08
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Would like to know what "created an object called 'parent'" means. Do you mean you created a function called 'parent' that took an object parameter.

Your 'parent' statement presumes that MLF_obj has a valid value. Well, it won't be valid unless the target module is open, which by your code is not guaranteed. I also suspect you won't get a Handle on it if you lack 'R' rights to it. See [3] below to open the module, THEN get the object handle. Even so, its wise to put in a check [if (null MLF_obj) continue] to make such scripts more bullet proof.

Anyway, looking at your code I see some flaws:
[1] Don't use 'current object' unless you are DEAD sure you have set the current. Your link loops should routinely use an Object variable, which perhaps the caller can set to Current.

[2] If you only care about links to a single particular module, you can use the 'string target(Link)' perm which sadly returns only the base name of the module. You could check that base name with a hard coded base name in the script.

[3] target_module_name is a poor label for a ModName_ handle. Anyway, once you figure out its not open you should open it: MFL = read(fullName target_module_name), false), instead of hard coding the module you want.

[4] I notice you don't check the sizeof the 'proj' array before you insert a new value into it. Perhaps you should use a Skip list intead of an array; using the 'mpm' as the 'Key' index.

[5] I notice that function parameter 'mpn' isn't used. I notice 'nbproj' isn't defined nor initialized. No doubt 'npproj' should be renamed 'mpn'.

- Louie
Report this to a Moderator Report this to a Moderator
 28-Mar-2008 09:04
User is offline View Users Profile Print this message


Guillaume Rosetti

Posts: 13
Joined: 4-Mar-2008

Louie,

Thanks for your help. I have tried to correct my code according to your recommendations.

First I clarify what I meant with "created an object called 'parent'". It was just an object declaration like that : Object parent = current Object. So I used a name for an object already used for a native DXL function.

About access rights and MFL_obj existence check, I think there is no problem because everybody has at least a read access to the concerned module. So I think the module will always be opened, and the MFL_obj will always exist.

About your remarks on my code,

[1] I have changed 'current Object' in my loop by an object defined at the script beginning which receives the current object. Here I'm dead sure it is the good object, because this script runs on an item in the right click menu, which is always launched from the current object.

[2] I think I can not use the 'string target(Link)' function. For the first loop because I have to test if the module is open and this function requires a ModuleName_. For the second loop because I search several modules which have the same name, so I need their project name to make the difference between them.

[3] I have replaced the module hard name by your suggestion.

[4] I have constructed the array in another function with a length always grater than the number of objects I will put in it. I think I can not use a skip list, because I use this array to create a multiList, which requires a string array in parameter.

[5] I forgot to remove the 'mpn' parameter which was not useful anymore.

I have reorganized my code according to your suggestions, and putting the "parent" problem in the createBox method. Now it works well.

Thanks for all !

Guillaume
Report this to a Moderator Report this to a Moderator
 28-Mar-2008 19:09
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

I don't thinking declaring "Object parent = current" will interfere with later use of the "Object parent(Object)" function, but sheesh, lets not point unloaded guns. Don't use variables the same name as functions. CORRECTION: just tried it, yes it WILL interfere; am getting DXL interprete errors when I do that.

The way your code was originally written, MFL_obj is NOT guranteed, since the link might be in an unopen module other than the hard-coded '/DXL Common Files/MFL' module, the only one the original script will open. In any case, bullet-proofing the code with a check for null should be routine.

[2] well, that's the only use of that string(target(lnk)) perm I can think of. Guess you cannot use it.

[4] Check for array out of bounds. Again, bullet-proof the code to avoid calls from irate customers 2 years from now.

[5] What about 'nbproj'? You should be getting run-time errors, unless its declared and initialized somewhere outside this code.

- Louie
Report this to a Moderator Report this to a Moderator
 2-Apr-2008 08:46
User is offline View Users Profile Print this message


Guillaume Rosetti

Posts: 13
Joined: 4-Mar-2008

Thanks for your suggestions Louie.

Now I have no problems anymore.

In the future I will take care not to declare a variable with the same name as a DXL function !

For your information, I have initialized the array size to the number of projects in the entire database. That will consequently always be greater that the length I need and will be a reasonable length too. About "nbproj", you can see in the previous code that it is correctly declared and initialized to 0 at the beginning.

Thanks again

Guillaume
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.