1. Yet Another Enhancement Suggestion
- Posted by Derek Parnell <ddparnell at bigpond.com> Aug 28, 2001
- 404 views
Hi Robert, please consider this idea for a later release. Proposal: If the index variable in a FOR loop is already declared, use that variable and allow it's value to be inspected when the loop ends. Reason: When a loop has prematurely exited, the program often needs to know where it was up to when this happened. Currently, we must either create extra variables to detect this common requirement, or use a WHILE loop and do the indexing manually. Examples: Currently this doesn't work... for i = 1 to length(pFields) do if ... then exit end if end for if i > ... because 'i' has no scope beyond the for-loop. This also fails... integer i for i = 1 to length(pFields) do if ... then exit end if end for if i > ... because 'i' is redeclared. I would like to see the second example become legal usage. It would save a lot of silly extra variables and generally simplify code. Also, it would not break existing code because it is currently illegal usage. Now we tend to do this... integer j j = 0 for i = 1 to length(pFields) do if ... then j = i exit end if end for if j > ... or do this... integer i i = 1 while i <= length(pFields) do if ... then exit end if i += 1 end while if i > ... both are more error-prone than allowing access to the FOR loop's index variable after the loop. ----------- cheers, Derek Parnell Senior Design Engineer Global Technology Australasia Ltd dparnell at glotec.com.au --------------------- -------------------------------------------------------------------- Global Technology Australasia Limited is the industry leader in next generation financial software solutions: www.glotec.com.au Delivering the Future of Banking Today CAUTION - This email and any files attached may contain privileged and confidential information intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient of this message you are hereby notified that any use, dissemination, distribution or reproduction of this message is prohibited. If you have received this message in error please notify the sender immediately. Any views expressed in this message are those of the individual sender and may not necessarily reflect the views of Global Technology Australasia Limited. --------------------------------------------------------------------
2. Re: Yet Another Enhancement Suggestion
- Posted by Robert Craig <rds at RapidEuphoria.com> Aug 28, 2001
- 401 views
Derek Parnell writes: > please consider this idea for a later release. <for-loop enhancement> Thanks for the suggestion. I'll look into it after 2.3. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
3. Re: Yet Another Enhancement Suggestion
- Posted by jjnick at cvn.com Aug 29, 2001
- 429 views
I concur, in my for loops, I have found it useful to access the value once the loop is done . . . ----- Original Message ----- From: "Derek Parnell" <ddparnell at bigpond.com> To: "EUforum" <EUforum at topica.com> Subject: Yet Another Enhancement Suggestion > > Hi Robert, > please consider this idea for a later release. > > Proposal: > If the index variable in a FOR loop is > already declared, use that variable and > allow it's value to be inspected when > the loop ends. > > Reason: > When a loop has prematurely exited, the > program often needs to know where it was > up to when this happened. Currently, we > must either create extra variables to > detect this common requirement, or use > a WHILE loop and do the indexing manually. > > Examples: > > Currently this doesn't work... > > for i = 1 to length(pFields) do > if ... then > exit > end if > end for > if i > ... > > because 'i' has no scope beyond the for-loop. > > This also fails... > integer i > for i = 1 to length(pFields) do > if ... then > exit > end if > end for > if i > ... > > because 'i' is redeclared. > > I would like to see the second example become legal usage. It would save a > lot of silly extra variables and generally simplify code. Also, it would not > break existing code because it is currently illegal usage. > > Now we tend to do this... > > integer j > j = 0 > for i = 1 to length(pFields) do > if ... then > j = i > exit > end if > end for > if j > ... > > or do this... > > integer i > i = 1 > while i <= length(pFields) do > if ... then > exit > end if > i += 1 > end while > if i > ... > > both are more error-prone than allowing access to the FOR loop's index > variable after the loop. > > ----------- > cheers, > Derek Parnell > Senior Design Engineer > Global Technology Australasia Ltd > dparnell at glotec.com.au > > --------------------- > > of > this message you are hereby notified that any use, dissemination, > distribution or reproduction of this message is prohibited. If you have > received this message in error please notify the sender immediately. Any > views expressed in this message are those of the individual sender and may > not necessarily reflect the views of Global Technology Australasia Limited. > > >