Converts a Boolean value to a string.
function BoolToStr(B: Boolean; UseBoolStrs: Boolean = False): string;
AnsiString BoolToStr(Boolean B, Boolean UseBoolStrs = False);
SysUtils
BoolToStr converts the given Boolean value to a string as follows:
Value of B |
Value of UseBoolStrs |
Value of returned string |
true |
false |
'-1' |
true |
true |
The first string in TrueBoolStrs (default 'True'); |
false |
false |
'0' |
false |
true |
The first string in FalseBoolStrs (default 'False'); |
C++ Examples:
/* This example requires that a memo and a TApplicationEvent be added to the form. Change the Windows Locale by using the Regional and Language Options in the Windows Control Panel. */ void __fastcall TForm1::ApplicationEvents1SettingChange(TObject *Sender, int Flag, const AnsiString Section, int &Result) { Memo1->Lines->BeginUpdate(); try { // char buffer[64]; AnsiString buffer; buffer.sprintf("Section = %s", Section.c_str()); Memo1->Lines->Add(buffer); buffer.sprintf("Flag = %8x", Flag); Memo1->Lines->Add(buffer); if (strcmp(Section.c_str(), "intl") == 0) { buffer.sprintf("DefaultLCID = %8x", SysLocale.DefaultLCID); Memo1->Lines->Add(buffer); buffer.sprintf("PriLangID = %8x", SysLocale.PriLangID); Memo1->Lines->Add(buffer); buffer.sprintf("SubLangID = %8x", SysLocale.SubLangID); Memo1->Lines->Add(buffer); buffer.sprintf("FarEast = %s", BoolToStr(SysLocale.FarEast, true)); Memo1->Lines->Add(buffer); buffer.sprintf("MiddleEast = %s", BoolToStr(SysLocale.MiddleEast, true)); Memo1->Lines->Add(buffer); Memo1->Lines->Add(""); } } __finally { Memo1->Lines->EndUpdate(); } }
Delphi Examples:
{ This example requires that a memo and a TApplicationEvent be added to the form. Change the Windows Locale by using the Regional and Language Options in the Windows Control Panel. } procedure TForm1.ApplicationEvents1SettingChange(Sender: TObject; Flag: Integer; const Section: string; var Result: Integer); begin Memo1.Lines.BeginUpdate; try Memo1.Lines.Add(Format('Section = %s', [Section])); Memo1.Lines.Add(Format('Flags = %.8x', [Flag])); if AnsiSameStr(Section, 'intl') then with SysLocale do begin Memo1.Lines.Add(Format('DefaultLCID = %.8x', [DefaultLCID])); Memo1.Lines.Add(Format('PriLangID = %.8x', [PriLangID])); Memo1.Lines.Add(Format('SubLangID = %.8x', [SubLangID])); Memo1.Lines.Add(Format('FarEast = %s', [BoolToStr(FarEast, True)])); Memo1.Lines.Add(Format('MiddleEast = %s', [BoolToStr(MiddleEast, True)])); end; Memo1.Lines.Add(''); finally Memo1.Lines.EndUpdate; end; // Result:= 0; end;
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|