Warning: read carefully the code you wrote

After wasting around two hours to correct a bug *, I ended with the following code that was meant to produce a 512 Pixels tall image from Portrait or Landscape images…

// b.Compute the image size If gCover_File.Width < gCover_File.Height Then // Portrait Windows_Width = gCover_File.Width / Scale_Value Windows_Height = 512 Else // Landscape Windows_Width = gCover_File.Width / Scale_Value Windows_Height = 512 End If

With commented code and the fact that I lost my mind in trying to resolve this trouble, I do not realized what was my fully working code.

Fortunately, this time, I go back home right after I cleared the bug. Also, while driving, I was thinking that I, for once, do not cleared (yet) the original and buggy code. So, once I get home and after a frugal lunch, I fired Xojo and get an eye on the code / fire TextEdit and watch what was the code (I saved a copy there for other reasons) before I modify it.

I was so tired… I do not realized that… I wrote two times the same code as you can read in the if block above ! ;).

Conclusion:
Before you left Xojo and after a hard writing time, check carefully your code, you may be surprised about what you read (wrote earlier)…

  • The bug: the result image had inverted values for the resized image width and height…

Nota: at 25 y/o, I remember the start code, but now my memory is a bit less reliable, so, usually (now), I forgot from where I come and how I reach the finished code.

I found the solution while I was seriously thinking to ask this forum for help (this most of the time works, but this time… I was really angry to have a problem for a so easy to solve problem), and then I started to be creative and it worked.