SourceFormatX

Overview

Features

Why Use It

Formatting Show

Integration

Screenshots

Documentation

FAQs & Tips

Update History

Award Gallery

Testimonials

License Policy

CodeMorph

CodeToHtml

Delphi Source Code Formatting Show


SourceFormatX code formatter bases on powerful syntax parse engines so it can beautify and format source code files with omnifarious styles, even these messy source code examples below:

C/C++ Java C# Delphi (Pascal)
PHP JSP ASP JavaScript
Visual Basic VB.NET VBScript HTML Components
80x86 ASM 8051 ASM CORBA IDL


This is an extreme Delphi code formatting example, the purpose of it is to show the power of SourceFormatX Delphi Code Formatter's syntax parse engine for Delphi and Object Pascal programming language.

  /* Before Delphi Code Formatting */

  unit AutoScale;interface uses Windows,Controls,Forms,Classes,Dialogs;type
  TAutoScale=class(TComponent)privateMatrix:Variant;PW,PH,BCount:Integer;procedure
   GetFormInfo(Form:TForm);public constructor Create(AOwner:TComponent);override;
  procedure Init(Form:TForm);procedure Resize(Form:TForm);published end;var
  AutoScale1:TAutoScale;procedure Register;implementation
  procedure Register;begin RegisterComponents('Uwis',[TAutoScale]);end;
  constructor TAutoScale.Create(AOwner:TComponent);begin inherited; //If statement
  if(AOwner is TForm)then Init(AOwner as TForm)else
  ShowMessage('The owner of TAutoScale is NOT a TForm.');end;
  procedure TAutoScale.Init(Form:TForm);begin BCount:=Form.ControlCount-1;
  Matrix:=VarArrayCreate([0,BCount,0,3], VarInteger);GetFormInfo(Form);end;
  procedure TAutoScale.GetFormInfo(Form:TForm); var I:Integer;RGN:TRect;begin
  for I:=0 to BCount do begin RGN:=Form.Controls[I].BoundsRect;Matrix[I,0]:=RGN.
  Left;Matrix[I,1]:=RGN.Top;Matrix[I,2]:=RGN.Right;Matrix[I,3]:=RGN.Bottom;end;PW
  :=Form.ClientWidth;PH:=Form.ClientHeight;end;procedure TAutoScale.Resize(Form:
  TForm);var L,T,LL,TT,RR,BB,W,H,WW,HH,I:Integer;Fas:Boolean;begin WW:=Form.
  ClientWidth;HH:=Form.ClientHeight;Fas:=Form.AutoScroll;Form.AutoScroll:=False;
  for I:=0 to(Form.ControlCount-1)do begin LL:=((Matrix[I,0]*WW)div PW);TT:=((
  Matrix[I,1]*HH)div PH);RR:=((Matrix[I,2]*WW)div PW);BB:=((Matrix[I,3]*HH)div PH)
  ;L:=LL;T:=TT;W:=RR-LL;H:=BB-TT;SetBounds(Form.Controls[I]);end;end;end.


  /* After Delphi Code Formatting */

  unit AutoScale;

  interface

  uses Windows, Controls, Forms, Classes, Dialogs;

  type
    TAutoScale = class(TComponent)
      privateMatrix: Variant;
      PW, PH, BCount: Integer;
      procedure GetFormInfo(Form: TForm);
    public
      constructor Create(AOwner: TComponent); override;
      procedure Init(Form: TForm);
      procedure Resize(Form: TForm);
    published
    end;
  var
    AutoScale1: TAutoScale;
  procedure Register;

  implementation

  procedure Register;
  begin
    RegisterComponents('Uwis', [TAutoScale]);
  end;

  constructor TAutoScale.Create(AOwner: TComponent);
  begin
    inherited; //If statement
    if (AOwner is TForm) then
      Init(AOwner as TForm)
    else
      ShowMessage('The owner of TAutoScale is NOT a TForm.');
  end;

  procedure TAutoScale.Init(Form: TForm);
  begin
    BCount := Form.ControlCount - 1;
    Matrix := VarArrayCreate([0, BCount, 0, 3], VarInteger);
    GetFormInfo(Form);
  end;

  procedure TAutoScale.GetFormInfo(Form: TForm);
  var
    I: Integer;
    RGN: TRect;
  begin
    for I := 0 to BCount do
    begin
      RGN          := Form.Controls[I].BoundsRect;
      Matrix[I, 0] := RGN.Left;
      Matrix[I, 1] := RGN.Top;
      Matrix[I, 2] := RGN.Right;
      Matrix[I, 3] := RGN.Bottom;
    end;
    PW := Form.ClientWidth;
    PH := Form.ClientHeight;
  end;

  procedure TAutoScale.Resize(Form: TForm);
  var
    L, T, LL, TT, RR, BB, W, H, WW, HH, I: Integer;
    Fas: Boolean;
  begin
    WW := Form.ClientWidth;
    HH := Form.ClientHeight;
    Fas := Form.AutoScroll;
    Form.AutoScroll := false;
    for I := 0 to (Form.ControlCount - 1) do
    begin
      LL := ((Matrix[I, 0] * WW) div PW);
      TT := ((Matrix[I, 1] * HH) div PH);
      RR := ((Matrix[I, 2] * WW) div PW);
      BB := ((Matrix[I, 3] * HH) div PH);
      L  := LL;
      T  := TT;
      W  := RR - LL;
      H  := BB - TT;
      SetBounds(Form.Controls[I]);
    end;
  end;

  end.

  Don't waste time on formatting Delphi / Object Pascal code by hand any more!  Download SourceFormatX Delphi Code Formatter today!