(initget "Addition Subtraction")
(setq uc (getkword "\n[Addition/Subtraction]? <A>: "))
The or was put there for a reason. ^ that is the reason.
Run this code and right click. My previous code was untested and as such there were a few mistakes. In here, I've corrected some. Note the forward slash between addition and subtraction. Why? The square braces that surround them. If you run this code then right click, you will see the two words inside them in your popup menu, which you can then click. Also, you'll notice the lengthening of the initget string area to "Addition Subtraction". This is so that if you or anybody else using your code uses the right click option it will be a valid input. Now, the <A>. <> Letters contained within those are supposed to mean that <A> in this case is the default answer. In other words, you can hit enter to achieve the same goal as hitting A or typing Addition. Think about it. If you do this <A/S>, what is the default, A or S? If I were using this program and I got to this portion of it, how would I know what would happen if I hit enter? Well, if I don't find out what's happening when I hit enter and don't code for it, then nothing should happen. With the initget function set to 1 you disallow the user the option to hit enter and achieve what the <> are for. So, you'll notice the number 1 is now missing. Now we should get a return value when hitting enter. The answer should be nil. Therefore, we program the function to recieve nil or Addition as the same answer by writing (or (= uc nil) (= uc "Addition")). Notice I changed the option to Addition instead of A. That is why the square brackets [], will work with the right click. How does A work then, if that's all you typed? Initget allows the letter A or the whole word Addition to be used, but it only returns the full Keyword it was supplied. What if you wanted the user not to hit enter to mean A or S? What should it mean? Does the user run this command, then feel before answering A or S that he didn't want to run it? If so, and it's very possible, he is consigned to continue or hit escape. You don't want him, most likely to do that, right? It's a bad idea to force users into using escape. I have a co-worker who uses it all the time. It drives me nuts. Anyway, what can you do, right? Well, A nor S has to be the default? What do we do? Try this:
(initget "Addition Subtraction Exit")
(setq uc (getKword "\n[Addition/Subtraction]<E>xit: "))
Then instead of if, you might consider cond. Huh? I'm just getting used to if! Here's an example.
(cond ((= uc "Addition")
(additup +)
)
((= uc "Subtraction")
(additup -)
)
((or (= uc "Exit") (= uc nil))
(a good error trap might be best here)
)
)
Of course, you could also leave the exit block out all together, but that would cause unexpected errors to happen when the code continues to run. I tried (exit) and (quit) but have never liked them in the past. They seem to shut down autocad, instead of just ending the command. That may not be the case, though, but sending the command to an error trap, would exit out and reset any variables that you may have needed to change on your user. That is also why you want to keep users out of the habit of hitting escape, but an error trap should also account for that. I say should because the user I mentioned before doesn't just hit escape once or twice. He hits it repeatedly very fast. I tested that once to see if I could cancel the error trap. I was able to. The values weren't reset.