Recent

Author Topic: ct2laz - convertor between CodeTyphon and Lazarus  (Read 43709 times)

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4458
  • I like bugs.
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #15 on: January 05, 2017, 11:16:45 am »
... I guess I will try to finally make ct2laz fully work on linux too. Stay tuned...  ::)
It should be easy because all the code you use from FPC and Lazarus libraries is already cross-platform.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #16 on: January 21, 2017, 07:09:03 pm »
From version 1.0 application also works on Linux. :)  ;)  :)

Tested on Linux Mint Cinnamon Debian 32-bit edition. Please report here testing results with your OS and bitness info. To download full source go to the first post. To download Linux or Windows 32-bit binary go to https://bitbucket.org/avra/ct2laz/downloads/.

If you just press "CT => Laz" button without changing default settings, application will download latest CodeTyphon components and CodeOcean examples, and convert them for direct use in Lazarus. That's what most people will use this application for, but remember that it can also convert whole projects, and that conversion works both ways.

Table "replacements.csv" is the hearth of the conversion process, as it holds all package name pairs that differ in Lazarus and CodeTyphon. If for any reason package names change or latest IDE versions bring some new packages, this is the place where you fix things. Then you can send me fixed CSV file, or let me know and I will fix changed/added package name pairs. If the same package exists for both IDEs (like "bgrabitmappack" in Lazarus and "pl_bgrabitmap" in CodeTyphon), but for some reason in Lazarus you want to use CodeTyphon version instead, just replace "T" with "F" (without quotes) in the first CSV table column. This means there will be no conversion for that package so all CodeOcean examples will keep working with CodeTyphon version of that package (which you installed instead of original Lazarus package).

Enjoy and thank you all!  :D

EDIT: link was missing a slash character, now it works as it should
« Last Edit: February 22, 2017, 01:48:07 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #17 on: February 06, 2017, 12:14:44 pm »
News:
  • PilotLogic has changed download URL with CodeTyphon 6.0, so for a few days download was broken. I have updated download URL so it works again. You should delete old INI file if you have it, in order for this fix to work.
  • Updated descriptions in replacements CSV file
  • Executable suffix now depends on architecture and target (thanks to hint from DonAlfredo).
  • Linux 32 bit binary was successfully tested on Debian 8 Cinammon 32 bit, Makulu 11 64 bit, Ubuntu Mate 15.10 32 bit, and Manjaro 16.06.1 32 bit. Don't forget that you need to install p7zip package.

https://bitbucket.org/avra/ct2laz/downloads/

EDIT: link was missing a slash character, now it works as it should
« Last Edit: February 22, 2017, 01:48:51 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Akira1364

  • Hero Member
  • *****
  • Posts: 561
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #18 on: February 16, 2017, 09:39:07 pm »
Don't know if you've seen this post already, but I thought I'd point it out in case you haven't:

http://www.pilotlogic.com/sitejoom/index.php/forum/ct-lab-news/3758-ct-lab-ver-6-10

Apparently two of the things PilotLogic has planned for the next version are
Quote
Lab task 0010 : Change Typhon Project Info file extension from "lpi" to "ctpr"
Lab task 0040 : Change Typhon Package file extension from "lpk" to "ctpkg"

So you might want to start factoring that into your development of ct2laz, I guess?
« Last Edit: February 18, 2017, 11:27:07 pm by Akira1364 »

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #19 on: February 17, 2017, 08:48:01 am »
Apparently two of the things of PilotLogic has planned for the next version are
Quote
Lab task 0010 : Change Typhon Project Info file extension from "lpi" to "ctpr"
Lab task 0040 : Change Typhon Package file extension from "lpk" to "ctpkg"

So you might want to start factoring that into your development of ct2laz, I guess?

Thanks for pointing that out. That case is already partly covered, since file extensions used for search and replace are configurable as can be seen on the attached screenshot. You just need to replace *.lpi and *.lpk extensions with new ones. I will probably wait for a while before making these new extensions default ones, and add a button for old ones. However file renaming is not covered yet. It will be covered soon (ideally before CT 6.1 officially comes out), but for now manual file renaming should do the work after ct2laz has finished conversion.
« Last Edit: February 17, 2017, 08:51:04 am by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #20 on: May 15, 2017, 12:55:56 am »
ct2laz has been updated. Renaming files feature was added, because CodeTyphon 6.10 changed several Lazarus file extensions. It is a must to first delete your old INI file before any conversion.

