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: 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
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.
Answer This question was answered by Chris Jones, on Thursday, August 23, 2007 11:15 PM

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
 23-Aug-2007 22:42
User is offline View Users Profile Print this message


Pete Kowalski

Posts: 301
Joined: 7-Feb-2003

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
Report this to a Moderator Report this to a Moderator
 23-Aug-2007 23:00
User is offline View Users Profile Print this message


Chris Jones

Posts: 177
Joined: 1-Jul-2005

Answer 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
Report this to a Moderator Report this to a Moderator
 23-Aug-2007 23:16
User is offline View Users Profile Print this message


Pete Kowalski

Posts: 301
Joined: 7-Feb-2003

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
Report this to a Moderator Report this to a Moderator
 24-Aug-2007 09:16
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

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
Report this to a Moderator Report this to a Moderator
 24-Aug-2007 18:26
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

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
Report this to a Moderator Report this to a Moderator
 27-Aug-2007 23:21
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

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".
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 2 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 2 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.