style, put locals init in declaration instead of body

This commit is contained in:
Basile Burg 2015-09-04 23:48:07 +02:00
parent 0cc5fe3e5d
commit 95aef4170f
10 changed files with 36 additions and 58 deletions

View File

@ -374,9 +374,8 @@ end;
function expandFilenameEx(const aBasePath, aFilename: string): string;
var
curr: string;
curr: string = '';
begin
curr := '';
getDir(0, curr);
try
if (curr <> aBasePath) and DirectoryExists(aBasePath) then
@ -490,11 +489,10 @@ end;
function shortenPath(const aPath: string; charThresh: Word = 60): string;
var
i: NativeInt;
sepCnt: NativeInt;
sepCnt: integer = 0;
drv: string;
pth1: string;
begin
sepCnt := 0;
if length(aPath) <= charThresh then
exit(aPath);
@ -729,7 +727,7 @@ end;
procedure processOutputToStrings(aProcess: TProcess; var aList: TStringList);
var
str: TMemoryStream;
sum: Integer;
sum: Integer = 0;
cnt: Integer;
buffSz: Integer;
begin
@ -752,7 +750,6 @@ begin
Detects last line terminator in the accumation.
Load TStrings from this stream range.
}
sum := 0;
str := TMemoryStream.Create;
try
buffSz := aProcess.PipeBufferSize;
@ -826,11 +823,9 @@ end;
function getLineEndingLength(const aFilename: string): byte;
var
value: char;
le: string;
value: char = #0;
le: string = LineEnding;
begin
value := #0;
le := LineEnding;
result := length(le);
if not fileExists(aFilename) then
exit;

View File

@ -434,7 +434,6 @@ begin
fAsblrAttrib.Assign(aValue);
end;
procedure TSynD2Syn.setCurrIdent(const aValue: string);
begin
if fCurrIdent = aValue then Exit;

View File

@ -389,7 +389,6 @@ begin
fClient.Execute;
writeSourceToInput;
//
str := 'a';
setlength(str, 256);
i := fClient.Output.Read(str[1], 256);
if i = 0 then

View File

@ -1,21 +1,21 @@
inherited CEInfoWidget: TCEInfoWidget
Left = 713
Height = 306
Height = 318
Top = 245
Width = 378
BorderIcons = [biSystemMenu, biMinimize, biMaximize]
Caption = 'About'
ClientHeight = 306
ClientHeight = 318
ClientWidth = 378
inherited Back: TPanel
Height = 306
Height = 318
Width = 378
ClientHeight = 306
ClientHeight = 318
ClientWidth = 378
inherited Content: TPanel
Height = 306
Height = 318
Width = 378
ClientHeight = 306
ClientHeight = 318
ClientWidth = 378
object GroupBox1: TGroupBox[0]
Left = 4
@ -46,18 +46,18 @@ inherited CEInfoWidget: TCEInfoWidget
end
object GroupBox2: TGroupBox[1]
Left = 4
Height = 189
Height = 201
Top = 113
Width = 370
Align = alClient
BorderSpacing.Around = 4
Caption = 'tools status'
ClientHeight = 169
ClientHeight = 181
ClientWidth = 366
TabOrder = 1
object boxTools: TScrollBox
Left = 4
Height = 161
Height = 173
Top = 4
Width = 358
HorzScrollBar.Page = 1

View File

@ -231,17 +231,14 @@ end;
procedure TCELibManEditorWidget.btnSelFileClick(Sender: TObject);
var
ini: string;
ini: string = '';
begin
if List.Selected = nil then
exit;
if List.Selected.SubItems.Count > 0 then
ini := List.Selected.SubItems[0]
else
begin
ini := '';
List.Selected.SubItems.Add(ini);
end;
with TOpenDialog.Create(nil) do
try
filename := ini;

View File

@ -708,22 +708,22 @@ end;
procedure TCEMainForm.LoadSettings;
var
fname1: string;
fname: string;
begin
// project and files MRU
fname1 := getCoeditDocPath + 'mostrecent.txt';
if fileExists(fname1) then with TCEPersistentMainMrus.create(nil) do
fname := getCoeditDocPath + 'mostrecent.txt';
if fileExists(fname) then with TCEPersistentMainMrus.create(nil) do
try
setTargets(fFileMru, fProjMru);
loadFromFile(fname1);
loadFromFile(fname);
finally
Free;
end;
// shortcuts for the actions standing in the main action list
fname1 := getCoeditDocPath + 'mainshortcuts.txt';
if fileExists(fname1) then with TCEPersistentMainShortcuts.create(nil) do
fname := getCoeditDocPath + 'mainshortcuts.txt';
if fileExists(fname) then with TCEPersistentMainShortcuts.create(nil) do
try
loadFromFile(fname1);
loadFromFile(fname);
assignTo(self);
finally
Free;
@ -973,9 +973,8 @@ procedure TCEMainForm.updateMainMenuProviders;
var
i, j: Integer;
itm: TMenuItem;
doneUpdate: boolean;
doneUpdate: boolean = false;
begin
doneUpdate := false;
for j := 0 to fMainMenuSubj.observersCount-1 do
begin
// try to update existing entry.
@ -1157,7 +1156,6 @@ var
act := nil;
cat := '';
end;
begin
for i:= 0 to fActionHandler.observersCount-1 do
begin
@ -1609,10 +1607,9 @@ end;
procedure TCEMainForm.actFileCompAndRunWithArgsExecute(Sender: TObject);
var
runargs: string;
runargs: string = '';
begin
if fDoc = nil then exit;
runargs := '';
if InputQuery('Execution arguments', '', runargs) then
compileAndRunFile(false, true, runargs);
end;
@ -1639,11 +1636,10 @@ end;
procedure TCEMainForm.actProjCompAndRunWithArgsExecute(Sender: TObject);
var
runargs: string;
runargs: string = '';
begin
if not fProjectInterface.compile then
exit;
runargs := '';
if InputQuery('Execution arguments', '', runargs) then
fProjectInterface.run(runargs);
end;
@ -1694,9 +1690,8 @@ end;
procedure TCEMainForm.actProjRunWithArgsExecute(Sender: TObject);
var
runargs: string;
runargs: string = '';
begin
runargs := '';
if InputQuery('Execution arguments', '', runargs) then
fProjectInterface.run(runargs);
end;
@ -1827,9 +1822,8 @@ end;
procedure TCEMainForm.actLayoutSaveExecute(Sender: TObject);
var
fname: string;
fname: string = '';
begin
fname := '';
if not InputQuery('New layout name', '', fname) then
exit;
//

View File

@ -541,9 +541,8 @@ end;
procedure TCEMessagesWidget.actCopyMsgExecute(Sender: TObject);
var
i: Integer;
str: string;
str: string = '';
begin
str := '';
for i := 0 to List.Items.Count-1 do
if List.Items[i].MultiSelected then
str += List.Items[i].Text + LineEnding;
@ -654,7 +653,7 @@ procedure TCEMessagesWidget.message(const aValue: string; aData: Pointer;
aCtxt: TCEAppMessageCtxt; aKind: TCEAppMessageKind);
var
dt: PMessageData;
item: TTreeNode;
item: TTreeNode;
begin
showWidget;
if aKind = amkAuto then
@ -799,8 +798,8 @@ end;
function guessMessageKind(const aMessg: string): TCEAppMessageKind;
var
pos: Integer;
idt: string;
pos: Integer = 1;
idt: string = '';
function checkIdent: TCEAppMessageKind;
begin
case idt of
@ -820,8 +819,6 @@ begin
end;
end;
begin
idt := '';
pos := 1;
result := amkBub;
while(true) do
begin
@ -852,11 +849,10 @@ end;
function getLineFromMessage(const aMessage: string): TPoint;
var
i, j: Integer;
ident: string;
ident: string = '';
begin
result.x := 0;
result.y := 0;
ident := '';
i := 1;
while (true) do
begin

View File

@ -725,7 +725,6 @@ begin
currentConfiguration.runOptions.setProcess(fRunner);
if runArgs <> '' then
begin
prm := '';
i := 1;
repeat
prm := ExtractDelimited(i, runArgs, [' ']);

View File

@ -720,9 +720,9 @@ var
node: TTreeNode;
i: Integer;
begin
cat := getCatNode(origin, sym.symType);
cat := getCatNode(origin, sym.symType);
{$HINTS OFF}
node := tree.Items.AddChildObject(cat, sym.name, Pointer(sym.fline));
node := tree.Items.AddChildObject(cat, sym.name, Pointer(sym.fline));
{$HINTS ON}
if not fShowChildCategories then node := nil;
cat.Visible:=true;

View File

@ -559,11 +559,10 @@ end;
procedure TCETodoListWidget.lstItemsCompare(Sender: TObject; item1, item2: TListItem; Data: Integer; var Compare: Integer);
var
txt1, txt2: string;
txt1: string = '';
txt2: string = '';
col: Integer;
begin
txt1 := '';
txt2 := '';
col := lstItems.SortColumn;
if col = 0 then
begin