Sources and overview:
https://bitbucket.org/avra/ct2laz/

Binaries for Windows and Linux and needed CSV file:
https://bitbucket.org/avra/ct2laz/downloads/
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

tigerA15

  • New Member
  • *
  • Posts: 17
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #21 on: May 19, 2017, 04:10:21 am »
thanks a lot.
   this tool has a little bug:
    it should change '{$R *.lfm}' to '{$R *.frm}'    :D

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #22 on: May 20, 2017, 01:19:23 am »
thanks a lot.
   this tool has a little bug:
    it should change '{$R *.lfm}' to '{$R *.frm}'    :D
Thanks for reporting. Only CSV file with replacement pairs needs to be updated for your find. It's too late now for this so I will leave it for tomorrow.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #23 on: May 20, 2017, 10:18:30 pm »
    it should change '{$R *.lfm}' to '{$R *.frm}'    :D
Fixed. You only need to replace your CSV with new one. Executable is not affected.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #24 on: June 15, 2017, 08:34:39 pm »
Well, here is one unintended feature: reverting CT 6.10+ project back to 6.00- version.  :-[

Some people have converted their projects to new version, found a spoiler bug, and now can't get back to old CT because they made no backup. Well, ct2laz comes to the rescue. First convert your CT 6.10+ project to Lazarus, and then back to CT but do not check the last 6.10 related checkbox and replace T with F in table column with .lfm} and .frm} in the above screenshot.

Enjoy!  ;)
« Last Edit: June 15, 2017, 08:37:26 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

sam707

  • Guest
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #25 on: July 19, 2017, 07:25:33 pm »
@avra = your ct2laz works pretty fine to me, so I can ensure that when I write some stuffs with CT they keep compatibility with LAZ! and it is NICE! THANK YOU avra

BUT there is a little 'bug' (prefer to say omission) I wanted to tell =

when I convert from <> to , there I must always manually edit the xml file describing project and change the extension of the main program mannually (CT 6.15, LAZ 1.6.4)

example =

Quote
    </RequiredPackages>
    <Units Count="4">
      <Unit0>
        <Filename Value="snipy.ppr"/>
        <IsPartOfProject Value="True"/>
      </Unit0>
      <Unit1>
        <Filename Value="formmain.pas"/>
        <IsPartOfProject Value="True"/>
        <ComponentName Value="MainForm"/>
        <HasResources Value="True"/>
        <ResourceBaseClass Value="Form"/>
      </Unit1>

in the .ctpr / .lpi file (xml project descr.) your ct2laz does not change the value I marked bold! from .lpr to .ppr

I do this manually at the moment

It's not big deal, i just wanted let you to know
Regards!
« Last Edit: July 19, 2017, 08:14:19 pm by sam707 »

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #26 on: July 20, 2017, 09:45:27 pm »
@avra = your ct2laz works pretty fine to me, so I can ensure that when I write some stuffs with CT they keep compatibility with LAZ! and it is NICE! THANK YOU avra
Thank you very much. :D   You are too kind!  :-[

in the .ctpr / .lpi file (xml project descr.) your ct2laz does not change the value I marked bold! from .lpr to .ppr
Thank you for this bug report. From a quick look, I would need to change some things. One of the initial decisions was to use no parser but very simple string replacements, and storing these replacement pairs in a simple CSV file. As CT decided to move further from Lazarus files I had to distinguish between quoted and not quoted strings, introduce file renaming and several other things. And so far I only needed to replace strings which are looked at as a whole. Solving this bug requires a possibility to replace strings which are not looked as a whole. I have already partially implemented such possibility but never used it in main code logic. The most convenient way to solve this fully seams to expand CSV file with one boolean. That would allow me to leave code pretty generic, avoid handling such specifics in code, and leave data to CSV where it belongs.

Unfortunately, I will probably not be able to deal with this bug before the end of August.  :'(
Cheers!  :)
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

sam707

  • Guest
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #27 on: July 21, 2017, 02:47:34 am »
np @Avra, i would have fix it myself by using a xml parser package, but i also have no time atm.. wife, kidos, hollidays (house to remake some walls)

i'm much more busy on hollidays than at work (that kills me hahahaha)

