Reputation: 13018
I want to run an if else on base of a commandfield on each row,
For example
If {CommandField=0} Update counter by 1 return counter
else if {CommandField=1} return 'Reporting'
I tried it but having error
stringVar layerType;
shared numberVar layNo;
if({Command.ISREPORT}=0) then
layNo:=layNo+1;layerType:=layNo;layerType
else if ({Command.ISREPORT}=1) then
layerType:='Reporting'; layerType
results should be like
ISREPORT LayerNo
0 1
0 2
0 3
0 4
1 'Reporter'
Upvotes: 0
Views: 4464
Reputation: 10005
Not sure I understand but is this right:
stringVar layerType;
shared numberVar layNo;
if({Command.ISREPORT}=0) then
( layNo:=layNo+1;
layerType:=ToText(layNo);
layerType;
)
else
( if ({Command.ISREPORT}=1) then
layerType:='Reporting';
layerType
)
...which can be simplified to this:
shared numberVar layNo;
if({Command.ISREPORT}=0) then
(
layNo:=layNo+1;
ToText(layNo);
)
else
(if ({Command.ISREPORT}=1) then
'Reporting';)
..assuming the value of ISREPORT can only be 0 or 1 then we can further simplify to this:
shared numberVar layNo;
if({Command.ISREPORT}=0) then
(
layNo:=layNo+1;
ToText(layNo);
)
else
(
layNo:=0;
'Reporting';
)
Update - I've changed the last example to reset the counter on 'reporting'.
Edit:
change the ToText(.. to this ToText(layNo,0);
(sets decimal places to zero)
Upvotes: 1