Recent

Author Topic: Creating a project with forms from other projects  (Read 576 times)

CarmichaelJohn

  • New Member
  • *
  • Posts: 46
Creating a project with forms from other projects
« on: March 14, 2023, 11:38:42 am »
Hello,
I am trying to create a new project with forms I have modified from older existing projects.  I created a new file directory for the new project and saved the existing form into the new directory using “save as” and giving it a new name.  Lazarus then asked me if I wanted to delete the old version of the form.  I chose the “No” option. But then when I ran the new project I got an error saying that Lazarus could not find the new form.  I can see that I am out of my depth here and am asking for help to:(1) either recreate the forms and save them in the new directory, or (2) is there a way to use the old forms, changing the name, and saving them into the new directory, or (3) copying the form, piece by piece onto a new form and save that new form to the new directory, or (4) what is the proper way to do this and not generate error messages?
Thank you in advance for any assistance you can provide.
John

cdbc

  • Hero Member
  • *****
  • Posts: 1078
    • http://www.cdbc.dk
Re: Creating a project with forms from other projects
« Reply #1 on: March 14, 2023, 12:09:54 pm »
Hi
Hold  on for a bit, I'll put together an example for you  ;)
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

Hansvb

  • Hero Member
  • *****
  • Posts: 618
Re: Creating a project with forms from other projects
« Reply #2 on: March 14, 2023, 12:37:20 pm »
if you copy the form files into the new project folder you can add them to the new project. Start lazarus, menu Project, Project inspector. In the project inspector you choose add, add file from the file sytem, select you're form file.


cdbc

  • Hero Member
  • *****
  • Posts: 1078
    • http://www.cdbc.dk
Re: Creating a project with forms from other projects
« Reply #3 on: March 14, 2023, 03:35:31 pm »
Hi
Right, here goes:  %)
1) My development tree starts at ~/src (on windows it's probably C:\src)
Code: Pascal  [Select][+][-]
  1.            - my_rtl/ this directory contains my own RTL, ex: my_advstring.pas, my_bomintf.pas
  2. ~/src/-|
  3.            - my_fcl/ this directory contains my own FCL, ex: lfm_editaccitem.pas/lfm
  4.        |   - frmreuse/ contains this test project
  5.  
2) When I develop something that can be reused, I place it in one of the
    libdirs, my_rtl or my_fcl
3) For forms, just copy the .pas and the .lfm files to ~/src/my_fcl/
4) In your new Project, go to: Project Options -> Compiler Options -> Paths
-> Other unit files and add your two libdirs
5) Now, you can: 1- add to uses in lpr for the new project; 2- add to uses
    per form or unit basis, as per my example app.
6) Example project uses an inputform from another app of mine, but from
    the main form not lpr. It gets created by a function in the input-unit
    instead of autocreation in lpr.
7) Play around with it and have fun  :D
Got questions?!? just ask  ;)
Regards Benny
« Last Edit: March 14, 2023, 04:07:54 pm by cdbc »
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

 

TinyPortal © 2005-2018