Author Topic: 2.0.2: Bad name in CARTWALL LOAD SET clears Cartwall  (Read 3171 times)

Cad

  • Regular
  • *
  • Posts: 2260
  • 'Old school' radio guy (and PC programmer)
    • View Profile
2.0.2: Bad name in CARTWALL LOAD SET clears Cartwall
« on: December 28, 2006, 14:41:39 »
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.
--
BFN
CAD

Torben

  • Administrator
  • Doktor mAirList
  • *****
  • Posts: 16918
    • View Profile
2.0.2: Bad name in CARTWALL LOAD SET clears Cartwall
« Reply #1 on: December 28, 2006, 14:58:24 »
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.

Cad

  • Regular
  • *
  • Posts: 2260
  • 'Old school' radio guy (and PC programmer)
    • View Profile
Yes, but…
« Reply #2 on: December 29, 2006, 03:57:43 »
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:
Code: [Select]
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!
--
BFN
CAD

Torben

  • Administrator
  • Doktor mAirList
  • *****
  • Posts: 16918
    • View Profile
2.0.2: Bad name in CARTWALL LOAD SET clears Cartwall
« Reply #3 on: December 29, 2006, 09:10:03 »
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.


Torben

Cad

  • Regular
  • *
  • Posts: 2260
  • 'Old school' radio guy (and PC programmer)
    • View Profile
Thanks yet again
« Reply #4 on: December 29, 2006, 10:27:15 »
Thanks for the reply: that sounds like the right way to procees it.

And thanks even more for not pointing out that my Delphi psuedocode was completely wrong, now I look at it again.

Oh well, it was very late when I typed it!
--
BFN
CAD