I am using a -while- loop for a particular application, where I need to retrieve a particular value from the second to the last loop.
In the fictitious example below, the -while- loop will end when it `n' either equals or surpasses `N' = 400 on the last loop. I need to retrieve the values of `n' and `i', not on the last loop (where `n' may be greater than `N') but on the loop previous, where `n' is just below `N', or equal to `N'.
In my application, `n' is not linear or incremental, so it is likely that the last loop will almost always produce an `n' that is greater than `N'
I hope I have stated my problem clearly enough.
Thanks in advance!
Ariel
Code:
local N = 400 local i = 0.01 local p = 0.20 while `n' <= `N' { local n1 = "something" + invnorm(`i') local n = ceil(`n1' / `p') local i = `i' + 0.01 if `i' == 1 exit } di "`n'" di "`i'"
0 Response to Getting values from second to last loop of a -while- loop
Post a Comment