Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How do I convert Bytes to byte?


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Sep 1, 2016 8:19 AM Last Post By: Jorge Uriarte
Jorge Uriarte

Posts: 41
Registered: 11/28/14
How do I convert Bytes to byte?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 1, 2016 5:54 AM
Hi there,

I am working with a Bluetooth program, and here is the code:

LData: TBytes;

LData := FSocket.ReceiveData;

I am having problems using LData... I think I need to convert it to a regular byte so that I can do other operations with it.

Any help will be greatly appreciated,

Jorge
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: How do I convert Bytes to byte?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 1, 2016 7:25 AM   in response to: Jorge Uriarte in response to: Jorge Uriarte
Jorge Uriarte wrote:

Hi there,

I am working with a Bluetooth program, and here is the code:

LData: TBytes;

LData := FSocket.ReceiveData;

I am having problems using LData... I think I need to convert it to a
regular byte so that I can do other operations with it.

Any help will be greatly appreciated,

TBytes is an array of bytes where you can access the first byte using
LData[0].

For example to calculate the sum of the Tbytes you can write a function
(an example how to proccess the array):

function Sum(ABytes: TBytes): integer;
var i: integer;
begin
  result:=0;
  for i:=low(ABytes) to high(Abytes) do
    inc(result, ABytes[i]);
end;
Jorge Uriarte

Posts: 41
Registered: 11/28/14
Re: How do I convert Bytes to byte?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 1, 2016 8:19 AM   in response to: Lajos Juhasz in response to: Lajos Juhasz
Lajos, thank you!

Lajos Juhasz wrote:
Jorge Uriarte wrote:

Hi there,

I am working with a Bluetooth program, and here is the code:

LData: TBytes;

LData := FSocket.ReceiveData;

I am having problems using LData... I think I need to convert it to a
regular byte so that I can do other operations with it.

Any help will be greatly appreciated,

TBytes is an array of bytes where you can access the first byte using
LData[0].

For example to calculate the sum of the Tbytes you can write a function
(an example how to proccess the array):

function Sum(ABytes: TBytes): integer;
var i: integer;
begin
  result:=0;
  for i:=low(ABytes) to high(Abytes) do
    inc(result, ABytes[i]);
end;
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02