I have recently been working on a desktop PAI (Partial Artificial Intelligence) that will be able to perform some basic tasks for me while I am not at my computer.
However, I want it to choose and say 1 of 9 different possible messages. For example, I have 9 different ways to say "How can I help you?", and I want it to choose and echo one of those 9 ways.
To do this, I want to use the variable %RANDOM%. The problem is that %RANDOM% generates a random number in between 0 and 32767, and I only want it to generate a random number in between 1 and 9.
I have seen multiple people across the internet say to use the piece of code:
SET /a rand=(%RANDOM%*9/32768)+1
However, this does not work. Or maybe it does for some people, but certainly not for me. Whenever I implement this into a batch file, it either just closes the window because it doesn't know how to run the code, or it just chooses the same number over and over again, no matter what.
I have also already tried it with and without Delayed Expansion, and if I try to run the code in the regular command prompt (CMD.EXE), it just says "Missing operator."
It's hard for me because I don't really know much about arithmetic in batch. Any help on fixing this is greatly appreciated!
Aucun commentaire:
Enregistrer un commentaire