Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-02

I am just wondering

8 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Juha Manninen
to Zelimir Ikovic

Zelimir Ikovic kirjoitti perjantai 04 helmikuu 2011 18:48:10:

Is there any VB6 to Lazarus translator, and how difficult would be to make one

Syntax translation would be rather easy but the libraries used by real programs are very difficult to map to FCL / LCL .
On a positive side, converting Visual Basic programs is still more realistic than C++ or even Java.
C++ has complex syntax. Java has clean syntax but the huge amount of libraries makes it (almost) impossible to convert.

Even Delphi conversion is quite a challenge sometimes.

If you want to study about Lazarus replacements for VB classes and functions, please write them down somewhere. They maybe can be used later.

Juha

Reply by email

Zelimir Ikovic
to Juha Manninen

It doesnot have to be full conversion but at least some help! I have 20000 lines VB6 program and I am not sure how to start. Just write all lines again line by line, function by function etc

or try to make a program that will generate GUI positions, and properties and import VB6 code (commented) and place it on right place, and then continue to fix and test ...

''''''''''''''''''''
VB6 FORM
''''''''''''''''''''
Begin VB.ListBox List1
Height = 3375
Left = 2040
TabIndex = 3
Top = 2640
Width = 5175
End
''''''''''''''''''''
VB6 CODE:
''''''''''''''''''''
Private Sub Command1_Click()
Label1.Caption = "aaa"
List1.AddItem "bbb"
End Sub

''''''''''''''''''''
LAZARUS FORM:
''''''''''''''''''''
object ListBox1: TListBox
Left = 44
Height = 285
Top = 97
Width = 358
ItemHeight = 0
TabOrder = 1
end
''''''''''''''''''''
LAZARUS CODE:
''''''''''''''''''''
procedure TForm1.Button1Click(Sender: TObject);
begin

  Label1.caption := 'aaa';
  ListBox1.Items.Add('bbb');

end;

Juha Manninen wrote 35 lines
From: Juha Manninen Subject: Re: [Lazarus] I am just wondering To: "Lazarus mailing list" Received: Friday, February 4, 2011, 9:15 AM Zelimir Ikovic kirjoitti perjantai 04 helmikuu 2011 18:48:10: > Is there any VB6 to Lazarus translator, and how difficult would be to make > one Syntax translation would be rather easy but the libraries used by real programs are very difficult to map to FCL / LCL . On a positive side, converting Visual Basic programs is still more realistic than C++ or even Java. C++ has complex syntax. Java has clean syntax but the huge amount of libraries makes it (almost) impossible to convert. Even Delphi conversion is quite a challenge sometimes. If you want to study about Lazarus replacements for VB classes and functions, please write them down somewhere. They maybe can be used later. Juha -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Juha Manninen
to Zelimir Ikovic

Zelimir Ikovic kirjoitti perjantai 04 helmikuu 2011 19:39:25:

Show quoted text 46 lines
It doesnot have to be full conversion but at least some help! I have 20000 lines VB6 program and I am not sure how to start. Just write all lines again line by line, function by function etc or try to make a program that will generate GUI positions, and properties and import VB6 code (commented) and place it on right place, and then continue to fix and test ... '''''''''''''''''''' VB6 FORM '''''''''''''''''''' Begin VB.ListBox List1 Height = 3375 Left = 2040 TabIndex = 3 Top = 2640 Width = 5175 End '''''''''''''''''''' VB6 CODE: '''''''''''''''''''' Private Sub Command1_Click() Label1.Caption = "aaa" List1.AddItem "bbb" End Sub '''''''''''''''''''' LAZARUS FORM: '''''''''''''''''''' object ListBox1: TListBox Left = 44 Height = 285 Top = 97 Width = 358 ItemHeight = 0 TabOrder = 1 end '''''''''''''''''''' LAZARUS CODE: '''''''''''''''''''' procedure TForm1.Button1Click(Sender: TObject); begin Label1.caption := 'aaa'; ListBox1.Items.Add('bbb'); end;

