View Single Post
Old 18th February 2021, 20:15   #48
Major Dude
Join Date: Mar 2008
Location: Erlangen
Posts: 919
I messed with your code a bit more.

The missing indentation makes it bad to read. For heaven's sake, use indentation. If you are too lazy to do it, simply run a code formatter over the source.

Putting everything into huge try-except blocks is also a bad idea because this swallows all exceptions including those generated by FPC's range check. Always test a program thoroughly with range checks ON, before putting everything into try/except blocks. Range check is REALLY REALLY useful to detect progamming errors.

I guess you also call Milkfloat3 from inside a try/except or try/finally block, and therefore you were never warned of the range violations within it. After having crashed my machine a few times, I found two further instances of
for j := 0 to something do if s[j]...
within Milkfloat3 on manual inspection. I changed these to start at 1, and now THAT crash is gone.

But there is more... In procedure MILKDROP, line 1281, you access s[1] without knowing if s has at least length 1. To gloss over any problems, you put it all within a large try-except block. But you probably call MILKDROP from inside yet another try-except block -> Crash!

And you are using GOTOs... these may be considered evil or not, there have been endless discussions on the subject - but GOTO together with try/except is really a very bad idea.
Nitorami is offline   Reply With Quote