Mar-26-2018, 06:43 PM
Hi, there! I'm writing a program as a project and it is meant to assist users with simple tasks. I have my own set of commands that I have made global in my program. Most commands will not allow another command to be executed until the current one is completed or aborted.
Basically, data can be messed up if the "cancel" command I made is executed when no command is currently running.
What I was attempting to do was have a global indicator that changes from True and False depending on if a command is running.
However, I tried putting it in 100 different ways, and every time, it would be ignored or raise an error.
Is there some sort of way to make a proper indicator so my "cancel" command wont run if no other command is?
This is all jumbled up grammatically; I hope it is still decently legible.
I also apologize if my code looks like a wreck ^^; I just started because of an assignment and im worried its pretty silly looking..
This is the cancel command.
cmd(input) is just the default operation that prompts a command to run
lecnac is just the cancel command, but it doesnt reprompt with the same huge amount of text.
I understand that it looks like there'd still be no problem with this, but it's something I need to fix.
hopefully this will give enough explanation on what I am trying to do.
Basically, data can be messed up if the "cancel" command I made is executed when no command is currently running.
What I was attempting to do was have a global indicator that changes from True and False depending on if a command is running.
However, I tried putting it in 100 different ways, and every time, it would be ignored or raise an error.
Is there some sort of way to make a proper indicator so my "cancel" command wont run if no other command is?
This is all jumbled up grammatically; I hope it is still decently legible.
I also apologize if my code looks like a wreck ^^; I just started because of an assignment and im worried its pretty silly looking..
This is the cancel command.
cmd(input) is just the default operation that prompts a command to run
lecnac is just the cancel command, but it doesnt reprompt with the same huge amount of text.
I understand that it looks like there'd still be no problem with this, but it's something I need to fix.
def _cancel(): if COMMAND(t) == True: print('WARNING: Aborting a command will not save your data.') print('Continue? (yes/no)') print('') yn = input() if yn == str('yes'): print('Action aborted.') print('') cmd(input) elif yn == str('no'): print('Action resumed.') print('') else: print('') print('You did not follow the specified format. Please try again.') _lecnac() else: print('You are not currently running a command.') print('') cmd(input)I don't have an example of me trying to indicate what I was talking about, but I set up an example with my quit command (t/f), and
hopefully this will give enough explanation on what I am trying to do.
def _quit(): t print('Are you sure you want to quit? (yes/no)') yn = input() if yn == str('_cancel'): _cancel() if yn == str('yes'): print('Goodbye.') elif yn == str('no'): print('') f cmd(input) else: print('You did not follow the specified format. Please try again.') _quit()