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: wierd null string
Topic Summary:
Created On: 21-Jun-2006 18:17
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.
 21-Jun-2006 18:17
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

If seen this wierd bug ..err.. feature before. Run the attached DXL and confirm. It prints YES null and the end of the DXL is reached. Run it again and cancel: the field command aborts. The EnvVar variable seems to be "null", but the wrong 'kind' of null.

The culprit seems to be the function call to getenv in the first line (Environment variable abc doesn't exist).

There have been other times where I have to add this line of code to make it work:
if (null Value) Value = ""

Anybody know what's going on?

- Louie
Report this to a Moderator Report this to a Moderator
 22-Jun-2006 08:18
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

Very strange. I have seen this before and I also have had to insert the following fix to make code work:
if (null value) value = ""

I have a lot of functions that return a string value - empty for success, otherwise an error message. In all caes I use the empty string "", and never use null. When handling built-in functions that DO return null I have had to cast the result as above so the following works ok:
string res = myFunction()
if (res != "") report error

I have no idea why this makes any difference, but for string variables, null is obviously NOT the same as "".

In your example, the field will accept "" or null as values for EnvVar when set explicitly, but as you say the value returned by getenv() does seem different in some way. Besides, null is a valid value for a string variable isn't it?

The print function accepts it ok, but other functions don't seem to.
Adding an empty string to the parameter fixes the problem (this effectively does the same as the fix above), but this still worries me.

Have you sent this to the support guys?

-------------------------
Tony Goodman
http://www.smartdxl.com

Edited: 22-Jun-2006 at 08:22 by Tony Goodman
Report this to a Moderator Report this to a Moderator
 22-Jun-2006 17:26
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

Null isn't the same as a string with zero length.

Null occurs when a variable is declared but does not have a value.
Report this to a Moderator Report this to a Moderator
 23-Jun-2006 15:05
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

No. Not defined is when you declare a variable; null is an actual value. Run the attached DXL, if you cancel the first time the print statement generates an error; if you confirm the 2nd time there is no error.

string Empty
if (confirm("Set Empty to null?")) Empty = null
print "<" Empty ">\n"

It appears that setting a string to null is sometimes not the same as setting it to an empty string "".

- Louie
Report this to a Moderator Report this to a Moderator
 23-Jun-2006 15:35
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

//Help files says DXL has a null constant: The constant null is used as a polymorphic value to indicate a null value.
//Below the first if work because of a null constant
// the 2nd if doesn't work because ZeroLength is Undefined


string EmptyNull =null
string ZeroLength=""

if (EmptyNull==ZeroLength) print "< Empty==ZeroLength >\n" //Work because EmptyNull is assigned to null constant.

string Undefined
if (Undefined==ZeroLength) print "< Undefined==ZeroLength >\n" //Gives error because Undefined is undefined
Report this to a Moderator Report this to a Moderator
 23-Jun-2006 16:19
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

I don't think we're communicating.

Your original statements:
[1] Null isn't the same as a string with zero length.
[2] Null occurs when a variable is declared but does not have a value.

Your demo shows that 'null' is not the same as undefined (you can print a null string but get DXL errors when you try to use an undefined string) contradicting [2]; and provides some evidence that 'null' is the same as a string with zero length, at least as far as the print statement is conserned, somewhat contradicting [1]. My DXL supports your [1]; we found a case when null isn't the same as a string with zero length "".

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