General information
Category:
Coding, syntax & commands
My guess is that the LOCATE inside the SCAN is moving the pointer to a record that don't match the SCAN condition.
This code will do the same thing, but is much nicer to read:
SELECT MyTable1
FOR I = 1 TO ALen(myArray1)
FOR J = 1 TO ALen(myArray2)
SCAN FOR (myField1 = myArray1[I]) AND (myField2 = myArray2[J])
lcTemp = myTable2.myField1
SELECT * FROM MyTable1 WHERE (myField1 = myArray1[I]) AND (myField2 = myArray2[J]) AND (myVar = lcTemp)
...
SELECT MyTable1
ENDSCAN
ENDFOR
ENDFOR
HTH
>I have a nested loop with 2 FOR...ENDFOR and a SCAN...ENDSCAN.
>
>FOR I = 1 TO ALEN(myArray1)
>sele my table1
>set filter to myField1 = myArray1[I]
>go top
>FOR J = 1 TO ALEN(myArray2)
>sele mytable1
>go top
>SCAN FOR myField2 = myArray2[J] WHILE !EOF('myTable1')
>locate for myVar = myTable2.myField1
>.
>.
>.
>
>ENDSCAN
>ENDFOR
>ENDFOR
>
>When I debug the loop, the scan searches in myTable 1 properly for myArray2[1]. When the FOR loop is incremented, the record pointer is still looking at records with myArray2[1] and seems to overlook the change in parameters.
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only