How can make the Ok button on the Message Box work?
6 views (last 30 days)
Show older comments
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 Comment
dpb
on 28 Nov 2016
What does "doesn't work" mean, specifically? And, minor detail, why not use errordlg which needs fewer arguments being already for errors?
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!