How can make the Ok button on the Message Box work?

조회 수: 6 (최근 30일)
Sarah Sadeq
Sarah Sadeq 2016년 11월 28일
댓글: dpb 2016년 11월 28일
Hello!
I'm working on a school project and I'm trying to display a message box that would display an error message to the user. It works, but the 'OK button' doesn't work. I'm confused on why doesn't it work.
That's half of my code.
function [ B,K,D,E,n_knights,quit] = next_move(B,K,D,E,n_knights)
%the number of kings in the game
n_kings = nnz(K);
n = max(size(B));
% display a blank or space to break between the strings so that the player
% could look at the strins clearly
disp(' ')
% display the number of the initial knights which is usually 10 and the initial number of kings
disp(['You have ',num2str(n_knights),' knights and there are ', num2str(n_kings),' kings']);
%would display the board by calling the function diplay_board
%the user has the board and the knowledge of the number of kings and
%knights in his disposel to start the game and his first move
disp(' ');
disp('here is the board');
disp(' ');
display_board(B);
disp(' ');
%player enters his/her first move
r = input('enter the next row you wish to explore sire: ');
c = input('enter the next column you wish to explore sire: ');
%check if the move that the user enters is not negative, nor an integer
%check also if it agrees with the demissions of the board (meaning if it exceeds the deminsions of the board or less than the demisions)
%also check if its a character or empty(user does not input anything)
while ( ischar(r) || ischar(c) || isempty(r) || isempty(c))
disp(' ')
msgbox('You have left an answer blank, or entered a non-numeric value. Please, try again.','Error','error');
disp(' ');
display_board(B);
disp(' ');
r = input('enter the next row you wish to explore sire: ');
c = input('enter the next column you wish to explore sire: ');
end
I would appreciate the help1
  댓글 수: 1
dpb
dpb 2016년 11월 28일
What does "doesn't work" mean, specifically? And, minor detail, why not use errordlg which needs fewer arguments being already for errors?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Board games에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by