Fixed up the interactive interface to include a cancel option when modifying variable properties.

This commit is contained in:
2020-04-20 02:57:54 -05:00
parent 57b2a236a3
commit e360323490
2 changed files with 27 additions and 15 deletions
+13 -11
View File
@@ -25,12 +25,19 @@ def modify_variable(var, vars):
response = input("Select a property to modify for %s or q to exit property modifying: " %(var.name))
if response == "type":
response = input("Enter the type of variable this is (currently %s): " %(var.type))
response = input("Enter the type of variable this is (currently %s) or c to cancel: " %(var.type))
if response == "c" or response == "C":
continue
vars[var.name].type = response
print("Updated to %s." %(response))
elif response == "start":
response = input("Enter the variable's starting point (currently %f): " %(var.starting_point))
response = input("Enter the variable's starting point (currently %f) or c to cancel: " %(var.starting_point))
if response == "c" or response == "C":
continue
try:
vars[var.name].starting_point = float(response)
@@ -39,15 +46,10 @@ def modify_variable(var, vars):
print("The starting point must be a number.")
elif response == "end":
response = input("Enter the variable's ending point (currently %f): " %(var.ending_point))
try:
vars[var.name].ending_point = float(response)
print("Updated to %f." %(float(response)))
except ValueError:
print("The ending point must be a number.")
pass
response = input("Enter the variable's ending point (currently %f) or c to cancel: " %(var.ending_point))
if response == "c" or response == "C":
continue
elif response == "q":
return
+14 -4
View File
@@ -31,12 +31,19 @@ def modify_variable(var, vars):
response = input("Select a property to modify for %s or q to exit property modifying: " %(var.name))
if response == "type":
response = input("Enter the type of variable this is (currently %s): " %(var.type))
response = input("Enter the type of variable this is (currently %s) or c to cancel: " %(var.type))
if response == "c" or response == "C":
continue
vars[var.name].type = response
print("Updated to %s." %(response))
elif response == "start":
response = input("Enter the variable's starting point (currently %f): " %(var.starting_point))
response = input("Enter the variable's starting point (currently %f) or c to cancel: " %(var.starting_point))
if response == "c" or response == "C":
continue
try:
vars[var.name].starting_point = float(response)
@@ -45,8 +52,11 @@ def modify_variable(var, vars):
print("The starting point must be a number.")
elif response == "end":
response = input("Enter the variable's ending point (currently %f): " %(var.ending_point))
response = input("Enter the variable's ending point (currently %f) or c to cancel: " %(var.ending_point))
if response == "c" or response == "C":
continue
try:
vars[var.name].ending_point = float(response)
print("Updated to %f." %(float(response)))