strange anomalies when using an iteration variable twice in 1 function
- From: Hans Heintz <NOSPAMhh_000001@xxxxxxxxx>
- Date: Thu, 29 Sep 2005 20:21:58 +0200
d4
I have 2 for to next loops in one function and find that in the second loop, using the iteration
variable to indicate array elements the first array element is used everytime.
in this example aEdit: ('1','0','0','0') type 'arrayofstring' self defined as 'array of string'
//=========================================================================
function Somefunction : variant;
var
i : integer;
aEdit : arrayofstring;
cTmp : string;
begin
//<snipped out some code here>
for i := low(aUservar) to high(aUservar) do begin
//..
end;
for i := low(aEdit) to high(aEdit) do begin
cTmp := aEdit[i];
result := hstrtoboolean(aEdit[i]); //<-testing compiler here
end;
end;
//=========================================================================
At iteration 1(as in i=1 whoever invented that counting should start at 0???) in loop 2 the compiler
would say that aEdit[i] = '0' but cTmp would be '1' and this valuable will be passed on to the
function hstrtoboolean.
If i add an integer variable 'k' to the function end replace all 'i' with 'k' in the second loop the
problem is over.
que?
.
- Follow-Ups:
- Re: strange anomalies when using an iteration variable twice in 1 function
- From: Bruce Roberts
- Re: strange anomalies when using an iteration variable twice in 1 function
- Prev by Date: Re: Layouts in Delphi?
- Next by Date: Re: strange anomalies when using an iteration variable twice in 1 function
- Previous by thread: Layouts in Delphi?
- Next by thread: Re: strange anomalies when using an iteration variable twice in 1 function
- Index(es):
Relevant Pages
|