Procedure someproc Local luReturnValue, ... luReturnValue = .f. With This If !.GetValidDateRanges() *!* don't need to continue since !.GetValidDateRanges() returned .f. else *!* only continue if .GetValidDateRanges() returns .t. * Some other code ... Select ... From ...Into Array .arrItems If Type('.arrItems[1,1]')#'N' *!* don't need to continue since Type('.arrItems[1,1]')#'N' else *!* only continue if Type('.arrItems[1,1]')='N' For ix=1 To Alen(.arrItems,1) If .arrItems[ix,2] = 'somecondition' luReturnValue = .SomeOtherProc(ix) *!* this assumes that .SomeOtherProc(ix) returns a logical, otherise *!* this procedure will return different data types which will bite you in the rear *!* I have my return value so I am done with this procedure as Cetin exited it here exit Endif If .arrItems[ix,3] = 'somecondition2' luReturnValue = .SomeOtherProc2(ix) *!* this assumes that .SomeOtherProc(ix) returns a logical, otherise *!* this procedure will return different data types which will bite you in the rear *!* I have my return value so I am done with this procedure as Cetin exited it here exit Endif Endfor if luReturnValue *!* only continue processing if everything up to this point is correct * Some other code where also there are few other returns ... endif Endif && Type('.arrItems[1,1]')='N' Endif && .GetValidDateRanges() Endwith RETURN ( luReturnValue ) EndprocI really miss the beautify option that was available in FPW 2.6 that allowed you to beautify code with "action diagram symbols" as it would transform most any code into a readable, easy to follow format by joining the structures and showing returns with < ==Return. In fact, when I look at unfamilliar code, old legacy code, poorly written code, or have made modifications and inadvertantly have mismatched structures (if/endif, do/enddo,do case/endcase or for/next) I will often open FPW26 and paste code into a program file and beautify with action diagram symbols just to quickly get a handle on what is going on. It works for most code except for code structures not supported in FPW26. The following is Cetin's code beautified in FPW2.6 with Action diagram symbols (except the I had to replace the graphics characters would be nice neat lines and arrows with characters that would print here). IMO, The ability to diagram code like this makes almost any code more readable and easier follow the intent and logic.
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>Hi Cetin,
>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.