Archive

Posts Tagged ‘delphi’

Delphi Split String Utility

April 27, 2012 5 comments

There is no built-in Split function in Delphi, sometimes we need an easy way to perform string splitting just like PHP or Python does: “Hello World”.split(‘ ‘) would produce dynamic array [‘Hello’, ‘World’].

In Delphi you can perform that in different way, for example using TStringList separated text behavior but you need maintenance the TStrings instance each time performing splitting.

var
  Temp: TStrings;
begin
  Temp := TStringList.Create;
  try
    Temp.Text := StringReplace('Hello World', #32, #13#10, [rfReplaceAll]);
    // Process the list here
    // Temp[0] = 'Hello'
    // Temp[1] = 'World'
  finally
    Temp.Free;
  end;
end;

Compare in Python way:

list = 'Hello World'.split(' ')
# list[0] == 'Hello'
# list[1] == 'World'

Pretty short and comfort is it.
I try makes something easy in Delphi way, like this:

var
  List: IStrings;
begin
  List := SplitEx('Hello World', ' ');
  // List[0] = 'Hello'
  // List[1] = 'World'

Or more complex:

  with SplitEx('08:00-13:00, '-') do
  begin
    // Index 0: 08:00
    with SplitEx(Strings[0], ':') do
      // Index 0: 08
      // Index 1: 00
      dtStartTime.Time := EncodeTime(AsInt[0], AsInt[1], 0, 0);

    // Index 1: 13:00
    with SplitEx(Strings[1], ':') do
      // Index 0: 13
      // Index 1: 00
      dtEndTime.Time := EncodeTime(AsInt[0], AsInt[1], 0, 0);
end;

Read more…

Categories: Delphi, Uncategorized Tags: , ,

TSafeMe… BindMe

March 17, 2011 14 comments

Forget Try-Finally to make sure your TObject instance destroyed completely on exit block procedure. TSafeMe makes your code clean without worrying with underlaying memory leaks.

Common try-finally pattern, is this your usual code?

function TXServer.ServiceDelete(const ServiceID: string): IXResponse;
var
  Q_SERVICES: TORM_Q_SERVICES;
begin
  Result := TXResponse.NewResponse();

  Q_SERVICES := TORM_Q_SERVICES.Create; // create new instance
  try
    try
      Q_SERVICES.SERVICE_ID.WhereValue := ServiceID;
      Q_SERVICES.Controller.Delete;
    except
      on E: Exception do
      begin
        Result.RESP_CODE := RC_ERROR;
        Result.RESP_MSG := E.Message;
      end;
    end;
  finally
    Q_SERVICES.Free; // then relese it
  end;
end;

Now compare with this one, see TSafeMe in action: Read more…

Categories: Delphi Tags:

PowerLogic SDK

January 27, 2011 8 comments

PowerLogic SDK is a framework that help you develop desktop application with Delphi more robust and fast, the successor are under development. PowerLogic consists of Delphi expert and modular framework itself.

Its main feature is the use of MDI interface, integrated with SSO (Single Sign On), the database access layer (with mini & fast ORM), and controller based architecture (plugin).

Debug your code directly under Delphi environment, no need to be changes, use your programming style and habit because you’re 100% coding in Delphi. Compile (CTRL+F9) and Run+Debug (F9) like usually… Everything configured to be works by the PowerLogic SDK Delphi expert.

With Delphi RAD you can create desktop-based applications quickly, with PowerLogic SDK you will be more rapid!

No need to think about the menus, deploying to the file server, versioning (auto update), and do not have to worry about authentication. All have been handled automatically, you just think the business logic.

PowerLogic SDK snaps.

TLogin 1.0 Standard Edition

June 4, 2007 33 comments

Torry's Delphi Pages

TLogin – simplify you to manage User Rights, add multiuser and user rights functionality to your application with just a few mouse clicks.

Allows to control the user access to your app. GUI components (menus, buttons, check boxes, radio, .., everything on your form) and to any non visual functionality. Just drag, drop and run.

With TLogin you can:
Read more…