Boolean to String Formatting

Prev Next

Introduction

Some powerful formatting features are available for formatting booleans.

The formatting template applies to following functions:

  • str(), 2nd parameter

Formatting Templates

Formatting Template Description Example Note
T / t True/False: 1st letter only T, F / t, f 1
TT / Tt / tt True/False: Full word TRUE, FALSE / True, False / true / false 1
Y / y Yes/No: 1st letter only Y, N / y, n 1
YY / Yy / yy Yes/No: Full word YES, NO / Yes, No / yes, no 1
# Numeric value: 1 for true, 0 for false 1, 0
' ... ' Contents inside quotation marks are treated as given text, including spaces "o'clock" See 3
" ... " See above 'time: ' See 3
All other characters Treated as given text

1 Uses the language as confgured by locale parameter or setting.
2 Applicable outside double quotation marks, otherwise symbols are treated as given text
3 Applicable outside single quotation marks, otherwise symbols are treated as given text

Locales

Specify a supported locale name, a country name or a language name. See locales for an overview of supported locales. Choices are not case sensitive.

Examples: en_US, DE_at, France, German, local, none

Program Examples

Following examples show use of date to string conversion without formatting template

               for all ( { en_us, de_de, fr_fr }, locale[] )
               {
                       print( str(true, "Tt Yy # ", locale[]),"   " );
                       echo( str(false, "TT y # ", locale[]) );
               }
True Yes 1    FALSE n 0
Wahr Ja 1    FALSCH n 0
Vrai Oui 1    FAUX n 0
Try it yourself: Open LIB_Features_boolean_to_string_conversion_and_formatting.b4p in B4P_Examples.zip. Decompress before use.