{*******************************************************}
{ }
{ Pascal Script Source File }
{ Run by RemObjects Pascal Script in CnWizards }
{ }
{ Generated by CnPack IDE Wizards }
{ }
{*******************************************************}
program SQLToString;
uses
Windows, SysUtils, Classes, CnWizIdeUtils;
function DupeString(const AText: string; ACount: Integer): string;
var
i: Integer;
begin
i := ACount;
while i > 0 do
begin
Result := Result + AText;
i := i - 1;
end;
end;
var
Lines: TStringList;
sTemp: string;
i, FirstPos: Integer;
IsDelphi: Boolean;
begin
//IsDelphi := false;
//IsDelphi := Compiler <> cnBCB6;
IsDelphi := WizOptions.CompilerID <> 'CB6';
//WriteLn(WizOptions.CompilerID);
//IsDelphi := Pos('Delphi', Application.MainForm.Caption) > 0;
Lines := TStringList.Create;
try
if IdeGetEditorSelectedLines(Lines) and (Lines.Count > 0) then
begin
i := 1;
sTemp := Lines[0];
while (sTemp[i] = ' ') do
i := i + 1;
FirstPos := i;
for i := 0 to Lines.Count - 1 do
begin
sTemp := Lines[i];
sTemp := Copy(sTemp, FirstPos, Length(sTemp));
if IsDelphi then
sTemp := QuotedStr(sTemp + ' ')
else
begin
sTemp := StringReplace(sTemp, '"', '\"', [rfReplaceAll]);
sTemp := '"' + sTemp + ' \r\n"';
end;
if IsDelphi and (i <> Lines.Count - 1) then
sTemp := sTemp + ' +';
Lines[i] := DupeString(' ', FirstPos - 1) + sTemp;
end;
IdeSetEditorSelectedLines(Lines);
end;
finally
Lines.Free;
end;
end.
[i][i][i]
==================================================================
FormatSrc--簡單的格式化源碼(可以對當前選擇的源碼做一些簡單的處理,美化一下,當然各位可以根據自己需求做更多的優化)
{*******************************************************}
{ }
{ Pascal Script Source File }
{ Run by RemObjects Pascal Script in CnWizards }
{ }
{ Generated by CnPack IDE Wizards }
{ }
{*******************************************************}
program FormatSrc;
uses
Windows, SysUtils, Classes, CnWizIdeUtils;
function DupeString(const AText: string; ACount: Integer): string;
var
i: Integer;
begin
i := ACount;
while i > 0 do
begin
Result := Result + AText;
i := i - 1;
end;
end;
var
Lines: TStringList;
sTemp: string;
i, FirstPos: Integer;
IsDelphi: Boolean;
begin
IsDelphi := WizOptions.CompilerID <> 'CB6';
Lines := TStringList.Create;
try
if IdeGetEditorSelectedLines(Lines) and (Lines.Count > 0) then
begin
for i := 0 to Lines.Count - 1 do
begin
sTemp := Lines[i];
if sTemp = '' then continue;
if sTemp[Length(sTemp)] <> ';' then continue;
while (Length(sTemp) >=2) and (sTemp[Length(sTemp) - 1] = ' ') do
Delete(sTemp, Length(sTemp) - 1, 1);
Lines[i] := sTemp;
end;
IdeSetEditorSelectedLines(Lines);
end;
finally
Lines.Free;
end;
end.[i][/i][/i][/i][/i]
{*******************************************************}
{ }
{ Pascal Script Source File }
{ Run by RemObjects Pascal Script in CnWizards }
{ }
{ Generated by CnPack IDE Wizards }
{ }
{*******************************************************}
program FormEventDemo;
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ScriptEvent, TypInfo, ExtCtrls, CnDebug;
// To use this demo, you must add it to script list and check
// "smFormEditorNotify -> fetComponentCreated" item.
var
FormEvent: TCnScriptFormEditorNotify;
Comp, CompRoot: TComponent;
i: Integer;
begin
if (Event <> nil) and (Event.Mode = smFormEditorNotify) and
(Event is TCnScriptFormEditorNotify) then
begin
FormEvent := TCnScriptFormEditorNotify(Event);
CnDebugger.LogMsg(IntToStr(Ord(FormEvent.NotifyType)));
[color=red] if FormEvent.NotifyType = fetSaving then
begin
if Assigned(FormEvent.FormEditor) then
CnDebugger.LogMsg('FormEvent.FormEditor');
if Assigned(FormEvent.Component) then
begin
CnDebugger.LogMsg('FormEvent');
CompRoot := FormEvent.Component;
CnDebugger.LogMsg(CompRoot.Name);
if Assigned(CompRoot) then
begin
for i := 0 to CompRoot.ComponentCount - 1 do
begin
Comp := CompRoot.Components[i];
if Comp.ClassName = 'TADOConnection' then
begin
if GetPropValue(Comp, 'Connected', True) then
SetPropValue(Comp, 'Connected', False);
end;
end;
end;
end;
[/color] end
else if FormEvent.NotifyType = fetComponentCreated then
begin
if FormEvent.Component <> nil then
begin
Comp := FormEvent.Component;
if Comp is TCustomMemo then
begin
if TCustomMemo(Comp).Lines.Text = Comp.Name then
begin
TCustomMemo(Comp).Lines.Clear;
if Comp is TMemo then
TMemo(Comp).ScrollBars := ssBoth;
end;
end
else if Comp is TCustomEdit then
begin
if TCustomEdit(Comp).Text = Comp.Name then
TCustomEdit(Comp).Text := '';
end
else if Comp is TPanel then
begin
if TPanel(Comp).Caption = Comp.Name then
TPanel(Comp).Caption := '';
end
else if Comp is TComboBox then
begin
if TComboBox(Comp).Text = Comp.Name then
TComboBox(Comp).Text := '';
end
else if Comp.ClassName = 'TADOConnection' then
begin
SetPropValue(Comp, 'LoginPrompt', False);
SetPropValue(Comp, 'ConnectionString', '');
end;
end;
end;
end;
end.