🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.comp.borland-delphi
4 messages
4 total messages Started by Nige Thu, 01 Dec 2005 09:26
Conversion Delphi / VB
#893
Author: Nige
Date: Thu, 01 Dec 2005 09:26
39 lines
2272 bytes
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
Re: Conversion Delphi / VB
#894
Author: Terry Russell
Date: Thu, 01 Dec 2005 20:35
71 lines
3166 bytes
"Nige" <nkarnold@blueyonder.co.uk> wrote in message
news:Nkzjf.110669$Es4.109854@fe2.news.blueyonder.co.uk...
> Hello.
>
> Can anyone help me with the Dephi function below...
>
> const  CC_TIME = $3f;

byte mask

>
> 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

>     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
    )

>   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

>
>   if (sum[3] >= max_f) then begin
>     Dec(sum[3], max_f);
>     Inc(sum[2]);
>   end;

add with carry , ripple changes

>   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
Re: Conversion Delphi / VB
#895
Author: Erik
Date: Fri, 02 Dec 2005 17:49
49 lines
2502 bytes

Nige wrote:
> 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.
Re: Conversion Delphi / VB
#896
Author: Erik
Date: Fri, 02 Dec 2005 17:52
23 lines
1866 bytes

Nige wrote:

> 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads