Delphi 2009 之 TStringBuilder 类[1]: Create

本文介绍如何在Delphi中使用TStringBuilder类创建字符串并进行操作。通过两个实例演示了TStringBuilder的基本用法:无参数创建及使用字符串初始化。这些示例展示了如何拼接字符串并显示最终结果。
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

//TStringBuilder.Create 可以无参数
procedure TForm1.Button1Click(Sender: TObject);
var
  sb: TStringBuilder;
begin
  sb := TStringBuilder.Create;
  sb.Append('Embarcadero');
  sb.Append(' CodeGear');
  sb.Append(' Delphi');
  sb.Append(' 2009');

  ShowMessage(sb.ToString); {Embarcadero CodeGear Delphi 2009}
  sb.Free;
end;

//TStringBuilder.Create 可用字符串初始化; 其他重载用处不大
procedure TForm1.Button2Click(Sender: TObject);
var
  sb: TStringBuilder;
begin
  sb := TStringBuilder.Create('Delphi ');
  sb.Append(2009);

  ShowMessage(sb.ToString); {Delphi 2009}
  sb.Free;
end;

end.
paxCompiler is an embeddable compiler of the Object Pascal, Basic and javascript programming languages. The key features of the paxCompiler are: The compiler generates machine code for Intel compatible processors (IA-32 architecture). It is possible to use the compiler as a scripting engine. You can embed the compiler into host application, register host-defined types, routines, variables and constants for the engine, read/write script-defined variables, call script-defined functions etc. You can save/load compiled scripts to/from a stream. The compiler was initially written in Borland Delphi as a set of Delphi components. TPaxCompiler, TPaxProgram and TPaxPascalLanguage are Delphi components that allows you to embed the paxCompiler into Delphi, Kylix or Borland C++ Builder application so you can customize and extend the application without having to recompile it. Source code of paxCompiler is compatible with Free Pascal 2.0. paxCompiler, implemented as paxcompilerlib.dll, can be used for scripting Microsoft Visual C++ applications. The compiler supports Object Pascal language based on the Delphi 7 standard. Syntax of Basic language is similar to VB.NET. Script-defined functions support register (Borland fastcall), cdecl, stdcall, safecall, pascal and msfastcall (Microsoft fastcall) calling conventions. Cross-language programming support. You can use Pascal units in Basic and javascript programs and vice versa. COM support. TPaxCompilerDebugger and TPaxCompilerExplorer components implement debugger (breakpoints, call stack, watches, step over, trace into, run to cursor, pause) and code explorer capabilities. Script-defined types support run-time information (RTTI). You can bind instances of script-defined classes with dfm files. You can import host-defined types with paxCompiler importer. You can create stand alone executable files. Support of compiled units and run-time packages. paxCompiler engine is thread safe. The roadmap of the compiler includes: Java compiler, C++ compiler, built-in assembler.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值