Commit a4691e77 authored by Martin Schreiber's avatar Martin Schreiber

* tcustomgrid Check valid cell before restoring focused cell by statfile.

* STR_*() macros expand parameter macros.
+ STR_COALESCE() macro.
parent f6495489
...@@ -164,6 +164,11 @@ STR_TRIMLEFT ...@@ -164,6 +164,11 @@ STR_TRIMLEFT
STR_TRIMRIGHT STR_TRIMRIGHT
Trim whitespace from the end of text. Trim whitespace from the end of text.
STR_COALESCE
Return first not empty value. Format is
${STR_COALESCE(text[,text...])} or
${STR_COALESCE("text"[,"text"...])}
MSEide file macros MSEide file macros
****************** ******************
Macro format is ${FILE_*(fileparameter)} or ${FILE_*("fileparameter")}. Macro format is ${FILE_*(fileparameter)} or ${FILE_*("fileparameter")}.
......
...@@ -33,7 +33,7 @@ function str_trim(const sender: tmacrolist; ...@@ -33,7 +33,7 @@ function str_trim(const sender: tmacrolist;
begin begin
result:= ''; result:= '';
if params <> nil then begin if params <> nil then begin
result:= trim(params[0]); result:= trim(sender.expandmacros(params[0]));
end; end;
end; end;
...@@ -42,7 +42,7 @@ function str_trimleft(const sender: tmacrolist; ...@@ -42,7 +42,7 @@ function str_trimleft(const sender: tmacrolist;
begin begin
result:= ''; result:= '';
if params <> nil then begin if params <> nil then begin
result:= trimleft(params[0]); result:= trimleft(sender.expandmacros(params[0]));
end; end;
end; end;
...@@ -51,17 +51,35 @@ function str_trimright(const sender: tmacrolist; ...@@ -51,17 +51,35 @@ function str_trimright(const sender: tmacrolist;
begin begin
result:= ''; result:= '';
if params <> nil then begin if params <> nil then begin
result:= trimright(params[0]); result:= trimright(sender.expandmacros(params[0]));
end;
end;
function str_coalesce(const sender: tmacrolist;
const params: msestringarty): msestring;
var
i1: int32;
begin
result:= '';
if params <> nil then begin
for i1:= 0 to high(params) do begin
result:= sender.expandmacros(params[i1]);
if result <> '' then begin
break;
end;
end;
end; end;
end; end;
const const
strmacroconst: array[0..2] of macroinfoty = ( strmacroconst: array[0..3] of macroinfoty = (
(name: 'STR_TRIM'; value: ''; handler: macrohandlerty(@str_trim); (name: 'STR_TRIM'; value: ''; handler: macrohandlerty(@str_trim);
expandlevel: 0), expandlevel: 0),
(name: 'STR_TRIMLEFT'; value: ''; handler: macrohandlerty(@str_trimleft); (name: 'STR_TRIMLEFT'; value: ''; handler: macrohandlerty(@str_trimleft);
expandlevel: 0), expandlevel: 0),
(name: 'STR_TRIMRIGHT'; value: ''; handler: macrohandlerty(@str_trimright); (name: 'STR_TRIMRIGHT'; value: ''; handler: macrohandlerty(@str_trimright);
expandlevel: 0),
(name: 'STR_COALESCE'; value: ''; handler: macrohandlerty(@str_coalesce);
expandlevel: 0) expandlevel: 0)
); );
......
...@@ -10220,7 +10220,10 @@ begin ...@@ -10220,7 +10220,10 @@ begin
if og_rowsizing in foptionsgrid then begin if og_rowsizing in foptionsgrid then begin
datarowheight:= reader.readinteger('rowheight',datarowheight); datarowheight:= reader.readinteger('rowheight',datarowheight);
end; end;
focuscell(po1); if ((po1.col < 0) or (po1.col < fdatacols.count)) and
((po1.row < 0) or (po1.row < frowcount)) then begin
focuscell(po1);
end;
end; end;
finally finally
endupdate; endupdate;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment