728
Views
5
Comments
How to convert bit to boolean
Question

I am uploading an excel sheet and converting it to a record list. The excel sheet contains a bit that represents true or false. How can I convert the bit to a boolean using OutSystems before I save it to the database?


Does OutSystems not have a bit data type?

2021-03-05 13-56-11
Ricardo Pereira
 
MVP

Hi Michael,

You can include that bit in an If clause. If(**** = 1,True,False) or If(**** = 0,True,False). This IF you can put in the assign.


It's that that you need?


Best regards,

Ricardo


2018-10-29 08-31-03
João Marques
 
MVP

Hi Michael,


You can simply put in the assign <Variable> = 1.


Cheers,

João

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

HI Michael,

Excel sheets don't contain "bits" in the traditional sense. An Excel sheet contains cells with values, each value internally represented by, as far as we are concerned, a black box. Excel certainly doesn't store its booleans as a single bit!

If the Excel file contains an Excel boolean (so shows up as non-text TRUE or FALSE), conversion to an OutSystems Boolean Attribute will be automatic. If the Excel file contains another type of value (e.g. Integer 0/1 or Text), you need to add an Attribute of that specific type, and convert it after uploading using a For Each to loop over the list and perform whatever conversion is needed.

@Ricardo: Never ever ever use True/False as value in an If. It's superfluous and ugly. "Variable = 1" is fully equal to "If(Variable = 1, True, False)". You don't need that If, and the code will be cleaner and easier to read! (I think that's also what João means to say, albeit he addresses Michael directly.)

2018-10-29 08-31-03
João Marques
 
MVP

Kilian Hekhuis wrote:

HI Michael,

Excel sheets don't contain "bits" in the traditional sense. An Excel sheet contains cells with values, each value internally represented by, as far as we are concerned, a black box. Excel certainly doesn't store its booleans as a single bit!

If the Excel file contains an Excel boolean (so shows up as non-text TRUE or FALSE), conversion to an OutSystems Boolean Attribute will be automatic. If the Excel file contains another type of value (e.g. Integer 0/1 or Text), you need to add an Attribute of that specific type, and convert it after uploading using a For Each to loop over the list and perform whatever conversion is needed.

@Ricardo: Never ever ever use True/False as value in an If. It's superfluous and ugly. "Variable = 1" is fully equal to "If(Variable = 1, True, False)". You don't need that If, and the code will be cleaner and easier to read! (I think that's also what João means to say, albeit he addresses Michael directly.)

Yes, Killian, indeed that's what I meant.


2021-03-05 13-56-11
Ricardo Pereira
 
MVP

Hi Kilian,


God point, you're right! Always learning! ;)

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.