![]() | |
#11
| |||
| |||
|
|
Looks like jBase is anticipating loop termination and so skips directly. |
#12
| |||
| |||
|
|
incorrect program causes incorrect result. |
#13
| |||
| |||
|
|
The point is that unlike FOR A = 10 TO 10 the statement FOR A = 10 TO 1 under uniVerse does _not_ set the variable A at all. It's left at its previous value if it had one, or left unassigned if not. It's as if the FOR loop never even existed. The D3 result is correct I accept that it's not incorrect. John |
#14
| |||
| |||
|
|
I can picture the code that's being executed in the 10 TO 1 issue. It's always been my understanding that the FOR statement checks to see if the incremented value exceeds the limit, then does the increment and enters the loop if it does not. It seems most platforms assign the initial value, then check, where Universe checks then increments. We're talking about the placement of one high level statement (2-3 assembler lines?). In another life that wouldn't be wrong but at this point if they want to follow established precedent then it is wrong. |
#15
| |||
| |||
|
|
Tony Gravagno wrote: I can picture the code that's being executed in the 10 TO 1 issue. It's always been my understanding that the FOR statement checks to see if the incremented value exceeds the limit, then does the increment and enters the loop if it does not. It seems most platforms assign the initial value, then check, where Universe checks then increments. We're talking about the placement of one high level statement (2-3 assembler lines?). In another life that wouldn't be wrong but at this point if they want to follow established precedent then it is wrong. Precedent aside, and having had a look at the Basic Commands Reference, I agree. The behaviour I see is wrong. For the statement FOR variable = start TO end [STEP increment] the manual says (without reservation) "variable is assigned the value of start, which is the initial value of the counter." QED. John |
#16
| |||
| |||
|
|
John Henderson wrote: uniVerse 10 = 5, consistent with the very telling result from running the 4-line program: FOR A = 10 TO 1 PRINT "HELLO WORLD" NEXT A PRINT A namely: Program "T3": Line 4, Variable "A" previously undefined. Empty string used. This seems to be the result of engineer attemptS to maintain some form of local scope versus global. While in the loop the variable space referenced is the local instance while outside the loop that local instance no longer exists so the global instance is used. |
#17
| |||
| |||
|
|
IF 3=4 THEN PRINT 5 IF 4=4 THEN PRINT 6 Jim Jim, I once worked with a wonderful older gentleman who insistend in writing |
#18
| |||
| |||
|
|
"Jim Idle" <jimi (AT) temporal-wave (DOT) com> wrote in message news:1171386813.675035.296520 (AT) h3g2000cwc (DOT) googlegroups.com... IF 3=4 THEN PRINT 5 IF 4=4 THEN PRINT 6 Jim Jim, I once worked with a wonderful older gentleman who insistend in writing code such as: if FLAG=FALSE then FLAG=FALSE I'd say Why? And he's say he just was making sure. He didn't trust the computer. Mark Brown |
#19
| |||
| |||
|
|
In an ideal world, depending on the index variable outside the scope of the For-Next is not allowed--fortran et al leave it undefined. |
#20
| |||
| |||
|
|
On Feb 13, 9:12 am, "Chandru Murthi" cmur_xyz_thi (AT) xyz_seeinggree_xyz_n (DOT) net> wrote: In an ideal world, depending on the index variable outside the scope of the For-Next is not allowed--fortran et al leave it undefined. That is incorrect regarding Fortran. For the code do i=1,2 print*,i end do print*,i the variable "i" has value 3 after exiting the loop, and the code must give the result 1 2 3 |
![]() |
| Thread Tools | |
| Display Modes | |
| |