Azzera filtri
Azzera filtri

Toggling Shift button in Calculator GUI

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Jan
Jan il 20 Dic 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 Commenti
Jan
Jan il 20 Dic 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 il 20 Dic 2012
Modificato: Muhammad Ali Qadar il 24 Dic 2012
yes that's very nicely working, Thank You so much.
regards.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Programming Utilities in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by