🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #315

Re: Big Endian format Found conversion

#315
From: Kent
Date: Thu, 13 Oct 2005 20:42
55 lines
2433 bytes
"Kent" <Kent.White@att.net> wrote:
>
>I have an application written in Delphi that I am porting to 
>Java. In the delphi program I read in some real values in 
>BigEndian format. I then convert these to Windows real format 
>by using a variant record, which Java doesn't have, to swap
>bytes so that the proper format can be obtained. 
>
>How do I accomplish the same task in Java? Below is the code
>that swaps the proper bytes to get the value in the proper 
>format.
>
>type
>  realvar = record  // Note use of variant record which Java does not have.
>              case RealNum:byte of
>                1:(bytename: byte4);
>                2:(realname: single);
>            end;
>  WordVar = record
>              case WordNum:byte of
>                1:(ByteName: Byte2);
>                2:(WordName: Word);
>            end;
>
>// procedures
>function TSDIAppForm.Convert(ByteArray:single):single;
>var
>  temp : realvar;
>begin
>  temp.realname := ByteArray;
>  swap(temp.bytename[1], temp.bytename[4]);
>  swap(temp.bytename[2], temp.bytename[3]);
> try
>  begin
>    if temp.realname < 0 then
>      Convert := 0
>    else
>      Convert := temp.realname;
>  end
> except
>   on EInvalidOp do
>     Convert := 0;
> end;
>end; { of Convert }
>
>function TSDIAppForm.ConvertWord(Value : Word):Word;
>var
>  Temp : Wordvar;
>begin
>  Temp.wordName := Value;
>  Swap(temp.ByteName[1], Temp.ByteName[2]);
>  ConvertWord := Temp.WordName;
>end; { of ConvertWord }
>
Technical Details
Message-ID: <434ec6b0$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!pd7cy2so!pd7cy1no!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <434ec3ae$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,8a96fd610a68e12d
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Kent" <Kent.White@att.net>
Sender: "Kent" <Kent.White@att.net>
Reply-To: "Kent" <Kent.White@att.net>
Subject: Re: Big Endian format Found conversion
Newsgroups: borland.public.jbuilder.java.language
X-User-Info: 209.33.31.12     
References:  <434ec3ae$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <434ec6b0$1@newsgroups.borland.com>
Date: 13 Oct 2005 13:42:24 -0700
X-Trace: newsgroups.borland.com 1129236144 207.105.83.66 (13 Oct 2005 13:42:24 -0700)
Lines: 56
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!pd7cy2so!pd7cy1no!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail