[Lazarus] I am just wondering

Juha Manninen juha.manninen62 at gmail.com
Fri Feb 4 19:35:44 CET 2011


Zelimir Ikovic kirjoitti perjantai 04 helmikuu 2011 19:39:25:
> 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 idea at all.

Lazarus 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




More information about the Lazarus mailing list