[fpc-pascal] Re: WORD (2 bytes) to String conversion

Graeme Geldenhuys graemeg.lists at gmail.com
Fri Oct 23 14:16:49 CEST 2009


2009/10/23 Graeme Geldenhuys <graemeg.lists at gmail.com>:
> Hi,
>
> I'm reading in a WORD (2 bytes) from a binary file. I can display the


As I pressed the Send button, I thought about trying the following.
And it worked!  But is this the best way of doing what I want?

type
  TWord = record
    b1: Char;
    b2: Char;
  end;

var
  w: TWord;
  s: string;
begin
  w := TWord(hdr^.ID);
  s := w.b1 + w.b2;
  writeln(s);
end;




-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-pascal mailing list