[SOLVED] Using global flags to advance in a script

10 次查看(过去 30 天)
Hello fellow community
I want to make a script with converting it into a GUI in the future in mind. It's purpose is to run parts of an algorithm one after another when i want to. Here I've submitted simplified version to replicate my problem. I'll be extremelly thankful if you can help me.
global locate_Flag;
global aim_Flag;
global throw_Flag;
locate_Flag = 0;
aim_Flag = 0;
throw_Flag = 0;
if locate_Flag == 1
disp('located succesfully');
if aim_Flag == 1
disp('aimed succesfully');
if throw_Flag == 1
disp('threw succesfully');
else
throw_Flag_temp = num2str(throw_Flag);
input(throw_Flag_temp);
str2double(throw_Flag_temp)
throw_Flag = throw_Flag_temp;
end
else
aim_Flag_temp = num2str(aim_Flag);
input(aim_Flag_temp);
str2double(aim_Flag_temp)
aim_Flag = aim_Flag_temp;
end
else
locate_Flag_temp = num2str(locate_Flag);
input(locate_Flag_temp);
str2double(locate_Flag_temp)
locate_Flag = locate_Flag_temp;
end

采纳的回答

JV
JV 2021-1-6
Ok so I propably managed to solve this myself
global locate_Flag;
global aim_Flag;
global throw_Flag;
while(1)
locate_Flag = 0;
aim_Flag = 0;
throw_Flag = 0;
locate_Flag_temp = input('waiting for confirmation ');
locate_Flag = locate_Flag_temp;
clear locate_Flag_temp
if locate_Flag == 1
disp('located succesfully');
aim_Flag_temp = input('waiting for confirmation ');
aim_Flag = aim_Flag_temp;
clear aim_Flag_temp
if aim_Flag == 1
disp('aimed succesfully');
throw_Flag_temp = input('waiting for confirmation ');
throw_Flag = throw_Flag_temp;
clear throw_Flag_temp
if throw_Flag == 1
disp('threw succesfully');
end
end
end
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by