When you try to execute a CARTWALL LOAD SET filename command which has a bad file name in it, or the file does not exist, mAirList displays a polite message box as one would expect.
Unfortunately, the Cartwall has already been cleared before this happens. A nasty surprise!
mAirList should check that the specified MLC file name is valid, and that the file does exist (and display the message box if not), before the Cartwall is cleared.
You’re right. But remember that there are other reasons that could lead to a failure: For example, the file might not be readable, or it might not contain valid XML data. In general, mAirList can never tell in advance whether loading will be successful.
I agree, but the circumstances of the specific test I tried were that the file ‘did not exist’ (in fact, I had misspelt the directory name).
mAirList correctly displayed a message box saying that it could not open the file, but only after it had cleared the Cartwall, presumably in anticipation of opening the file successfully.
Speaking as a fan of Visual BASIC (as you know!), I thought this was what you Delphi folks used try…catch…finally type syntax for? As in:try
(open the specified MLC file);
catch
(display message box and clean up);
finally
(clear Cartwall and THEN load from the MLC file);Sorry, but I couldn’t resist the programmer’s humour!
We do have these try/except things, however, this is not the point here - catching the exception, you could display your own message box, when not catching it (and it’s not catched by the GUI), Delphi will display the default one.
I have now modified the code such that closing of the players occurs after opening the file, parsing the XML data and identifying the “Cartwall” node. At that state, it is very likely that the file does contain valid cartwall data. This modification will be included in mAirList 2.0.3.