Effacer les filtres
Effacer les filtres

Toggling Shift button in Calculator GUI

1 vue (au cours des 30 derniers jours)
Muhammad Ali Qadar
Muhammad Ali Qadar le 20 Déc 2012
I have been Understanding the Calculator already made in Matlab, I have seen that if we click on shift button first time then shift=1 and it remains 1 till we restart the program, So What I want that when I first time click on it, should set shift=1 and if I click again it Should set it to 0 e.g shift=0; I have Problem here
function pushbutton26_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton26 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global jj shift
shift=1;
Can Somebody let me know how can I toggle this button. All of the Files are available here at the following link.

Réponse acceptée

Jan
Jan le 20 Déc 2012
This program has been created by GUIDE. This causes ugly names like "pushbutton26_Callback". The shift-status is most likely store in the global variable "shift".
Ugly function names accompanied with global variables and a poor documentation of the code are a bad programming style. I understand that GUIDE is responsible for this, but posting such code and asking others for changes hits a critical point: Any tiny change requires an exhaustive analysis of the code to avoid unwanted side-effects. A really professional advice would be: Do not modify foreign code if it has a low quality already.
It is possible, perhaps you have only change the last line from "shift=1" to "shift=1-shift". But it is tedious to check if this is correct, while it is easy to test if this is working appearently.
  3 commentaires
Jan
Jan le 20 Déc 2012
You can add something like this to the callbacks of all concerned buttons:
global shift;
... The processing of the button's function
shift = 0;
Muhammad Ali Qadar
Muhammad Ali Qadar le 20 Déc 2012
Modifié(e) : Muhammad Ali Qadar le 24 Déc 2012
yes that's very nicely working, Thank You so much.
regards.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming Utilities dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by