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: Creating new arrays and storing into skip
Topic Summary:
Created On: 1-Oct-2008 20:50
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.
 1-Oct-2008 20:50
User is offline View Users Profile Print this message


Olimipia Pospiech

Posts: 2
Joined: 4-Sep-2008

Hi all

I am pretty new in dxl and need your help. My problem is that I`d like to create a Skip containing 2 Strings, 1 Integer and 1 array.
Actually the array is the problem. I`ve created a method that shall put all the string the integer and the array into the list.

The problem is that the array I put into the skip each time I run my method contains the same values. It seems that the array is always the same and just a reference is put
into the skip. I need to create a new array (new reference) and put it in. Could it be possible that the same variable name, like that of my array (attributesArray) always references
the same memory register? Can someone give me a helping hand. Thank you in advance. Best regards. Olimpia

Condition.jpg
Condition.jpg  (67 KB)



Edited: 1-Oct-2008 at 20:52 by Olimipia Pospiech
Report this to a Moderator Report this to a Moderator
 1-Oct-2008 21:00
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

I believe you need to change definition of skip list to create instead of createString.
Report this to a Moderator Report this to a Moderator
 1-Oct-2008 21:10
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

I don't see how that would change what's happening with his array ron.

DXL is likely overwriting the previous array by putting it at the same memory address. I would suggest using another Skip list or a DXL Array. If you use a skip list, use create() to create it not createString. Then use an integer key so the elements will be kept in order. Just be sure to delete all of these skip lists or arrays when your program is done.

-------------------------
David Pechacek
AAI Services Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com
Report this to a Moderator Report this to a Moderator
 1-Oct-2008 21:21
User is offline View Users Profile Print this message


Olimipia Pospiech

Posts: 2
Joined: 4-Sep-2008

Hi Boys

Thanks you for the very fast answer. I didn`t expect it that fast. The way you suggested David, seems to be the best one. I will try that.

Best regards, Olimpia

Edited: 1-Oct-2008 at 21:23 by Olimipia Pospiech
Report this to a Moderator Report this to a Moderator
 2-Oct-2008 09:18
User is offline View Users Profile Print this message


Tony Goodman

Posts: 97
Joined: 6-May-2008

I would do this using an array type.

The following example is not working code, just an example of how it might work.

You have a row in the array for each profile. The index to the row would be the same as the integer key in your skip list.
Entries in the row are accessed using indices.
An attribute count allows you to count through the atribute values.

The advantage of this method is that you only need one data structure and that the array expands automatically, so you don't need to worry about creating stuff before inserting into the skip.

-------------------------
Tony Goodman
Smart DXL limited
www.smartdxl.com
Report this to a Moderator Report this to a Moderator
 2-Oct-2008 13:10
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

Tony the only reason I'm not a big fan of Arrays in DXL is that I've had issues with them that made no sense. I would put a string into an array and then get an error that crashed DOORS when I tried to take it out (yes into a string variable). Ever since my initial bad taste I've been wary about using them.

-------------------------
David Pechacek
AAI Services Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com
Report this to a Moderator Report this to a Moderator
 2-Oct-2008 13:46
User is offline View Users Profile Print this message


Paul Howstan

Posts: 47
Joined: 27-Sep-2006

David,

In my experience, that error is nearly always down to the string not being defined on the same line as the get statement. ie

String str = get(array, i, j)

is fine

String str
str = get(array, i, j)

is not as the DXL interpreter struggles to work out which variation of get to use (string get(), int get(), real get() etc...)

String str
str = (string get(array, i j))

is fine

Paul
Report this to a Moderator Report this to a Moderator
 2-Oct-2008 16:06
User is offline View Users Profile Print this message


Tony Goodman

Posts: 97
Joined: 6-May-2008

Yes, I always explicitly cast the value, just to be sure to be sure.

In fact, for a program with lots of array gets, I would use wrapper functions for example:

string getArrayValue(array arr, int x, int y)
{
return(string get(arr, x, y))
}

int getArrayValue(array arr, int x, int y)
{
return(int get(arr, x, y))
}

-------------------------
Tony Goodman
Smart DXL limited
www.smartdxl.com
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.