[SOLVED] Using global flags to advance in a script

10 views (last 30 days)
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

Accepted Answer

JV
JV on 6 Jan 2021
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

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!