Recent

Author Topic: How do you convert LFM-to-PAS at runtime?  (Read 758 times)

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
How do you convert LFM-to-PAS at runtime?
« on: February 17, 2020, 07:45:21 pm »
There is this video on youtube https://www.youtube.com/watch?v=M250unH3Ltw that according to the uploader shows how convert the state of the form to a pascal file.

It isn't very clear according to thes mailing list thread https://lists.freepascal.org/pipermail/pas2js/2018-April/000182.html it uses  the TCompWriterPas class.

Does any one have working examples of the use of this class?
Lazarus 3.0/FPC 3.2.2

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: How do you convert LFM-to-PAS at runtime?
« Reply #1 on: February 17, 2020, 08:29:36 pm »
There is some code in the Lazarus sources at
$LazarusDir/components/codetools/tests/testcompreaderwriterpas.pas

eljo

  • Sr. Member
  • ****
  • Posts: 468
Re: How do you convert LFM-to-PAS at runtime?
« Reply #2 on: February 17, 2020, 08:54:50 pm »
Code: Pascal  [Select][+][-]
  1. uses CompWriterPas, ....
  2. procedure TForm1.MenuItem7Click(Sender: TObject) ;
  3. var
  4.   Strm:TFileStream;
  5. begin
  6.   if SaveDialog1.Execute then begin
  7.     Strm := TFileStream.Create(SaveDialog1.FileName,fmCreate or fmShareExclusive);
  8.     try
  9.       WriteComponentToPasStream(self, Strm);
  10.     finally
  11.       Strm.Free;
  12.     end ;
  13.   end;
  14. end;      
  15.  

dsiders

  • Hero Member
  • *****
  • Posts: 1084
Re: How do you convert LFM-to-PAS at runtime?
« Reply #3 on: February 17, 2020, 08:55:29 pm »
There is some code in the Lazarus sources at
$LazarusDir/components/codetools/tests/testcompreaderwriterpas.pas

And in:

examples/pascalstream/CopyAsPasPkg/copyaspasdemounit1.pas:
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

 

TinyPortal © 2005-2018