SCAN statement help  
Author Message
Spangltk





PostPosted: Visual FoxPro General, SCAN statement help Top

can anyone see anything wrong with this SCAN statement The compiler says theres a Nesting error b/c (im guessing) that it sees ENDSCAN but doesn't recognize the SCAN statement like it should.

SCAN WHILE VarSono $ sotran.sono AND ln_counter < 50 ;
FOR sotran.qtyord <> 0 ;
AND sotran.qtyshp = 0 ;
AND NOT RTRIM(sotran.item) == "INSURANCE" ;
AND NOT LEFT(sotran.item, 5) = "SHIP_" ;
AND NOT sotran.sostat = "X"


Visual FoxPro2  
 
 
CetinBasoz





PostPosted: Visual FoxPro General, SCAN statement help Top

This is just a command line. Look at the block itself. Generally beautify indentation helps you to sort out where nesting error is. If you still suspect this is it then:

Comment the line all together and put scan alone (with a test data of course). If it errors again then it's not the expression itself.


 
 
Spangltk





PostPosted: Visual FoxPro General, SCAN statement help Top

for some reason the NOT... didn't work, once I took out 'NOT' and replaced the = with <> it worked.

 
 
Garrett Fitzgerald





PostPosted: Visual FoxPro General, SCAN statement help Top

for some reason the NOT... didn't work, once I took out 'NOT' and replaced the = with <> it worked.


That really shouldn't have happened. If you change it back, does it break again

 
 
Spangltk





PostPosted: Visual FoxPro General, SCAN statement help Top

yeah,

looking at it more though, this is a program im just modifying, instead of deleting the code I am just commenting it out and the commented code above the scan statement was breaking it up.

*SCAN REST WHILE Detail.tranno = Master.tranno AND ln_counter < 50 ;
SCAN WHILE VarSono $ sotran.sono AND ln_counter < 50 ;
FOR sotran.qtyord <> 0 ;
AND sotran.qtyshp = 0 ;
AND NOT RTRIM(sotran.item) == "INSURANCE" ;
AND NOT LEFT(sotran.item, 5) = "SHIP_" ;
AND NOT sotran.sostat = "X"

I guess the ; at the end of the comment extends it to the next line. VFP didn't turn it green so I assumed it wasn't a comment. The reason why the code worked 'After I fixed it' is becuase the new code wasn't directly after the comment. Thanks.

 
 
Alex Feldstein





PostPosted: Visual FoxPro General, SCAN statement help Top

The ";" at the end of the commented line makes the compiler think the whole continuing command is commented out too. The parser does not fully understand that and does not color it in the editor as commented out.

The thing to do when commenting out lines is not to end with ";" or else leave a blank line after the commented out line.