movesuccessful=0;
if dimension==1;
if (0<currentgraphx) & (currentgraphx<=columnsshown) & (1<=currentgraphy) & (currentgraphy<=rows) & (movebuttondownvalue==1);
if changersafety==0 | (changersafety==1 & currenty==totalrows)
movesuccessful=1;
selectedoriginrow=currenty; selectedorigincol=currentx; selectedoriginiteration=1;
selectedendrow=currenty; selectedendcol=currentx; selectedenditeration=1;
else;
errordlg('Can only change latest state','Error');
end;
end;
end;
if dimension==2
if (0<currentgraphx) & (currentgraphx<=columnsshown) & (0<currentgraphy) & (currentgraphy<=rowsshown) & (movebuttondownvalue==1);
if changersafety==0 | (changersafety==1 & currentiteration==completediterations)
movesuccessful=1;
selectedoriginrow=currenty; selectedorigincol=currentx; selectedoriginiteration=currentiteration+1;
selectedendrow=currenty; selectedendcol=currentx; selectedenditeration=currentiteration+1;
else;
errordlg('Can only change latest state','Error');
end;
end;
end;
if movesuccessful==1;
CA_Display; % Paste doesn't seem to work unless this is run first
undo; % This is necessary to remove each successive paste during the move
paste_selection;
selectedendrow=selectedoriginrow+acopiedrows-1;
selectedendcol=selectedorigincol+acopiedcol-1;
selectedenditeration=selectedenditeration2-acopiediteration+1;
CA_Display;
end;