'keyboard' calls fail outside try..catch when try..catch contains a keyboard call

2 ビュー (過去 30 日間)
jessupj
jessupj 2020 年 9 月 10 日
編集済み: jessupj 2020 年 9 月 10 日
R2020a. this is driving me nuts this morning.
function dummyout = check_kb(DUMMYARG)
fprintf('check which keyboard\n')
which keyboard
fprintf('call keyboard\n')
keyboard
try A=fake_cmd; catch fprintf('catch kb\n');keyboard end
I have this MWE function. It fails. The FIRST keyboard statement returns an error that
Unrecognized function or variable 'keyboard'.
even theough the previous line (which keyboards) show that it is found as a built-in.
The problem seems to be that calling keyboard in the try/catch loop makes keyboard undefined outside of the try catch. If I remove the try/catch, or even just the 'keyboard' portion in the catch, the first keyboard call is then defined.
What i'm after is a better understanding of why this happens. Workarounds are easy, but this seems pathological and it would help me (and others) better use the debugger.

採用された回答

Fangjun Jiang
Fangjun Jiang 2020 年 9 月 10 日
There is no problem running the code in R2020a.
  1. run "which -all keyboard" to see if there are other function called keyboard
  2. Don't put try-catch-end statements in one line.
  1 件のコメント
jessupj
jessupj 2020 年 9 月 10 日
編集済み: jessupj 2020 年 9 月 10 日
yeah. for whatever reason, I had to reboot my system to get the error to stop.
But it was producing an error that 'keyboard' was undefined with only the built-in keyboard function found by which (the '-all' option had no change in effect). this happened in even after closing/restarting matlab and must have been a system environment problem/snafu.
thanks for checking it out!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDesktop についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by