Select ... From ...Into Array .arrItems If Type('.arrItems[1,1]')#'N' *-- Evan would replace * Return .F. && No items *-- with luReturnValue = .F. * This one is OK * assuming I'd have some kind of do nothing down the code till return * and something to signal for..endfor should be skipped - * another if..endif wrapper :( or moving the code in this block * Personally I hate the need to browse till the end of routine * to see I was doing nothing else more before returning the .f. in this case Endif For ix=1 To Alen(.arrItems,1) If .arrItems[ix,2] = 'somecondition' *-- Evan would replace * Return .SomeOtherProc(ix) *-- with luReturnValue = .SomeOtherProc(ix) * My original code cuts processing any more elements here and returns * Assuming it was a typo you forgot to put an 'exit' Endif If .arrItems[ix,3] = 'somecondition2' *-- Evan would replace * Return .SomeOtherProc2(ix) *-- with luReturnValue = .SomeOtherProc2(ix) Endif Endfor * W/o typo no 'exit' in loop * Unnecessarily .SomeOtherProc and .SomeOtherProc2 might be called * multiple times and last call might set the return value * just the reverse of what should it be * Still you need revise the code more as luReturnValue * doesn't give any hint on if the rest of code should be processed or not * Revising the code and placing more if..else..endif code would do itCetin
>Procedure someproc >*-- Evan would replace >* Local ... >*-- with >Local luReturnValue, ... >With This > If !.GetValidDateRanges() > *-- Evan would replace > * Return .F. > *-- with > luReturnValue = .F. > Endif > * Some other code ... > Select ... From ...Into Array .arrItems > If Type('.arrItems[1,1]')#'N' > *-- Evan would replace > * Return .F. && No items > *-- with > luReturnValue = .F. > Endif > For ix=1 To Alen(.arrItems,1) > If .arrItems[ix,2] = 'somecondition' > *-- Evan would replace > * Return .SomeOtherProc(ix) > *-- with > luReturnValue = .SomeOtherProc(ix) > Endif > If .arrItems[ix,3] = 'somecondition2' > *-- Evan would replace > * Return .SomeOtherProc2(ix) > *-- with > luReturnValue = .SomeOtherProc2(ix) > Endif > Endfor > * Some other code where also there are few other returns ... >Endwith >*-- Evan would add here: >RETURN ( luReturnValue ) > >Endproc >>
>>Procedure someproc >>Local ... >>With This >> If !.GetValidDateRanges() >> Return .F. >> Endif >> * Some other code ... >> Select ... From ...Into Array .arrItems >> If Type('.arrItems[1,1]')#'N' >> Return .F. && No items >> Endif >> For ix=1 To Alen(.arrItems,1) >> If .arrItems[ix,2] = 'somecondition' >> Return .SomeOtherProc(ix) >> Endif >> If .arrItems[ix,3] = 'somecondition2' >> Return .SomeOtherProc2(ix) >> Endif >> Endfor >> * Some other code where also there are few other returns ... >>Endwith >>Endproc >>>>This already has the code broken down into many handler routines. From my POV it's easier to follow this code then to follow 'one exit point' counterpart.