PRODUCTS

FEATURED PRODUCT

Grid, menus, calendars, advanced edits, navigational controls and much more... to create feature-rich IntraWeb applications faster

License only 125 EUR See More

SEARCH

LOGIN

Customer login to access products, support information & special benefits.

NEWS ALERTS

Add your e-mail address here to receive the monthly TMS Software alerts.

 

LINKS

EXAMPLE 50

TAdvStringGrid

example 50 : (ab)using TAdvStringGrid for console type sort / file conversion apps

Sometimes it's great when the boss walks in and gives some specifications for a small application, you can call him back within 10 minutes with a solution.

Today is such a day and the boss walks in asking for an application that will give him sorted HTML files resulting from CSV files sent by the customer. As this should be processed automatically from an existing script, this should be a console application. Time to fire up Delphi, create an instance of TAdvStringGrid, load the CSV file, sort it and save it as HTML. Compile & done. Here is the result:

program asg50;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  AdvGrid;

var
  asg: TAdvStringGrid;
  c,err: Integer;

begin
  if ParamCount <> 3 then
    writeln('Use : ASG50 "Sort column" "Input CSV-filename" "Output HTML-filename"')
  else
  begin
    val(paramstr(1),c,err);

  if err= 0 then
  begin

    asg := TAdvStringGrid.Create(nil);

    asg.SaveFixedCells := False;
    asg.LoadFromCSV(paramstr(2));
    asg.SortSettings.AutoFormat := False;
    asg.SortSettings.Column := c;

    asg.QuickSort(c,1,asg.RowCount - 1);

    asg.SaveToHTML(paramstr(3));

    asg.Free;
  end
  else
  begin
     writeln('Use : ASG50 "SortColumn" "Input CSV-filename" "Output CSV-filename"');
     writeln('with SorColumn valid zero based column index');
  end;

end;


end.


Delphi project & source files for downloading included in the main demos distribution for Delphi.

The project and source files have been written with Delphi 6,7. To use these files in other versions of Delphi, ignore any remarks when opening the form files and save the files. After this, compilation can be done. The error messages are due to properties included in the Delphi 6 form file, but not available in lower versions of Delphi.  

Copyright © 1995 - 2008 TMS Software