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: Trying 2 Understand Get Command and Array
Topic Summary:
Created On: 8-Oct-2006 19:46
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 Pete Kowalski, on Sunday, October 8, 2006 8:12 PM

Answer:
Doh! I wish Telelogic spend more time in the future to beef up their documentation.

I figured out what I did after banging my head against the desk.

Array should be declared at least (1,1) such as below

quote:


int aNumber = 5
Array anArray = create(1,1)
put(anArray,aNumber,1,1)

int aSecondNumber = null
aSecondNumber = (int get(anArray,1,1))
print aSecondNumber

 8-Oct-2006 19:46
User is offline View Users Profile Print this message


Pete Kowalski

Posts: 301
Joined: 7-Feb-2003

Hi -

I wrote this small program, and I expect it to print 5 but instead it prints 0.

Can someone explain to me why?

Here is the code:

quote:


int aNumber = 5
Array anArray = create(0,1)
put(anArray,aNuber,0,1)

int aSecondNumber = null
aSecondNumber = (int get(anArray,0,1))
print aSecondNumber



Thanks,

-------------------------
pete.kowalski(at)motorola.com
Report this to a Moderator Report this to a Moderator
 8-Oct-2006 20:11
User is offline View Users Profile Print this message


Pete Kowalski

Posts: 301
Joined: 7-Feb-2003

Answer Answer
Doh! I wish Telelogic spend more time in the future to beef up their documentation.

I figured out what I did after banging my head against the desk.

Array should be declared at least (1,1) such as below

quote:


int aNumber = 5
Array anArray = create(1,1)
put(anArray,aNumber,1,1)

int aSecondNumber = null
aSecondNumber = (int get(anArray,1,1))
print aSecondNumber



-------------------------
pete.kowalski(at)motorola.com
Report this to a Moderator Report this to a Moderator
 9-Oct-2006 20:14
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

The documentation clearly says that the create command is just the initial size of the array. If you insert into a position that doesn't exist, that position is created.

I notice that your new script doesn't do it correctly either. Array indexing is origin zero. You create an array of size 1x1; well the coordinates of that position are 0x0. When you insert into position 1x1 then the array is now size of 2x2.

I notice in your original snippette that you spelled 'aNumber' as 'aNuber' in the 3rd line. Surprised that didn't give DXL errors but perhaps you have auto declare on.

- Louie
Report this to a Moderator Report this to a Moderator
 12-Oct-2006 22:46
User is offline View Users Profile Print this message


Pete Kowalski

Posts: 301
Joined: 7-Feb-2003

Louie,

Thanks for your tips again.

I swear there is a misprint in my Telelogic documentation. Once I find a scanner here I will post it just to prove to myself I don't need glasses.

With my original code, I mistyped the variable "aNumber" but corrected it in my second post. That is why no DXL error was generated, and I always have auto declare off. I learned the hard way.

Thanks again,

-------------------------
pete.kowalski(at)motorola.com
Report this to a Moderator Report this to a Moderator
 12-Oct-2006 23:25
User is offline View Users Profile Print this message


Iftakher Uddin

Posts: 56
Joined: 16-Sep-2004

instead of scanner you can use digital camera ;-) (just kidding....)

Once I was trying to extract the forum posts in order to create a handy searchable dxl documentation (specially for offline use)... sometimes I found forum explanation is better than dxl documentation... but I gave up!! :-(

greetings to all....

Rony
Report this to a Moderator Report this to a Moderator
 13-Oct-2006 02:58
User is offline View Users Profile Print this message


Pete Kowalski

Posts: 301
Joined: 7-Feb-2003

I second this.

OR, I look at other people's code to learn how it "should" be done.

-------------------------
pete.kowalski(at)motorola.com
Report this to a Moderator Report this to a Moderator
 13-Oct-2006 08:12
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

quote:

Originally posted by: Pete Kowalski
OR, I look at other people's code to learn how it "should" be done.


... make that 'could' or 'might successfully' and I'll agree!

A bit off topic, but...
Have you read Jack Ganssle's latest Muse (latest is 134, which isn't in the back-list yet)? He talks there about how one has to read loads of books for a literature major, or loads of manuscripts (music!) for a music major, but for a computing major, it's "Here's how a for loop works. Go write code". We should ALL be reading code to see how it 'could' be done.

Paul.

-------------------------


Paul dot Tiplady at TRW dot com
TRW Automotive
Report this to a Moderator Report this to a Moderator
 17-Oct-2006 00:01
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

More importantly ... we should all be WRITING code some someone ELSE can read it, so THEY can see how it 'could' be done. That notion seems to be missing from many modern languages and code that I've seen, where the language offers myriads of options to do the same thing, and coders gleefully see how cleverly they can code their modules with a view towards reducing the total number of lines and total number of bytes of code and increasing the apparent chaos of the code, making the code effectively write-only.

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