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: intOf(Date d) != (intOf(Date d))
Topic Summary: intOf(Date d) handling is inconsistent
Created On: 15-Sep-2005 18:55
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.
 15-Sep-2005 18:55
User is offline View Users Profile Print this message


Shawn Stepper

Posts: 96
Joined: 6-Aug-2004

When working with dates, intOf returns different string values, depending upon whether or not it has parentheses around it. See the example program below:

Date d = "04/28/05 15:39:05"
print intOf(d) "\n"
print (intOf(d)) "\n"

The output of this is:

4
1114727945

intOf(d) treats d as if it were a string
(intOf(d)) treats d as a date

This difference should be documented (or fixed? bug or feature?).

Note that this is in DOORS 7.1.

-------------------------
Shawn Stepper
shawn.e.stepper@wellsfargo.com
Report this to a Moderator Report this to a Moderator
 15-Sep-2005 19:43
User is offline View Users Profile Print this message


Michael Sutherland

Posts: 248
Joined: 13-Sep-2002

Shawn,

I consider it a flaw, and believe it should be fixed. The flaw seems to be in "binary op (concatenation)" for functions with integer return values.

Another example:

print random( 100 ) "\n"
print ( random( 100 ) ) "\n"

Results:

0.000009100 *wrong*
35 *correct*

The extra parenthesis typecasts the integer function correctly, and avoids the bug.

-------------------------
Michael Sutherland
michael@galactic-solutions.com
http://galactic-solutions.com
Report this to a Moderator Report this to a Moderator
 20-Sep-2005 21:43
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

I think its more restrictive than Sutherland suggests. This issue comes up when using the binary op inside some other function like "print" or "if".
Date d = "04/28/05 15:39:05"
int a =intOf(d)
int b = (intOf(d))
print a "\t" b "\n" // prints correctly and the same: 1114720745 1114720745

But yes, routinely use parenthesis when dealing with integer operations in call parameters.

- Louie
Report this to a Moderator Report this to a Moderator
 21-Sep-2005 13:46
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

Parentheses around the parameter to a single parameter function are not required and seem to be ignored by the interpreter. Hence the problem here is caused by the parameter being cast to a string by the concatenation of "\n".

The following is a well known feature:
If you run
print upper("hello") "world\n"

you might expect to get "HELLO world" as the output.

However, what you actually get is "HELLO WORLD". The string concatenation has higher precedence than the function call, so the string are concatenated before being passed to the function.

-------------------------
Tony Goodman
http://www.smartdxl.com
Report this to a Moderator Report this to a Moderator
 21-Sep-2005 19:52
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

I had thought the problem was localized to system built in functions. But confirming your observation:

string Upper(string InString)
{ return(upper(InString))
}

string Results = upper ("hello ") "world\n"
print "Print1\t" upper("hello ") "world\n"
print "Print2\t" (upper "hello ') "world\n"
print "upper\t" Results
Results = Upper("hello ") "world\n"
print "Upper\t" Results

Notice the 2nd print works. Use of both "upper" and "Upper" behave the same.

Sounds like we should initiate a trouble report suggesting that the interpreter does NOT ignore the parenthesis for single-parameter functions.

- Louie
Report this to a Moderator Report this to a Moderator
 30-Sep-2005 01:23
User is offline View Users Profile Print this message


Shawn Stepper

Posts: 96
Joined: 6-Aug-2004

Parentheses being ignored is a major problem. I didn't realize the problem was that bad!

print upper("hello") "world\n"

should DEFINITELY produce:

HELLO world

This also explains the problem that I initially reported. Expanding on my first post:

Date d = "04/28/05 15:39:05"
print intOf(d) "\n"
print intOf d "\n"
print intOf(d "\n")
print (intOf(d)) "\n"

Produces:

4
4
4
1114727945

The only reason [print (intOf(d)) "\n"] produces the correct result is because the extra () force precedence to be interpreted CORRECTLY. But they should not be necessary.

So, anyone from Telelogic reading this? This is a serious defect!

-------------------------
Shawn Stepper
shawn.e.stepper@wellsfargo.com

Edited: 30-Sep-2005 at 01:28 by Shawn Stepper
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.