I'd noticed also a "adLCL" and "LCL" requirement failing sometimes, lets keep in touch, when back at my office i'll dl your source code and read it deep

THANK YOU anyway for your great ct2laz  :-*

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #28 on: July 21, 2017, 11:21:06 am »
i'm much more busy on hollidays than at work
Usually that's not the case with me, but this time I have to convert one old arcade cabinet into MAME cabinet for the kids with custom electronics interfacing original joysticks, buttons and lights. They think it is for them.  ::)

Quote
I'd noticed also a "adLCL" and "LCL" requirement failing sometimes
Please report details once you find a pattern. Patches are also welcome.  ;)

Cheers!
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #29 on: January 01, 2018, 02:50:51 pm »
ct2laz has been updated to v1.20. It is now fully compatible with CT 6.30+. Because of the breaking changes you must delete your old INI file (if there is one) and download latest REPLACEMENTS.CSV file. As usual, CSV file and prebuilt Windows and Linux executables can be downloaded here:
https://bitbucket.org/avra/ct2laz/downloads/

I was shocked this time by the amount of changes that PilotLogic has put into trying to differentiate Typhon from Lazarus. Besides more file extensions renaming, some functions having Lazarus in it's name have been renamed, and even XML tags in project groups have been changed. I had to make some significant changes to be able to cover all cases without employing a parser (which would slow down conversion significantly so I will try to avoid it as long as I can). I don't like such differentiation between Typhon and Lazarus, and since you are reading this I guess you don't like it either. I want the freedom of choice, so ctlaz comes to the rescue again. You are safe to start a project in Typhon knowing that you can get back to Lazarus any time. Breaking compatibility with Lazarus was one of the show stoppers for many people, and at the time they have decided to not start any new projects in Typhon. With ct2laz they are on a safe side again, so this is a major benefit that ct2laz brings to Typhon. On the other hand, even pure Lazarus users can benefit from using Typhon components and CodeOcean examples. Some components have bug and cross platform fixes, others can not be found anywhere else. From my point of view, it's a win-win situation for everyone.

By default, ct2laz will convert every known package name. But let's say that you want to use Typhoon's pl_indy instead of original indy Lazarus package, or pl_synapse instead of laz_synapse. That would mean that you would actually want to exclude those 2 packages from the conversion process. That is possible because all conversion pairs are stored in a CSV database table file. All you have to do is to locate their rows in CSV file and change T to F in first column of such rows in the table. That would tell ct2laz to skip such rows. You can do it from ct2laz (grid data is editable), or if you know what you are doing then you can also edit CSV file directly in some editor (it is plain ASCII file, but you must be careful not to corrupt it's structure).

If you already have Typhon installed then you don't have to use downloading option in ct2laz at all. Simply uncheck 2 first checkboxes and put typhon_src.7z (components) and CodeOcean.7z (examples) into conversion process directory. This is what you would like to do also in case when your Typhon is not the latest version and you want to use exactly your already existing Typhon for the process. Because of the breaking changes, for use with CT 6.10 and older it is better to use old ct2laz executables and CSV file. For such needs I have saved them all and you can still find them in Downloads section. For your convenience here is the direct link to the archive.

If you want, you can even misuse ct2laz as a general files search and replace utility, by creating new REPLACEMENTS.CSV file with your own conversion pairs, and playing with available options on the form.

Previous ct2laz versions had only simple string replacements, and just took care of replacing quoted conversion pairs in one type of files and non-quoted in others. Things got more complicated with CT 6.20 and CT 6.30 so function handlers were introduced. That is the number in 2nd column of the CSV file. As you can see, it can have 3 values but I expect this number to grow in the future:
Code: Pascal  [Select][+][-]
  1. const
  2.   HANDLER_NONE                         = 0;
  3.   HANDLER_FORCE_REPLACE_WITHOUT_QUOTES = 1;
  4.   HANDLER_FORCE_PARTIAL_STRING_REPLACE = 2;
First number 0 is the old ct2laz behavior. The rest (1 and 2) are introduced to handle latest CT changes.

All CT 6.30 components and examples have been tested with 32-bit Lazarus 1.8.1 and FPC 3.0.5 on Windows 10. Some CT components are Windows only, and some are found to work only with trunk versions of Lazarus and/or FPC.

Have fun!  :D ;) :D
« Last Edit: January 01, 2018, 03:10:35 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018