It should display per letter from a word that is pulled from the file Woorden.txt. And per letter check which letter it is, and change some values. Then go to the next letter and continue till all letters are processed. Then go to the next word on the list and go through the process again, until all words are processed.
Even if the error is fixed so that the %calc% does show the correct letter, and processes the name from the file Woorden.
How would I make the loop so that after all letters of a word are processed that it doesnt exit like it does now, but that it continuous to extract the next word in the file Woorden.txt?
Code: Select all
aecho off
setlocal enabledelayedexpansion
setlocal enableextensions
:variable
set simplenum=
set previousword=%word%
set word=
set characters=
set reverseword=
set startw=0
set lengthw=1
set calc=
:nextletter
for /f "tokens=1* delims=" %%A in (woorden.txt) do (
call set calc=%%A:~%startw%,%lengthw%%%%
call :calculate
set /a startw=%startw%+1
goto nextletter
:calculate
IF '%calc%' EQU '' echo EXIT
IF '%calc%' EQU 'a' set /a simplenum=%simplenum%+1&&set /a characters=%characters%+1&&set word=%word%A&&echo %word%&&set reverseword=%reverseword%Z
IF '%calc%' EQU 'b' set /a simplenum=%simplenum%+2&&set /a characters=%characters%+1&&set word=%word%B&&echo %word%&&set reverseword=%reverseword%Y
IF '%calc%' EQU 'c' set /a simplenum=%simplenum%+3&&set /a characters=%characters%+1&&set word=%word%C&&echo %word%&&set reverseword=%reverseword%X
IF '%calc%' EQU 'd' set /a simplenum=%simplenum%+4&&set /a characters=%characters%+1&&set word=%word%D&&echo %word%&&set reverseword=%reverseword%W
IF '%calc%' EQU 'e' set /a simplenum=%simplenum%+5&&set /a characters=%characters%+1&&set word=%word%E&&echo %word%&&set reverseword=%reverseword%V
IF '%calc%' EQU 'f' set /a simplenum=%simplenum%+6&&set /a characters=%characters%+1&&set word=%word%F&&echo %word%&&set reverseword=%reverseword%U
IF '%calc%' EQU 'g' set /a simplenum=%simplenum%+7&&set /a characters=%characters%+1&&set word=%word%G&&echo %word%&&set reverseword=%reverseword%T
IF '%calc%' EQU 'h' set /a simplenum=%simplenum%+8&&set /a characters=%characters%+1&&set word=%word%H&&echo %word%&&set reverseword=%reverseword%S
IF '%calc%' EQU 'i' set /a simplenum=%simplenum%+9&&set /a characters=%characters%+1&&set word=%word%I&&echo %word%&&set reverseword=%reverseword%R
IF '%calc%' EQU 'j' set /a simplenum=%simplenum%+10&&set /a characters=%characters%+1&&set word=%word%J&&echo %word%&&set reverseword=%reverseword%Q
IF '%calc%' EQU 'k' set /a simplenum=%simplenum%+11&&set /a characters=%characters%+1&&set word=%word%K&&echo %word%&&set reverseword=%reverseword%P
IF '%calc%' EQU 'l' set /a simplenum=%simplenum%+12&&set /a characters=%characters%+1&&set word=%word%L&&echo %word%&&set reverseword=%reverseword%O
IF '%calc%' EQU 'm' set /a simplenum=%simplenum%+13&&set /a characters=%characters%+1&&set word=%word%M&&echo %word%&&set reverseword=%reverseword%N
IF '%calc%' EQU 'n' set /a simplenum=%simplenum%+14&&set /a characters=%characters%+1&&set word=%word%N&&echo %word%&&set reverseword=%reverseword%M
IF '%calc%' EQU 'o' set /a simplenum=%simplenum%+15&&set /a characters=%characters%+1&&set word=%word%O&&echo %word%&&set reverseword=%reverseword%L
IF '%calc%' EQU 'p' set /a simplenum=%simplenum%+16&&set /a characters=%characters%+1&&set word=%word%P&&echo %word%&&set reverseword=%reverseword%K
IF '%calc%' EQU 'q' set /a simplenum=%simplenum%+17&&set /a characters=%characters%+1&&set word=%word%Q&&echo %word%&&set reverseword=%reverseword%J
IF '%calc%' EQU 'r' set /a simplenum=%simplenum%+18&&set /a characters=%characters%+1&&set word=%word%R&&echo %word%&&set reverseword=%reverseword%I
IF '%calc%' EQU 's' set /a simplenum=%simplenum%+19&&set /a characters=%characters%+1&&set word=%word%S&&echo %word%&&set reverseword=%reverseword%H
IF '%calc%' EQU 't' set /a simplenum=%simplenum%+20&&set /a characters=%characters%+1&&set word=%word%T&&echo %word%&&set reverseword=%reverseword%G
IF '%calc%' EQU 'u' set /a simplenum=%simplenum%+21&&set /a characters=%characters%+1&&set word=%word%U&&echo %word%&&set reverseword=%reverseword%F
IF '%calc%' EQU 'v' set /a simplenum=%simplenum%+22&&set /a characters=%characters%+1&&set word=%word%V&&echo %word%&&set reverseword=%reverseword%E
IF '%calc%' EQU 'w' set /a simplenum=%simplenum%+23&&set /a characters=%characters%+1&&set word=%word%W&&echo %word%&&set reverseword=%reverseword%D
IF '%calc%' EQU 'x' set /a simplenum=%simplenum%+24&&set /a characters=%characters%+1&&set word=%word%X&&echo %word%&&set reverseword=%reverseword%C
IF '%calc%' EQU 'y' set /a simplenum=%simplenum%+25&&set /a characters=%characters%+1&&set word=%word%Y&&echo %word%&&set reverseword=%reverseword%B
IF '%calc%' EQU 'z' set /a simplenum=%simplenum%+26&&set /a characters=%characters%+1&&set word=%word%Z&&echo %word%&&set reverseword=%reverseword%A
)
echo %simplenum% %word%>>DATAbases.txt
GOTO :EOF
Content of Woorden.txt:
we
were
werein
whatiteachyou
howtoget
makethis
makethiswork
cometogether
information
After running this batchscript from a CMD /K, command prompt I get the message:
1' was unexpected at this time
IF 'we:~0,1' EQU '' EXIT
Code: Select all
call set calc=%%A:~%startw%,%lengthw%%%%
I think the error is in this particular line, but I dont know for sure.
What is causing the error to come up?
I also want to ask what the proper way of using the call set command is. As far as my research goes, I couldnt find proper info.
Have I used the right code here to set the calc value to the 0,1 position of a string?
I want the first letter of a word which is in the variable %%A to be set to the variable calc.
And after that, I increase the variable, and check for the second letter, the third, fourth etc.
Which below that line is checked with a series of IF's.
Code: Select all
call set calc=%%A:~%startw%,%lengthw%%%%
call :calculate
set /a startw=%startw%+1
goto nextletter
:calculate
IF '%calc%' EQU '' echo EXIT
IF '%calc%' EQU 'a' set /a simplenum=%simplenum%+1&&set /a characters=%characters%+1&&set word=%word%A&&echo %word%&&set reverseword=%reverseword%Z
After each cycle of checking which letter is found in the %calc% variable, I want it to return to this command:
call :calculate
And start the process again with the next letter. Im not sure if my current use of the FOR loop and closing parenthesis is done in the right way. Because I think the GOTO :EOF command should be on the inside of the loop, and not on the outside of the FOR loop.
How do I solve these problems?
I wish to have provided enough information. And im willing to provide clarify if needed.
Thanks in advance