![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: wierd null string Topic Summary: Created On: 21-Jun-2006 18:17 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
Null isn't the same as a string with zero length.
Null occurs when a variable is declared but does not have a value. |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
//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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
wierd null string
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.