Help debugging

attach is a sample of code I am testing. I am getting an error with the use of the SWITCH command. So what did I forget in the switch command?

The first line checks to see if the value which is an integer is greater than zero. if it is then it should pull up the current machine number that that employee is assigned and also the employee designator. Then it checks to make sure the old assigned machine is greater than zero. If so then it will use the employee designator which should be a capital O or H. If it is a capitol O then I want it to be equal to assigned_operator, and H would be assigned_assist1. The it will do an update query where it would use the now converted (using the switch command) transact. However everytime it comes to this switch command I get an error message, either being illegal or improper format. Any assistance greatly appreciate.

if ass_op>0:
old_mach = fpmi.db.runScalarQuery(“SELECT mach_num FROM Show_All_Employees_ACTIVE_INACTIVE WHERE ProdEmployeeID = %s”%ass_op,“mocrosoft”)
old_desc = fpmi.db.runScalarQuery(“SELECT [function] FROM Show_All_Employees_ACTIVE_INACTIVE WHERE ProdEmployeeID = %s”%ass_op,“mocrosoft”)
if (old_mach >= 0):
switch(old_desc,‘O’,‘H’,‘assigned_operator’,‘assigned_assist1’,’’)
fpmi.gui.messageBox("%s"%old_desc)
fpmi.db.runUpdateQuery(“UPDATE interim SET assigned_operator = 0 WHERE mach_num = %s”%old_mach,“mocrosoft”)

mrtweaver,

Please use the code tags to show any code. Now I’m assuming that your code looks like this (because indentation counts):if ass_op>0: old_mach = fpmi.db.runScalarQuery("SELECT ...") old_desc = fpmi.db.runScalarQuery("SELECT ...") if (old_mach >= 0): switch(old_desc,'O','H','assigned_operator','assigned_assist1','') fpmi.gui.messageBox("%s"%old_desc) fpmi.db.runUpdateQuery("UPDATE ...")
The error you are getting here (NameError: switch) is saying that there is no function called switch. It looks like you are confusing it with the expression language switch statement. I would just go with an if - else statement. ie:if ass_op>0: old_mach = fpmi.db.runScalarQuery("SELECT ...") old_desc = fpmi.db.runScalarQuery("SELECT ...") if (old_mach >= 0): if old_desc == 'O': new_desc = 'assigned_operator' elif old_desc == 'H': new_desc = 'assigned_assist1' else: new_desc = '' fpmi.gui.messageBox("%s"%old_desc) fpmi.db.runUpdateQuery("UPDATE ...")
Also, you aren’t assigning a variable to get the value of your switch, so I had to assume it was going into new_desc

Thanks Bob, I think you are right I was confusing the Expression and Jython Scripting. I forgot about ELIF. Thanks again and have a great day.