CreateBank() Error Check

Blitz3D Forums/Blitz3D Programming/CreateBank() Error Check

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

The solution by big10p is valid for all Blitz commands that return a handle. If the value is 0, it didn't execute properly. This includes all the Create() commands, and the Load commands as well. In theory, it is good practice to check the handle for validity whenever you execute any of these commands, but it seems to me that few people actually code such checks for a valid handle thru a Create/Load command.

I had a program that kept aborting when trying to Draw an aimage. I looked at the LoadImage command, and the file was correct (so I thought). Then I actually read the handle returned, and it said zero (0). Huh? I asked myself. "That image and directory is valid and correct!" went my indignation. But, I finally came down off my high horse and really looked at the image. It was yada-yada.jpg. I was loading yada-yada.png. Computers are SO stupid!

Which leads me to a observation on computers and programming:

Computers don't do what you THOUGHT you told them to do. Instead, they do what you ACTUALLY told them to do, which is not necessarily the same as what you thought you told them to do.