Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with old Delphi 5 application under Windows 10 (64bit)

Status
Not open for further replies.

mwallin

Programmer
May 15, 2002
2
US
I have been maintaining an old Delphi 5 application under Windows 10 (64bit) for bank for a number of years and have recently run what looks like a show stopper:

I am finding an anomalous behavior in a FOR loop with Delphi 5 under Windows 10 64bit. Here is the simplified code:
FOR i := nMin TO nEnd Do
Begin
// Code
End

The problem is that the code inside the begin..end is being run even if the range of the loop 0 to 0. To test this, I set both nMin and nEnd to 0 and the code inside the Begin..End is still being executed. I am also getting Invalid Op Exceptions.

I know that Delphi 5 is way outdated but my client that has ignored my warnings for years and now is apparently going to have to pay the piper.

Has anybody else run into this behavior with Delphi 5?
 
The code your presented here works fine.
I have several D5 programs running on latest W10 versions.
Are you using threads?


-----------------------------------------------------
Helping people is my job...
 
This is exactly how the for loop is expected to operate. From the documentation:

The for statement assigns the value of initialValue to counter, then executes statement repeatedly, incrementing or decrementing counter after each iteration. (The for...to syntax increments counter, while the for...downto syntax decrements it.) When counter returns the same value as finalValue, statement is executed once more and the for statement terminates. In other words, statement is executed once for every value in the range from initialValue to finalValue. If initialValue is equal to finalValue, statement is executed exactly once. If initialValue is greater than finalValue in a for...to statement, or less than finalValue in a for...downto statement, then statement is never executed. After the for statement terminates (provided this was not forced by a Break or an Exit procedure), the value of counter is undefined.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top