It is not a bad source directory : components/codetools/ has file LFMTrees.pas. You may want to look at the LFM file parser there:

 function TLFMTree.Parse(LFMBuf: TCodeBuffer = nil): boolean;

A VB form file parser could be made easily based on it. The actual conversion would start after the form is parsed. Your example (surprisingly) has an easy VB.ListBox which maps directly to LCL TListBox. Many other components are not so easy.

FPC source has : packages/fcl-passrc, which is a pascal parser and could work as a base for a VB parser, unless you know of an existing VB parser made with pascal.

Again, the used libraries are the real problem after the language syntax is converted. How much of your (or others') code could be converted realistically? If you think it is worth making a converter, then create some code and I promise to help with it.

Juha

Reply by email

Graeme Geldenhuys
to Zelimir Ikovic: It doesnot have to be full conversion but at least some help! I have 20000 lines VB6…
Zelimir Ikovic wrote
It doesnot have to be full conversion but at least some help! I have 20000 lines VB6 program and I am not sure how to start. Just write all lines again line by line, function by function etc

We had to make the same decision a few years back. One of our VB6 apps was around 300,000 lines of code. We decided to rather rewrite to app from scratch using Free Pascal. This gave us the opportunity the learn from our previous mistakes, do a great design by using true OOP techniques, Design Patterns and a Object Persistent Framework (tiOPF in fact). Our new version of the product is now very flexible (easy to add new features, supports multiple db backends etc.), true cross platform and a very clean design...plus a lot faster than the VB6 counterpart.

So I would highly recommend a rewrite manually. It is well known fact that your second or third attempt at a software product is ALWAYS better that the first.

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email

Bo Berglund
to Zelimir Ikovic: Is there any VB6 to Lazarus translator, and how difficult would be to make one Regardsz
Zelimir Ikovic wrote
Is there any VB6 to Lazarus translator, and how difficult would be to make one Regardsz

Back around 1996 when we switched from VB to Delphi2 there was a company that sold a product that did VB2Delphi including support for the database functions (at that time we used Access databases). We tested the converter and even though it did work it generated a messy code, which noone wanted to maintain.
So we did not use it for the intended purpose.
But the DAO interface objects supplied by the converter worked amazingly well with Access and we used that all the way until Delphi5, when there was a Borland Add-On for ADO. At that time we dropped the DAO database support objects too and went with ADO.

I would not expect it to be possible really to make a sane machine conversion so I agree with Graeme that you are probably better off rewriting the code and use modern OOP techniques instead of bringing over the VB mess...

Bo Berglund

Reply by email

Hans-Peter Diettrich
to Zelimir Ikovic: Is there any VB6 to Lazarus translator, and how difficult would be to make one Regardsz
Is there any VB6 to Lazarus translator, and how difficult would be to make one

VB is an OLE wrapper, closer to .NET than to Delphi (VCL) or Lazarus (LCL). A converter may be feasable, to some degree, but the GUI won't work with the LCL, so that a very new development environment would be required (like for fpGUI or mseide...).

Some time ago I made an C to Pascal converter, that might be extended with VB syntax. But the final converter will be incapable of translating many VB constructs (OnError...).

Another chance would be a VB front-end for FPC, so that VB modules can be compiled without a transformation into Pascal before. Currently only an Oberon front-end is implemented, but the code generation has not been finished yet - it would require more support by the FPC developers, or a freeze to a specific FPC version, that can not be kept in sync with the FPC development.

And last no least there exists a fine tool for converting one language into another one: TextTransformer <http://www.texttransformer.com/>. It can be used to transform both VB code and forms into .pas and .lfm files. The integrated debugger will be very helpful in the implementation and verification of the VB grammar.

I'm not yet sure about possible problems with importing declarations from other modules, regardless of which way you want to go.

DoDi

Reply by email