Sign in Join
Wiki copytemporary

Code Conversion Guide/pt: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11Guia de conversão do Delphi para o Lazarus
22
33## Sobre
44
55Esta página é sobre como converter um código para poder usá-lo no compilador [[Free Pascal]] e a IDE do Lazarus. O Lazarus e o Free Pascal tem aspectos em comum com o Delphi e Kylix, porém, não são clones. Há várias diferenças nos códigos e convenções... e em algumas áreas, o FPC pode exigir uma sintaxe mais correta. Por favor veja o guia [[Lazarus For Delphi Users]] para uma descrição de algumas das diferenças funcionais.
66
77O propósito deste guia é documentar algumas das diferenças específicas que freqüentemente são encontradas durante o processo de conversão de código ao traduzir código existente de Delphi para Lazarus.
88
99Este documento foi colocado na área de conhecimento-base de wiki para que assim pudesse ser ampliado facilmente por qualquer um que tenha encontrado um problema e gostaria de postar isto para outros estarem atentos
1010
1111## Selecionando um componente ou biblioteca para conversão
1212
1313### Onde achar conteúdo para converter
1414
1515Há MUITOS códigos possíveis na internet de serem convertidos para serem usados com o FPC e o Lazarus. Aqui tem uma [[Page Of Code Sites]] por onde você pode começar. Por favor adicione outro link se encontrar algum outro local. TurboPower Software recentemente seus produtos comerciais sob a MPL. Uma lista de packages disponíveis pode ser encontrado [aqui](http://sourceforge.net/users/tpsfadmin/).
1616
1717Para evitar retrabalho, packages que foram convertidas estão listadas em [[Components and Code examples]] Se você converteu uma package ou está convertendo, por favor adicione uma nota na página [[Current conversion projects]]
1818
1919### Licenciamento
2020
2121Licenças para a faixa de domínio de código existente freeware/domínio público para versões restritivas que proíbem a modificação, re-distribuição e uso comercial. Antes de converter qualquer pacote, é uma boa idéia analisar seu licenciamento e ter a certeza que ele vai ser compatível com o Lazarus e o compilador Free Pascal. Verificação de licença é especialmente importante com componentes, de vez que ao incorporar um a um formulário, isso pode impor a necessidade de obter uma licença, o que pode ser indesejável ​​ou incompatível para o aplicativo inteiro.
2222
2323Ao converter componentes, por favor, respeite os desejos do autor original e mantenha todos os direitos autorais e cabeçalhos de licenciamento junto com endereços de e-mail e url's. É cortês e, muitas vezes útil para informar o autor que a sua componente está sendo (ou foi) convertida... especialmente se o componente está sob uma licença restritiva. Novo interesse em um antigo ou esquecido componente, pode às vezes inspirar autores a revisar seus originais e excessivo licenciamento restritivo.
2424
2525Em geral, Domínio Público (freeware), e o LGPL/MPL são as formas de licenciamento mais flexível para a distribuição de componentes. Para mais informações, o site [Open Source Definition](http://www.opensource.org/docs/definition.php) é um bom lugar para iniciar. Há também diversas comparações disponíveis para ajudar a esclarecer como os vários tipos de licenças de trabalho e qual o impacto que terá sobre o código que está sendo vinculado. Procure por "open source license comparison"
2626
2727### Dependências
2828
2929Outro passo antes de começar a trabalhar em uma conversão é verificar se o código não tem dependências profundas de outros pacotes que podem não estar disponíveis ou representam um desafio considerável de conversão. Algumas ofertas de freeware obrigam ou se estendem a pacotes proprietários que freqüentemente não estão disponíveis ou vêm com licenças inadequadas.
3030
3131### Questões de Compilador
3232
3333Atualmente a versão estável 1.0.x do compilador Free Pascal não suporta interfaces, threads ou registros Variant. Se o código que você está convertendo necessita desses construtores, você terá que usar o ramo de desenvolvimento 1.1 do compilador ... que não é sempre garantido para trabalhar com Lazarus.
3434
3535Veja também:
3636
3737- [Problemas conhecidos](http://www.freepascal.org/probs.html)
3838- [Unfixed bugs](http://www.freepascal.org/bugs/db.php3?statusfield=Unfixed)
3939
4040### SO e problemas de plataforma
4141
4242Lazarus e o compilador Free Pascal são cross-platform e ferramentas de desenvolvimento para serem usadas também em vários sistemas operacionais. Em contraste, a maioria dos códigos escritos em Delphi são especificamente escritos para rodar em um processador Intel sob Win32. Se o seu canditado a componente possui muito código específico da plataforma Win32, seria sábio procurar uma alternativa independente da plataforma. Mas não desista... é verdadeiramente incrível o suporte LCL.
4343
4444## Fazendo a conversão
4545
4646### Montando o ambiente de Lazarus para um projeto de conversão
4747
4848#### Crie um projeto teste
4949
5050- Coloque o código a ser convertido em um subdiretório (ex: c:\convertdir)
5151- Abra-o com o Lazarus
5252- File-\>Save All para o subdiretório c:\convertdir. Os nomes para o Projeto e a Unit Default são opcionais.
5353- Abra em c:\convertdir a unit "main" para ser convertida * Adicione-a ao projeto: Project-\>Add Active Unit to Project
5454- Clique em Tools-\>Quick Syntax Check ou em Run-\>Build All para começar.
5555
5656#### Termos iniciais para se cuidar
5757
5858- Nomes de arquivos são sensíveis ao letras maiúsculas e minúsculas nos compiladores da série 1.0.x Se você estiver trabalhando com uma versão como essa, faça com que todos os seus arquivos sejam escritos em minúsculas, pois do contrário, você terá como frase de erro "File not found" - arquivo não encontrado.
5959
6060#### Fontes Delphi VCL, Kylix CLX no Lazarus
6161
6262Ao converter fontes de Delphi/Kylix, é freqüentemente útil fazer uma declaração sobre o que uma função específica está fazendo. A IDE Lazarus pode analisar as fontes de Delphi/Kylix. Para isto, é necessário indicar o local dos arquivos para o compilador. Pode-se conseguir isso através do menu Environment-\>CodeTools Defines Editor-\>Insert Template
6363
6464### Problemas de conversão e soluções
6565
6666#### Arquivos Delphi / Kylix equivalentes no Lazarus
6767
6868| | | |
6969|----|----|----|
7070| Delphi / Kylix | Lazarus | Descrição |
7171| .pas .dfm / .xfm .dcu / .dpu .dpr .res .dof / .kof --- --- --- | .pas, .pp .lfm .o .lpr --- --- .lrs .lpi .ppu | Arquivo unit de Pascal Arquivos de dados do form Arquivo da unit compilada Arquivo do Projeto Arquivo de recursos Arquivo de opções do projeto Arquivo de recursos do Lazarus Arquivo de informações do projeto Arquivo de descrição de unit FPC |
7272
7373#### Contentendo projetos/forms/units Delphi para Lazarus
7474
7575Renomeie ou copie o arquivo .dpr para um arquivo .lpr. Comente ou remova a diretiva
7676
7777{\$R *.res}
7878
7979e adicione
8080
8181{\$mode delphi}{\$H+}
8282
8383ou
8484
8585{\$mode objfpc}{\$H+}
8686
8787no arquivo .lpr. A IDE do Lazarus pode através do menu Tools no item "Convert Delphi Project to Lazarus Project". Ele solicita um arquivo .dpr (Delphi Project) e o converte para um .lpr; mais tarde, também cria um .lpi.
8888
8989Existe várias maneiras de converter forms do Delphi através da IDE do Lazarus que realiza o trabalho da conversão do .dfm para o .lfm. Isso pode ser encontrado como item do menu Tools com o sob o nome "Convert DFM file to LFM". Clique nele, e na caixa de dialogo escolha seu arquivo .dmf e o conversor fará o resto.
9090
9191Se você precisa converter a unit inteira (com ou sem um form), o Lazarus também inclui a opção de converter uma unit Delphi para uma Unit Lazarus, através do item "Convert Delphi unit to Lazarus unit" que fará o seguinte:
9292
93931. renomeiará os arquivos .pas and .dfm para minúsculas.
94942. converterá .dfm para .lfm file (atualmente sem a verificação da validade do conteúdo; somente o formato)
95953. criará um arquivo .lrs vazio (o conteúdo será adicionado mais tarde)
96964. adicionará a diretiva
9797 {\$mode delphi}
98985. substituirá as unidades Windows por LCLIntf
99996. adicionará units LResources se necessário (i.e., se o unit.lrs for usado;
100100 o uso de LResources
101101
102102 pode ser implementado a parte)
1031037. removerá variáveis da unit
1041048. removerá a diretiva
105105 {\$R *.dfm}
1061069. adicionará a seção de inicialização e a diretiva
107107 {\$i unit.lrs}
108108
109109Isto fará uma conversão rápida e fácil da maioria das Units Delphi ao formato do Lazarus. Isto não checa a validade, ou muda a sintaxe automática. Assim, qualquer mudança na sintaxe, mudanças adicionais nos nomes das Units, mudanças necessárias por causa de diferenças nos objetos/controles, você terá que fazer manualmente.
110110
111111#### Selecting the right compiler mode
112112
113113The [[Free Pascal]] Compiler supports 5 different pascal modes. For example TP for turbo pascal, lets you compile turbo pascal units. There is also a DELPHI compatibility mode that can be set to make existing code easier to convert. Lazarus prefers the OBJFPC mode, which almost equals the DELPHI mode, but is less ambigious than the Delphi syntax. Here are the important points:
114114
115115The mode can be selected at command line or at the start of the source. Using the command line has the advantage, that you don't need to change the source, but the disadvantage, that others must be told.
116116
117117Most Delphi units can be compiled by the [[Free Pascal]] compiler by adding
118118
119-`{$IFDEF FPC}`\
120-`  {$MODE DELPHI}`\
121-`{$ENDIF}`
119+```
120+{$IFDEF FPC}
121+ {$MODE DELPHI}
122+{$ENDIF}
123+```
122124
123125right after the unit name.
124126
125127For more details about [[Free Pascal]] modes see the [Free Pascal Documentation](http://www.freepascal.org/docs-html/prog/progap4.html#progse62.html)
126128
127129#### Cross-Platform considerations
128130
129131- Inline assembler is always a problem because it will bind the code to the Intel architecture. Some developers do algorithm prototypes in Pascal and ifdef the their optimized assembler. Fortunately TurboPower did this in numerous places with their code. If this is the case with the package you're converting, throw the switch back to Pascal.
130132- Don't reference specific memory location like the BIOS data area. Find out what the code needs and try to find a cross platform alternative.
131133- Don't do processor specific tricks (like using the Intel TSC) without enclosing your code in an ifdef for the platform the code needs... and providing an alternative for environments that don't have the hardware capability.
132134- If you need some OS specific code, then you can use IFDEFs. See below for a list of macros.
133135
134136#### Useful compiler variables
135137
136138To write code, that behaves on different systems differently, you can use the
137139
138140{\$IFDEF Name}
139141
140142directives.
141143
142144- {\$IfDef LCL}
143145
144146This variable is defined, when using the LCL package. Useful to write code, that works with the LCL and Delphi.
145147
146148- {\$IfDef FPC}
147149
148150This variable is defined, when using the FPC compiler. Useful to write code, that works with FPC and Delphi.
149151
150152- {\$IfDef Unix}
151153
152154 ,
153155
154156 {\$IfDef Win32}
155157
156158 , ...
157159
158160Defined by FPC for the current Target OS. Delphi defines "Linux", "Win32" and "MSWindows". [[Free Pascal]] runs on much more platforms and so it is recommended to use the more general items. For example "Unix" is defined for Linux, FreeBSD, NetBSD and OpenBSD, where Lazarus already runs. Use
159161
160-`{$IfDef Linux}`\
161-`  {$Define Unix}`\
162-`{$EndIf}`
162+```
163+{$IfDef Linux}
164+ {$Define Unix}
165+{$EndIf}
166+```
163167
164168to work around this for Kylix.
165169
166170For more details see the [Free Pascal Documentation](http://www.freepascal.org/docs-html/prog/prog.html#QQ2-23-21).
167171
168172#### Finding a missing identifier
169173
170174There are differences in how the LCL is organized when compared to the Delphi VCL. If you get a "not found" compiler error about a major class or identifier, the chances are good that it's in a different unit. A complete cross reference can be found by grep'ing lazarus/docs/xml or the lcl subdirectory.
171175
172176For example the commonly used tbutton typically throws an error in Delphi code because it's located in a unit named buttons.pp. The following command finds the correct unit very quickly (in the lazarus source directory):
173177
174-` grep -in ' tbutton =' lcl/*`
178+```
179+ grep -in ' tbutton =' lcl/*
180+```
175181
176182#### Major unit differences between Lazarus and Delphi
177183
178184- - Please add to this topic! **
179185
180186- Windows-\>Interfaces, LCLIntf, LCLType, LCLProc, VCLGlobals, ...)
181187
182188As the LCL is not windows specific, the code that is in the Delphi Windows unit for directly accessing the Win32 API is abstracted into seperate interfaces, which can be accessed from the LCLIntf unit. Keep in mind, that Lazarus does not emulate win32, so many functions are missing and some do not work as their win32 counterparts. These functions only exist for Delphi compatibility and should only be used for quick & dirty porting. LCL also breaks out many of the types, so often LCLType, and sometimes VCLGlobals are required. LCLProc also contains a few functions which can be useful for lower level handling such as "FreeThenNil" as is in Delphi 5 and higher, "DeleteAmpersands" to remove additional ampersands from a string for controls(& vs && etc). The Interfaces unit needs to be included in the .lpr file to initialize the appropriate widgetset.
183189
184190- Messages-\>LMessages
185191
186192TControl Messages for win32 event callbacks of the format WM_CALLBACK and the structs associated with them are often found in the Messages unit in Delphi. In the LCL these types of messages and there structs are usually found in LMessages, usually with name changes of WM to LM, so for instance WM_MOUSEENTER becomes LM_MOUSEENTER, and TWMMouse becomes TLMMouse.
187193
188194- Graphics, Controls-\>GraphTypes, GraphMath, Graphics, Controls
189195
190196To simplify some things and break complexity of circles between units, a few types have been abstracted into a shared unit called GraphType, which includes things, which in Delphi are located in Graphics or Controls, for instance the bvNone etc of panels. So sometimes you have to include it. Also a unit which, although incompatible with Delphi, adds other useful functionality is GraphMath, which adds a TFloatPoint for precision, misc routines for dealing with beziers, lines, and arcs, as well as some operator overloading for use with TPoints and TRect, such as for instance Point1 := Point2 + Point3, and comparing two rects like if (rect1 = rect2) then ...
191197
192198- Mask-\>MaskEdit
193199
194200For more intelligent naming considerations, the unit for TMaskEdit is called \[MaskEdit\|\] instead of the slightly more nebulous Mask as in many versions of Delphi.
195201
196202- StdCtrls-\>StdCtrls,Buttons
197203
198204In many version of Delphi TButton is located in StdCtrls, while TSpeedButton and TBitBtn are in Buttons. For consistency and simplicity the LCL puts all button types in Buttons, which can occasionally break code conversion, so it is always a good idea to include.
199205
200206#### Property and method differences Delphi -\> FPC/LCL
201207
202208- TBitmap contains a canvas in the LCL
203209
204210#### Syntax differences
205211
206212**Please add to this topic!**
207213
208214Because of the inherent strictness in FPC, some syntax changes are necessary, even though
209215
210216{\$Mode Delphi}
211217
212218does allow more laziness like Delphi does. For this reason complying as much with the syntax rules of
213219
214220{\$Mode ObjFPC}
215221
216222as possible is highly recommended, even when the codebase is still going to be shared between Delphi and the LCL. Some of these are simply better coding practices, and sometimes because Delphi mode is not entirely accurate, or in a few instances Delphi acceptible code does not function as expected with FPC, even though it might compile. To that end even though not all such are strictly required, the following list of changes should be considered mandatory :
217223
218224When assigning an event handling entry point, prefix it with an "@"
219225
220226For instance, you might assign a button callback manually
221227
222228Delphi
223229
224230FPC
225231
226232begin
227233
228234if not
229235
230236Assigned(MyButton.OnClick)
231237
232238then
233239
234240`    MyButton.OnClick:= SomeFunction; `
235241
236242//@ not required
237243
238244//more code...
239245
240246end
241247
242248;
243249
244250begin
245251
246252if not
247253
248254Assigned(MyButton.OnClick)
249255
250256then
251257
252258`    MyButton.OnClick:= @SomeFunction; `
253259
254260//@ IS required
255261
256262//more code...
257263
258264end
259265
260266;
261267
262268When calling a procedure variable use this syntax
263269theprocname()
264270
265271In Delphi there is no difference between a function result and a variable, however there is in FPC, so to call a function, even if it has no parameters, you must append parenthesis. For Example -
266272
267273Delphi
268274
269275FPC
270276
271277With
272278
273279(SomeObject)
274280
275281do begin
276282
277283If
278284
279285Assigned(OnMyCallback)
280286
281287then
282288
283289`    OnMyCallback; `
284290
285291//parenthesis not required
286292
287293end
288294
289295;
290296
291297With
292298
293299(SomeObject)
294300
295301do begin
296302
297303If
298304
299305Assigned(OnMyCallback)
300306
301307then
302308
303309`    OnMyCallback(); `
304310
305311//parenthesis required
306312
307313end
308314
309315;
310316
311317When accessing values in a pointer to a record you must dereference first
312318
313319In Delphi it is not required to de-reference a pointer to a record to access values within it, it can, in fact, be treated just like the record itself, or any other object. In FPC it must be first de-referenced. As an example,
314320
315321Delphi
316322
317323FPC
318324
319325Function
320326
321327GetSomeValue(ARecord: PMyRecord)
322328
323329
324330Integer;
325331
326332begin
327333
328334If
329335
330336Assigned(ARecord)
331337
332338then
333339
334340`    Result`
335341
336342
337343=
338344
339345ARecord.SomeValue
340346
341347else
342348
343349`    Result:= `
344350
3453510
346352
347353;
348354
349355end
350356
351357;
352358
353359Function
354360
355361GetSomeValue(ARecord: PMyRecord)
356362
357363
358364Integer;
359365
360366begin
361367
362368If
363369
364370Assigned(ARecord)
365371
366372then
367373
368374`    Result`
369375
370376
371377=
372378
373379ARecord^.SomeValue
374380
375381else
376382
377383`    Result:= `
378384
3793850
380386
381387;
382388
383389end
384390
385391;
386392
387393When accessing chars of an indexed string Property of an object, it must be enclosed in parentheses
388394
389395With Delphi it is possible to treat a Property exactly like some other const or var, even to accessing for instance individual chars of a string directly, while this is not always possible in FPC, specifically for indexed properties. Instead it must be enclosed in parentheses, to make distinct. While this may not always hold true it is probably a good practice to consider anyway. For example
390396
391397Delphi
392398
393399FPC
394400
395401Type
396402
397403TSomeComponent=
398404
399405class
400406
401407(TComponent)
402408
403409//More code...
404410
405411Published
406412
407413Property
408414
409415MyString:
410416
411417String
412418
413419index
414420
4154213
416422
417423read
418424
419425GetMyString;
420426
421427//More code...
422428
423429End
424430
425431;
426432
427433var
428434
429435`  MyChar`
430436
431437
432438char;
433439
434440begin
435441
436442If
437443
438444Length(MyString)\>
439445
4404462
441447
442448then
443449
444450//no parenthesis needed
445451
446452`    MyChar:= MyString[`
447453
4484543
449455
450456\];
451457
452458//More code...
453459
454460end
455461
456462;
457463
458464Type
459465
460466TSomeComponent=
461467
462468class
463469
464470(TComponent)
465471
466472//More code...
467473
468474Published
469475
470476Property
471477
472478MyString:
473479
474480String
475481
476482index
477483
4784843
479485
480486read
481487
482488GetMyString;
483489
484490//More code...
485491
486492End
487493
488494;
489495
490496var
491497
492498`  MyChar`
493499
494500
495501char;
496502
497503begin
498504
499505If
500506
501507Length(MyString)\>
502508
5035092
504510
505511then
506512
507513//parenthesis sometimes needed
508514
509515`    MyChar:= (MyString)[`
510516
5115173
512518
513519\];
514520
515521//More code...
516522
517523end
518524
519525;
520526
521527You must typecast pointers to actual type when using with var or function of that type
522528
523529Sometimes in Delphi you will have a null pointer variable representing an object. While it might seem a complex situation, it is oddly quite common especially in large component packs as a method of preventing too many circular includes between objects in different units. In Delphi it is then possible to send this null pointer to a function expecting that object, without bothering to typecast to actual type, in fpc you must typecast.
524530
525531For example -
526532
527533Delphi
528534
529535FPC
530536
531537Unit 1
532538
533539Type
534540
535541TSomeObject=
536542
537543class
538544
539545(TComponent)
540546
541547//More code...
542548
543549End
544550
545551;
546552
547553Procedure
548554
549555DoSomething(Value: TSomeObject);
550556
551557Function
552558
553559GetSomeObject: TSomeObject;
554560
555561Unit 2
556562
557563Type
558564
559565TSomeComponent=
560566
561567class
562568
563569(TComponent)
564570
565571//More code...
566572
567573Published
568574
569575`  SomeObject: Pointer`
570576
571577;
572578
573579//More code...
574580
575581End
576582
577583;
578584
579585Application
580586
581587var
582588
583589`  MyComponent: TSomeComponent`
584590
585591;
586592
587593begin
588594
589595`  MyComponent.SomeObject`
590596
591597
592598=
593599
594600GetSomeObject;
595601
596602//More code...
597603
598604`  DoSomething(MyComponent.SomeObject)`
599605
600606;
601607
602608end
603609
604610;
605611
606612Unit 1
607613
608614Type
609615
610616TSomeObject=
611617
612618class
613619
614620(TComponent)
615621
616622//More code...
617623
618624End
619625
620626;
621627
622628Procedure
623629
624630DoSomething(Value: TSomeObject);
625631
626632Function
627633
628634GetSomeObject: TSomeObject;
629635
630636Unit 2
631637
632638Type
633639
634640TSomeComponent=
635641
636642class
637643
638644(TComponent)
639645
640646//More code...
641647
642648Published
643649
644650`  SomeObject: Pointer`
645651
646652;
647653
648654//More code...
649655
650656End
651657
652658;
653659
654660Application
655661
656662var
657663
658664` MyComponent: TSomeComponent`
659665
660666;
661667
662668begin
663669
664670`  MyComponent.SomeObject`
665671
666672
667673=
668674
669675Pointer(GetSomeObject);
670676
671677//More code...
672678
673679`  DoSomething(TSomeObject(MyComponent.SomeObject))`
674680
675681;
676682
677683end
678684
679685;
680686
681687#### Resources
682688
683689Delphi resource files are win32 specific and not compatible with Lazarus, so you'll have to recreate and compile them using the lazres. Lazres can be found in the lazarus/tools subdirectory. If you've downloaded the Lazarus sources, you'll need to compile it first.
684690
685691- cd lazarus/tools
686692- make install
687693
688694To add a resource to your application:
689695
690696- lazres myresource.lrs mypix.xpm anotherpix.xpm
691697- Add the LResources unit to your Uses clause
692698- Include the .lrs file you created under the initialization block
693699
694700Example:
695701
696702function
697703
698704TForm1.LoadGlyph(
699705
700706const
701707
702708GlyphName:
703709
704710String
705711
706712): TBitMap;
707713
708714begin
709715
710716`  Result:= TPixmap.Create`
711717
712718;
713719
714720`  Result.LoadFromLazarusResource(GlyphName)`
715721
716722;
717723
718724end
719725
720726;
721727
722728//More code...
723729
724730begin
725731
726732`  Speedbutton1.glyph:= LoadGlyph('mypix')`
727733
728734;
729735
730736//More code...
731737
732738end
733739
734740;
735741
736742initialization
737743
738744{\$I unit1.lrs}
739745
740746{\$I myresource.lrs}
741747
742748end
743749
744750.
745751
746752### Another method to convert a Delphi or Kylix project to Lazarus
747753
748754- Rename or copy all .dfm or .xfm files to .lfm (Early Delphi versions do not produce a text-based .dfm file. The convert utility, if present in the \bin folder can be used to covert the .dfm first))
749755- Rename or copy .dpr file to .lpr
750756- Make necessary changes to .lpr file:
751757
7527581. Add {\$mode delphi}{\$H+} or {\$mode objfpc}{H+} directives
7537592. Add 'Interfaces' to uses clause
7547603. Comment out or delete {\$R *.res} or directive
755761
756762- Make necessary changes to all .pas unit files:
757763
7587641. Add {\$mode delphi}{\$H+} or {\$mode objfpc}{H+} directives
7597652. Add 'LResources', and if the form has buttons, add 'Buttons' to uses clause
7607663. Comment out or delete {\$R *.dfm} or {\$R *.xfm} directive
7617674. Add 'Initialization' section at the end of each unit file, and add {\$I unitname.lrs} directive in it
762768
763769- Select Project-\>New Project form file
764770- Select the .lpr file
765771- At 'Create a new project' window, choose 'Application'
766772- Build project and make further necessary corrections to get proper compilation, at this point the .lpi file is generated automaticaly. You may also get 'Error reading Form' messages, click on 'Continue Loading' if you do.
767773- Save all, and you have a Lazarus project :-)
768774
769775## Getting Help
770776
771777If you encounter a problem during conversion that you just can't solve, there are a wide variety of places to get help. For pure Object Pascal and FPC issues, the best place to start is the Free Pascal [Documentation](http://www.freepascal.org/docs-html/) by Michaël Van Canneyt and Florian Klämpfl. For more Lazarus oriented problems, the Lazarus Project Documentation in the Lazarus-CCR Knowledgebase \[Main Page\] is the next place to look. Finally you can post a question on any of the [mailing lists for the Free Pascal Compiler](http://www.freepascal.org/maillist.html) or the [FPC forums](http://community.freepascal.org:10000/bboard/) where a lot of experts are subscribed.
772778
773779There are some outstanding search and knowledge bases online that can also be a great help for learning new techniques and solving problems. Tamarack Associates operates a fast [search](http://www.tamaracka.com/search.htm) engine specifically for the Borland usenet archives. Mer Systems Inc. provides a similar search [engine](http://www.mers.com/searchsite.html). Another outstanding source of information along with a sitewide [search](http://www.efg2.com/Lab/search.htm) capability is Earl F. Glynn's Computer Lab and Reference [Library](http://www.efg2.com/).
774780
775781## Packaging and Releasing your component
776782
777783### Creating a Lazarus package for your component(s)
778784
779785Creating a package makes installing the code you've converted a much easier process... especially if you're providing more then one component. Mattias Gärtner has written an overview of [[Lazarus Packages]] that should be read before beginning this process.
780786
781787### Documentation
782788
783789The purpose of this site and the wiki format is to make the generation of professional documentation an easy and quick process. The wiki also makes it possible to see the results of your posting immediately and make any changes you'd like in real time.
784790
785791Using the Lazarus-CCR wiki to create nice looking documentation is very easy. If you've never used wiki markup before, you can get familiar with it in the [[Sand Box]] practice area.
786792
787793### Creating a Code Release Page
788794
789795The Code Release Page contains vital information about your component that a potential downloader will need to know, such as license, intended platform, status (alpha, beta, stable...), where to download it, who wrote it, is support available... etc.
790796
791797The following procedure will let you create a Code Release Page with your browser:
792798
793799- Edit the [[Components and Code examples]] page and add a project name wiki link entry for your component in the "Released Components" section. Save the modified page.
794800
795801- Go to the [[Component Release Template]], select all and copy. Hit the back button on your browser to return to the [[Components and Code examples]] page.
796802- Click on your new wiki component name entry and paste the release template into the blank edit box.
797803- Edit the template accordingly and hit save.
798804- Do edit-saves until your document looks the way you want it to.
799805
800806### Submitting the component
801807
802808If you're a release technician on the project, upload your component to the SourceForge File Release System and add it to the list of release packages. Otherwise send it to one of the project administrators (Tom Lisjac or Vincent Snijders) and we'll add it to the repository.
803809
804810If you think you need to continue to develop on the component, we can also put it into CVS so you'll continue to have access to it.
805811
806812## Contributors and Changes
807813
808814This page has been converted from the epikwiki [version](http://lazarus-ccr.sourceforge.net/index.php?wiki=CodeConversionGuide).
809815
810816- Initial version by Tom Lisjac and Mattias Gärtner - 9/22/2003 VlxAdmin
811817- Moved Getting help from the main page. T. Lisjac - 9/24/2003 VlxAdmin
812818- Added documentation templates, procedure and links. 9/25/2003 VlxAdmin
813819- LCLLinux was renamed to LCLIntf, Jesus Reyes, 9/27/2003
814820- added more information on Unit changes, [AndrewJohnson](http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson) 9/27/2003
815821- Updated Syntax differences, including some examples, [AndrewJohnson](http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson) 9/27/2003
816822- FPC 1.0.x doesn't support interfaces, Vincent Snijders 9/28/2003
817823- Fixed some of the examples per new WikiWord definition, 9/28/2003 VlxAdmin
818824- Made code more consistant to remove last accidental Pascal WikiWord definitions, [AndrewJohnson](http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson) 9/27/2003
819825- Use tables for code examples for nice blocks, and easy side by side view of Delphi-\>FPC differences, [AndrewJohnson](http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson) 10/17/2003
820826- Use pascal stylesheet to make example code more readable, [AndrewJohnson](http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson) 10/18/2003
821827- Some translations and small corrections in translations exist -\> User: jrxds 12/01/2012
822828
823829---
824830*From the Free Pascal wiki, page "Code Conversion Guide/pt", as it stood on 2012-01-12 after a change by Jrxds, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history