Ok folks...

52 views
Skip to first unread message

joel...@gmail.com

unread,
Mar 8, 2006, 12:29:36 PM3/8/06
to Telelogic DOORS DXL
I have just been told to "get to know Doors" as part of my job. The
scripting language is giving me problems. Here is some dxl code that
has been dropped into my lap:

string ParaString (Object o) {
int n
string s, t
s = number o
if (matches("-",s)) {
s[match 0]
n = start 0
t = s[(n-2):n]
n = n - 1
if (t == ".0-")
n = n - 2
t = s[0:n]
} else
t = s
return t
}

In particular, this sequence is confusing:

s = number o
if (matches("-",s)) {
s[match 0]
n = start 0
t = s[(n-2):n]
n = n - 1
if (t == ".0-")
n = n - 2
t = s[0:n]

Why are they assigning a dash to the beginning to the module? Why are
they then stepping back two spaces to the beginning of the string?
Etc. I'm not understanding the "why" of what they are doing. And, of
course, there are no comments.

Second: What is wrong with this sequence?

Object o
Module m = current
Column c
int ccount=0
Column shallCol

//scans each column to see if we've made one for the shallID
for c in current Module do {
ccount++
if ((title c)=="Shall ID") {
(shallIDexists = true)
}
}
ccount++

//if shallID column hasn't been made, make it, set to 50 pixels, and
label it.
if !shallIDexists {

shallCol = insert(column ccount)
width (shallCol, 50)
title (shallCol, "Shall ID")
}

It keeps giving me a "Syntax error" for:

shallCol=insert(column ccount)

Here is the insert in the reference manual:


insert (column in module)

Declaration:
Column insert(Column c)

Operation:
Inserts a column, pushing subsequent columns one right. Returns a
handle to the new column. If a column is inserted at a new position, it
is important to initialize the width of the new column (see the width
(get) function).

Example:
This example inserts a new column 1 as a copy of the old column 1, if
present:

insert(column 1)


Some help?

Dave Knight

unread,
Mar 8, 2006, 6:35:11 PM3/8/06
to Telelogic DOORS DXL
This function takes an object, gets its heirachical number (i.e.
"2.4.3-0.1") and strips off the leading part. I'm not entirely sure of
why they are doing it this way since it appears the function simply
returns the first digit of the object's number. It also barfs on level
1 objects so they must be calling it on nested objects only. Doesn't
make sense though since getting the first character of the object
number can be done in one line of code.

A quick test is shown below.

Module m = current
Object obj
for obj in m do {
if ((level obj) > 1) {
print "Object level : " level obj "\n"
print "Object number: " number obj "\n"
print "ParaString : " ParaString(obj) "\n\n"
}
}


Object level : 2
Object number: 2.0-1
ParaString : 2

Object level : 4
Object number: 2.0-2.0-1.0-1
ParaString : 2

Object level : 3
Object number: 4.0-1.0-1
ParaString : 4

joel...@gmail.com wrote:
> I have just been told to "get to know Doors" as part of my job. The
> scripting language is giving me problems. Here is some dxl code that
> has been dropped into my lap:
>
> string ParaString (Object o) {
> int n
> string s, t
> s = number o
> if (matches("-",s)) {
> s[match 0]
> n = start 0
> t = s[(n-2):n]
> n = n - 1
> if (t == ".0-")
> n = n - 2
> t = s[0:n]
> } else
> t = s
> return t
> }
>

joel...@gmail.com

unread,
Mar 8, 2006, 7:45:04 PM3/8/06
to Telelogic DOORS DXL
Ok, figured this out, but still, the second one is kicking my *ss...

int ccount=2
Column shallCol

shallCol = insert(column ccount) //What is wrong with this statement?

Paul

unread,
Mar 9, 2006, 4:07:23 AM3/9/06
to Telelogic DOORS DXL
The problem is with the 'if' statement on the previous line. You should
have either:
if (!shallIDexists) {...
or
if !shallIDexists then {...

You will also need to declare and initialise shallIDexists:
bool shallIDexists = false

And you'll need to assign an attribute to the newly-created column:
attribute(shallCol, "Attribute Name")

joel...@gmail.com

unread,
Mar 9, 2006, 10:59:03 AM3/9/06
to Telelogic DOORS DXL
D'oh...

Thanks for all your help guys...I have a feeling I'll be asking a few
questions before I get the hang of this crazy scripting language...

Paul

unread,
Mar 9, 2006, 12:03:03 PM3/9/06
to Telelogic DOORS DXL
There's a more active DXL forum at support.telelogic.com

joel...@gmail.com

unread,
Mar 10, 2006, 10:55:06 AM3/10/06
to Telelogic DOORS DXL
Oh, I dunno...this one has been great so far. Good to know about other
resources though!

Thanks,

Joe

Reply all
Reply to author
Forward
0 new messages