Error trapping non-existent?

Blitz3D Forums/Blitz3D Programming/Error trapping non-existent?

Cold Storage(Posted 2005) [#1]
I've read as much as I can in the last 24hrs and it seems that Blitz isn't too hot on error trapping.

i.e. yes, something bad has happened, but not something terrible. So here's the error code and do with it what you will... meanwhile I will continue to run.

It always seems to bomb out if there are any errors.

Is that the case?

If not - I'm all ears! ;O)

For example, trying to read a directory that doesn't exist should really be trappable - but it bombs the program.

There is only one error trap I've found, and all that does is print a custom message before terminating.


_PJ_(Posted 2005) [#2]
FileType is a good way to check a file beforehand, this will report on whether a file is a folder, a file or doesn't exist.

Also, check the handle value (memory address) it will equal zero if no data is loaded... something like this:



By the way... Do you have the Debug mode enabled on the IDE?


Cold Storage(Posted 2005) [#3]
Basically I'm writing a visual file browser - just like Windows Explorer so a user can select a file.

So, I ReadDir the current directory and then the user can click on a Sub-Directory and then I ReadDir that, display the contents, and so on....

BUT!

ReadDir crashes my program with a "Directory does not exist" - when it tries to read through a hidden Directory ( attrib H is set ).

FileType happily sees it (not good in my case) but ReadDir bottles it and can't see it (surely an inconsistency?).

If only Blitz had an Attrib command I could avoid ReadDir'ing the Hidden Directories. Or if FileType had a type "3" for hidden files (dreamland!).

The only way I can see to get Attrib info. is to issue a DOS "Command /c" to a text file. I've got this working now, but of course it creates a horrible flickering window - BTW surely you can execute a "Command /c" without console???


:O(



Can anyone rescue me from this nightmare? Surely someone has had this problem before?


Nicstt(Posted 2005) [#4]
i use RunTimeError eg:

Global gfxLadderRight = LoadImage("Game Bitmap\Ladder Right.bmp")
If gfxLadderRight = False Then RuntimeError "Can't locate the 'Graphics File'."



Cold Storage(Posted 2005) [#5]
Only problem there is the program bombs out - you can't keep running, or keep the fact that there was a problem secret from the user.

I either need to not show hidden files ( not sure how to? )

OR

I need to be able to trap the error and just go "beep" or something.

Like I say, if there's a problem the program just ends - no real error trapping.

I'm hoping someone who's written a file browser in Blitz 3D will have solved this without having to write a C++ .dll.

If that's the only way though, will I have to upgrage my Blitz 3D to 1.88? ( I seem to remeber reading that .dll support only began in later versions and I'm still using the old v1.64 shipped version.

If you could do;

myDir%=ReadDir(folder$)
If myDir%=false then PlaySound etc...

Then that'd be fine - but the first line just bombs on hidden directories.


Cold Storage(Posted 2005) [#6]
OK OK OK.... I am a complete plonker!

It's crashing when trying to execute the NextFile$ command, not the ReadDir.

So, I check mydir% and it's zero on Hidden files.


I'm Soooooo.... Sorry!

( and rather embarassed! )


Cold Storage(Posted 2005) [#7]
In fact, I've discovered that it's NOT hidden files that cause the crash!

It's "C:\System Volume Information" - not 'really' a folder, but gets reported as one by FileType...( GAH! )

Blitz3D will happily browse hidden folders. :O)


Ross C(Posted 2005) [#8]
I think that's where the system restore information is held :o)