//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "SystemStrLCat.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: SysUtilsStrLCat
// Routine: SysUtils.StrLen
// Routine: SysUtils.StrLCat

// BeginCode
/*
The following example uses an edit control and a button on a
form in an application. When the button is clicked, the edit
control’s text is split in halves that are copied into
separate buffers. Then the contents of the buffers are
displayed in a message box.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  AnsiString EditText = AnsiString(Edit1->Text);
  char* szFirstHalf = new char[StrLen(EditText.c_str())/2+2];
  char* szSecondHalf = new char[StrLen(EditText.c_str())/2+2];
  char* pszSecondHalf = &EditText[StrLen(EditText.c_str())/2+1];

  *szFirstHalf = 0;
  *szSecondHalf = 0;

  StrLCat(szFirstHalf, EditText.c_str(), StrLen(EditText.c_str())/2);
  StrCat(szSecondHalf, pszSecondHalf);

  Application->MessageBox(WideString(szFirstHalf).c_bstr(), L"First Half", MB_OKCANCEL);
  Application->MessageBox(WideString(szSecondHalf).c_bstr(), L"Second Half", MB_OKCANCEL);

  delete [] szFirstHalf;
  delete [] szSecondHalf;
}
// EndCode
// EndExample: SysUtilsStrLCat
//---------------------------------------------------------------------------
