(this question is relative to the tech support phone message I left 5/25/2011, ~9:00 EDT)
I’ve been working on a table editor. I need to be able to compare the sequence number that got entered into a text field. If it matches the sequence number of another row, it should fail (so that you can’t have two rows with the same number). If it’s the same as the row that got picked, it should permit the change. Here’s what I have:
origpointer = event.source.parent.getComponent('Field_Pointer').text seqpointer = event.source.parent.getComponent('Field_Pointer').text sequence = event.source.parent.getComponent('Field_Sequence').text prompt = event.source.parent.getComponent('Text Area_Prompt').text if seqpointer != "" and system.db.runScalarQuery("SELECT COUNT(*) FROM prompt_file WHERE seqpointer = '%s'" % seqpointer) > 0 and seqpointer != origpointer: system.gui.messageBox("Sequence Pointer already exists.") elif seqpointer == "": system.gui.messageBox("Pointer field cannot be empty.") elif sequence == "": system.gui.messageBox("Sequence field cannot be empty.") else: system.db.runPrepUpdate("UPDATE prompt_file SET `sequence` = ?, `prompt` = ? WHERE `seqpointer` = ?", [sequence, prompt, seqpointer]) system.nav.closeParentWindow(event)
Basically, if pointer 87 is selected, it should allow pointer 87 to be edited. But if pointer 87 is selected, the user should not be able to change “87” to “88” if pointer 88 already exists. If “88” does NOT exist, then pointer 87 should become pointer 88. Does that make sense?