BytesOf (C++)
Description
This example demonstrates the use of BytesOf and WideBytesOf functions.
Code
Integer i;
TBytes ByteArray;
void __fastcall WriteBytes(TBytes BArray, TEdit* Edit)
{
for (i=0;i<BArray.Length;i++)
{
Edit->Text = Edit->Text + IntToStr(BArray[i]) + " ";
}
}
void __fastcall TMainForm::btGetBytesClick(TObject *Sender)
{
/* Convert the string into a byte array */
ByteArray = BytesOf(Edit1->Text);
/* Write the bytes in the second edit box */
WriteBytes(ByteArray, Edit2);
Edit1->Enabled = false;
btGetBytes->Enabled = false;
btGetWideBytes->Enabled = false;
}
void __fastcall TMainForm::btGetWideBytesClick(TObject *Sender)
{
/* Convert the string into a byte array, with two bytes per character */
ByteArray = WideBytesOf(Edit1->Text);
/* Write the bytes in the second edit box */
WriteBytes(ByteArray, Edit2);
Edit1->Enabled = false;
btGetBytes->Enabled = false;
btGetWideBytes->Enabled = false;
}
Uses
- Vcl.Controls.TControl.Enabled ( fr | de | ja )
- System.SysUtils.BytesOf ( fr | de | ja )
- System.SysUtils.WideBytesOf ( fr | de | ja )