#---------------------------------------------------------------------- # Simple command processor. # # (C) March 5, 2018 -- Dr. William T. Verts # # New things: # # (1) Multiline strings. Use of """......""" or '''......''' allows # the string to span lines, and will include the line breaks as part # of the string. # # (2) Use of a Boolean (bool) to control the while loop. The loop # will run until the variable MoreToDo becomes false, which is one # of the user commands. # # (3) Capitalizing the string. This requires the string.upper # function, found in the string library. We must import the # string library. By capitalizing the string, it allows the user # to be sloppy about case on data-entry, and the program will adapt. # # (4) if-elif-else network and pass. We set up the tests for all the # commands we expect to eventually implement, but those we haven't # gotten to yet can be faked with the pass statement. When we get # around to writing the code, the pass will be replaced with the # correct functionality. # # (5) JES Input/Output. In pure Python we would use raw_input and # print, but in JES we can use requestString and showError instead. #---------------------------------------------------------------------- import string def Main(): Message = """Enter a Command from the list: QUIT INPUT PRINT SAVE BRIGHTEN DARKEN FOCUS EMBOSS CONTRAST Enter a command --- """ MoreToDo = True while (MoreToDo): S = string.upper(requestString(Message)) print S if (S == "QUIT" ): MoreToDo = False elif (S == "INPUT" ): pass elif (S == "PRINT" ): pass elif (S == "SAVE" ): pass elif (S == "BRIGHTEN"): pass elif (S == "DARKEN" ): pass else: showError("ERROR, " + S + " is not a legal command") return