How to convert bit to boolean

How to convert bit to boolean

  

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?

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


Hi Michael,


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


Cheers,

João

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

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.


Hi Kilian,


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