|Got a working version that verifies every letter is unique. It assembles the values in a string and then does compares on the characters in the string.|
I had to change my user input philosophy. When the user finishes entering the Rn values, the last value will be blank (zero lenth string). When the user finishes entering the Bn values, the last value will be a # character.
This works well since the blank Rn value is not assembled in the string while the # Bn value is assembled as the last character in the string. So the string ends up looking like:
with no space between the I and J characters. But even if there was a space, it wouldn't have affected the results I don't think.
Here's my working program in case it helps someone else. Or maybe someone can come up with a simpler version. The meat of the program is from :LOOP1 to :ERROR".
:: These variables would be set up by the user
echo string is %S%
:: echo displays "string is EFGHIJKLMN#"
:: Set initial counts
:: Compare letters. Check for end of string # to end passes.
:: Check for end of string # to exit when no dups found.
if "!S:~%P1%,1!"=="!S:~%P2%,1!" goto :ERROR
if "!S:~%P2%,1!"=="#" goto :PASS_BUMP
if "!S:~%P1%,1!"=="#" goto :CONTINUE
set /a P2+=1
set /a P1+=1
set /a P2base+=1
echo --- Duplicate letter found = !S:~%P1%,1! ---
echo Do user input again
echo --- No duplicates found ---
:: Continue with program
--- IGNORE THIS PARAGRAPH. See EDIT below. ---
One thing I need help on. When I tried to do the echo command in the :ERROR routine as:
echo Dup letter is !S:~%P1%,1!
It wouldn't work. So I had to set that value in the variable named "var" first and then do the echo. Any suggestions on how to do it in the echo command without having to set it in a variable first?
EDIT: nbrane let me know that the echo command should have worked. He/she is correct and I must have had a typo in my batch code while testing. I corrected the echo code above and eliminated the unnecessary set var statement.