 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Nige Guest
|
Posted: Thu Dec 01, 2005 2:26 pm Post subject: Conversion Delphi / VB |
|
|
Hello.
Can anyone help me with the Dephi function below...
const CC_TIME = $3f;
procedure TvStripForm.AddTime(var sum: array of Byte; b: array of Byte);
var
i: Integer;
max_f: Integer;
begin
for i := Low(sum) to High(sum) do
Inc(sum[i], (b[i] and CC_TIME));
max_f := 25;
if ((b[3] and (not CC_TIME_)) = 192) then
max_f := 30;
if (sum[3] >= max_f) then begin
Dec(sum[3], max_f);
Inc(sum[2]);
end;
if (sum[2] >= 60) then begin // seconds
Dec(sum[2], 60);
Inc(sum[1]);
end;
if (sum[1] >= 60) then begin // minutes
Dec(sum[1], 60);
Inc(sum[0]);
end;
end;
I wan't to create the same function in Visual Basic, but Im struggling, as I
don't really know Delphi all that well. We dont intend to leave Delphi
behind, someone in our department wants to see if VB tackles the above
function, as he thinks it will be a much long winded away around..
personally I dont think it will.
Any help appreciated |
|
| Back to top |
|
 |
Terry Russell Guest
|
Posted: Fri Dec 02, 2005 1:47 am Post subject: Re: Conversion Delphi / VB |
|
|
"Nige" <nkarnold (AT) blueyonder (DOT) co.uk> wrote in message
news:Nkzjf.110669$Es4.109854 (AT) fe2 (DOT) news.blueyonder.co.uk...
| Quote: | Hello.
Can anyone help me with the Dephi function below...
const CC_TIME = $3f;
|
byte mask
| Quote: |
procedure TvStripForm.AddTime(var sum: array of Byte; b: array of Byte);
var
i: Integer;
max_f: Integer;
begin
for i := Low(sum) to High(sum) do
|
lowest index of s highest index of s
| Quote: | Inc(sum[i], (b[i] and CC_TIME));
|
logical and with mask of byte b[i]
add it to sum[i]
( there could probably be some sanity checks, or code assumes
these checks have been made at calling level
dunno why the dynamic arrays and indexes, the rest only operates on 4
bytes
that could pass as a native
)
| Quote: | max_f := 25;
if ((b[3] and (not CC_TIME_)) = 192) then
max_f := 30;
|
invert cc_time , logical and with byte b[3]
if it is same as byte 192 then max_f=25 otherwise no change
| Quote: |
if (sum[3] >= max_f) then begin
Dec(sum[3], max_f);
Inc(sum[2]);
end;
|
add with carry , ripple changes
| Quote: | if (sum[2] >= 60) then begin // seconds
Dec(sum[2], 60);
Inc(sum[1]);
end;
if (sum[1] >= 60) then begin // minutes
Dec(sum[1], 60);
Inc(sum[0]);
end;
end;
I wan't to create the same function in Visual Basic, but Im struggling, as
I
don't really know Delphi all that well. We dont intend to leave Delphi
behind, someone in our department wants to see if VB tackles the above
function, as he thinks it will be a much long winded away around..
personally I dont think it will.
|
What I know about VB is locked in a little mental rubber room
and classified never to be released.
probably not much difference, 'tis fairly simple code, basic even :-)
and not worth much when considering development environments,
they manage code layouts and debugging , not bit twiddling |
|
| Back to top |
|
 |
Erik Guest
|
Posted: Fri Dec 02, 2005 10:49 pm Post subject: Re: Conversion Delphi / VB |
|
|
Nige wrote:
| Quote: | Hello.
Can anyone help me with the Dephi function below...
const CC_TIME = $3f;
procedure TvStripForm.AddTime(var sum: array of Byte; b: array of Byte);
var
i: Integer;
max_f: Integer;
begin
for i := Low(sum) to High(sum) do
Inc(sum[i], (b[i] and CC_TIME));
max_f := 25;
if ((b[3] and (not CC_TIME_)) = 192) then
max_f := 30;
if (sum[3] >= max_f) then begin
Dec(sum[3], max_f);
Inc(sum[2]);
end;
if (sum[2] >= 60) then begin // seconds
Dec(sum[2], 60);
Inc(sum[1]);
end;
if (sum[1] >= 60) then begin // minutes
Dec(sum[1], 60);
Inc(sum[0]);
end;
end;
I wan't to create the same function in Visual Basic, but Im struggling, as I
don't really know Delphi all that well. We dont intend to leave Delphi
behind, someone in our department wants to see if VB tackles the above
function, as he thinks it will be a much long winded away around..
personally I dont think it will.
Any help appreciated
|
The best way to port Delphi to VB is to learn Delphi and let go
of VB. Let go, try to forget it existed once upon a time.
That's the best way. |
|
| Back to top |
|
 |
Erik Guest
|
Posted: Fri Dec 02, 2005 10:52 pm Post subject: Re: Conversion Delphi / VB |
|
|
Nige wrote:
| Quote: | someone in our department wants to see if VB tackles the above
function, as he thinks it will be a much long winded away around..
personally I dont think it will.
Any help appreciated
|
Ok, I figured it out.
Take a plastic garbage bag, sneak up behind this "someone"
and throw it over their head.
Hold till twitching stops.
Repeat if necessary.
Good luck, if you need help, I'll be glad to lend a hand.
Erik |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|