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

#include <vcl.h>
#pragma hdrstop

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

// BeginCode
/*
The following example uses two edit controls and a button on
a form. When the button is clicked, the text in the edit
controls is compared.
*/

#include <memory>       //for STL auto_ptr class

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  std::auto_ptr<char> szResult(new char[Edit1->Text.Length() + Edit2->Text.Length() + 20]);
  int iResult = StrComp(Edit1->Text.t_str(), Edit2->Text.t_str());
  StrCopy(szResult.get(), Edit1->Text.t_str());
  if (iResult < 0)
	StrCat(szResult.get(), " is less than ");
  else if (iResult > 0)
	StrCat(szResult.get(), " is greater than ");
  else
	StrCat(szResult.get(), " is equal to ");

  StrCat(szResult.get(), AnsiString(Edit2->Text).c_str());
  ShowMessage(AnsiString(szResult.get()));
}
// EndCode
// EndExample: StrComp
//---------------------------------------------------------------------------
