Try and Catch In Pascal

前端 未结 3 1602
甜味超标
甜味超标 2021-01-19 18:11

I\'m using Dev-Pas 1.9.2 and am trying to make sure the program doesn\'t crash when a symbol or a letter value is entered.

I\'ve googled and googled and can\'t find

3条回答
  •  北海茫月
    2021-01-19 18:16

    (in addition to Ken White's)

    1. I think one can use READ for a char typed variable, and save the user to type enter.

    2. But I would go for a string typed version and use VAL.

      • It is something more encoding agnostic, and
      • the principle extends beyond value 9.
      • requires an enter though, and heavy input will mess up your screen.

    For the latter there are other methods (e.g. using unit Crt or Video), but that probably goes beyond the scope of the assignment

提交回复
热议问题