![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Saving a STRING value to a BOOL variable Topic Summary: Created On: 23-Aug-2007 22:42 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() Answer: I would guess you'll have to just check "by hand" with an if statement. Throw in an upper() for good measure..... string TRUE = "TRUE" string x = true bool b if(upper(x) == TRUE) b = true else b = false | |
![]() |
|
Hi --
How can I assign a string variable value to a bool variable? For example... string x = "true" bool b = x Any clues? Thanks, ------------------------- pete.kowalski(at)motorola.com |
|
![]() |
|
![]() |
|
I would guess you'll have to just check "by hand" with an if statement. Throw in an upper() for good measure.....
string TRUE = "TRUE" string x = true bool b if(upper(x) == TRUE) b = true else b = false |
|
![]() |
|
![]() |
|
Thank you very much, Chris.
Logic is very easy. I could swear there is a "hidden" DXL function that would do this as well. ------------------------- pete.kowalski(at)motorola.com |
|
![]() |
|
![]() |
|
Try this (it's quicker!):
string x = "true" // or "false" bool b = x == "true" Works for me - I use it when I recover a saved set of settings for a dialogue box (from a config file). I save the bools to the config file by writing them out as a string, which ends up with them being either "true" or "false" (always lower case). Paul. ------------------------- Paul dot Tiplady at TRW dot com TRW Automotive |
|
![]() |
|
![]() |
|
Even though Chris answered well, I think I'll post the attached function that I use. Its only redeeming characteristic is checking for length of string, which reduces memory leak in case the function is called with some huge value <such as bool IsTrue = fBoolOf(richTextWithOle(obj."Object Text"))>
- Louie |
|
![]() |
|
![]() |
|
But, if you retrieve a boolean attributes (such as 'IsRequired') it comes back as a string 'True' or 'False', not 'true' or 'false'. If you've imported from Excel they come in as 'TRUE' or 'FALSE' sometimes. That's why converting to upper case (or for me lower case) is needed: bool b = lower(x) == "true".
|
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Saving a STRING value to a BOOL variable
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.