Recent

Author Topic: Copying code  (Read 2661 times)

katfo

  • New Member
  • *
  • Posts: 39
Copying code
« on: August 31, 2016, 12:46:13 pm »
I have a main project and have written code for it. Thus far everything is ok and I don’t want to mess with its working code.

That is why I start a separate test project which deals with some details in the main project. Both projects have a form with identical components (type, name etc.). When the test works as it should, I try to copy the code back to the main project but get a bunch of errors. For example in word I can copy text from a document to another. Why can’t I do likewise in Lazarus and how should it be done. Thanks in advance.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Copying code
« Reply #1 on: August 31, 2016, 01:24:54 pm »
What errors do you get?

Perhaps the .lfm (form file) differs between the two projects.

katfo

  • New Member
  • *
  • Posts: 39
Re: Copying code
« Reply #2 on: August 31, 2016, 02:50:22 pm »
For example: Identifier not found "edit2". However, both projects contain Edit2. Of course some properties (font, size, text color etc.) in Edit2 differ between projects but I assume that those don't matter.

Zoran

  • Hero Member
  • *****
  • Posts: 1980
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Copying code
« Reply #3 on: August 31, 2016, 02:51:26 pm »
The problems I can think of now:

1. When you copy the form (Let's call it Form2), you have to copy both pas and lfm files - Form2.pas and Form2.lfm. Did you do it?

2. Perhaps Form2 uses other units from the old project which it can't find in new project. You should copy these files too.

3. Old project might be dependent on some package and Form2 uses units from this package. New project does not have these dependencies, so it does not know where to look for these units. This can happen when you add components from Component palette (old project automatically includes the package where these components are located, but in new project this package has to be added manually).

4. Something else. ;)
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

katfo

  • New Member
  • *
  • Posts: 39
Re: Copying code solved
« Reply #4 on: August 31, 2016, 06:29:57 pm »
The problem in my case was copying the whole Edit2KeyPress –event from test project and then pasting it into main project. It caused errors. I solved it in the following way:

In the main project I created a new Edit2KeyPress–event. Then I copy-pasted from test into main only the lines concerning variables. After that I copy-pasted the lines between begin and end. Finally I checked and made sure that there was left only this Edit2KeyPress–event which was thus formed. Now everything worked as they should. Thank you.

 

TinyPortal © 2005-2018