Delphi - read a Hex value in a text file and put it in a LongWord -


i need little project. have text file called script.txt, inside of it,i have:

 0000fca2:fa2c 0000bc8d:f21c 

i need put '$0000fca2' in longword called "address". , put '$fa2c' in longword called "hexvalue". and, in second line have same. '$0000bc8d' in longword called "address2" , first, ihave put '$f21c' in "hexvalue2" longword. how can it?

sorry, i'm begun delphi last week, have many doubts. googled question don't find answer it. , sorry wrong sentences, english isn't first language.

thanks much!

you create own lass reading , parsing file:

uses   system.generics.collections;  type   tdataline = class   private     fhexvalue: longword;     faddress2: longword;   public     constructor create(const aline: string);     property hexvalue: longword read fhexvalue;     property address2: longword read faddress2;   end;    tdatafile = class(tobjectlist<tdataline>)   public     constructor create; reintroduce;     procedure loadfromfile(const afliename: string);   end;    { tdataline }  constructor tdataline.create(const aline: string); var   buffer: tarray<string>;   tmp: int64; begin   buffer := aline.split([':'], tstringsplitoptions.excludeempty);   if trystrtoint64('$' + buffer[0], tmp)     fhexvalue := tmp;    if trystrtoint64('$' + buffer[1], tmp)     faddress2 := tmp; end;  { tdatafile }  constructor tdatafile.create; begin   inherited create(true); end;  procedure tdatafile.loadfromfile(const afliename: string); var   dataline: tdataline;   buffer: tstringlist;   sline: string; begin   buffer := tstringlist.create;   try     buffer.loadfromfile(afliename);     sline in buffer       add(tdataline.create(sline));       freeandnil(buffer);   end;     end; 

then call this:

procedure tform19.formcreate(sender: tobject); var   datafile: tdatafile; begin   datafile := tdatafile.create;   datafile.loadfromfile('data.txt');   caption := datafile.count.tostring;   datafile.free; end; 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -