I'm trying to get data from a file and store it in a variable for later use in my batch file.
Code example
SETLOCAL EnableDelayedExpansion
:: Reading a line in from a file
for /f "tokens=2 delims=:" %%a in (input.txt) do (
SET "TEMP=%%a"
echo %%a
echo %TEMP%
REM I want TEMP to be set to the value of %%a after the first character
SET "TEMP=%%a:~1%"
)
ENDLOCAL
Data inside input.txt:
O: Dracorex Hivelord, VE, SG, OV, AW, NM, Living Dam, BR, EV, VE #2
R: Silus the Corrupt, EV, OS, EB, VE, BR, DH, BV
The result that I'm getting when testing to see if its working the way I want:
SET temp=! Silus the Corrupt, EV, OS, EB, VE, BR, DH, BV!
ENDLOCAL & SET TEMP=C:\Users\THOMAS~1\AppData\Local\Temp
echo Silus the Corrupt, EV, OS, EB, VE, BR, DH, BV
echo C:\Users\THOMAS~1\AppData\Local\Temp
Can't seem to find out what I'm doing wrong.
Another part that I'm trying to do
for /f "tokens=*" %%a in (input2.txt) do (
SET STR=%%%a:~26, 6%
call :GetWinChance %STR%
)
Data inside input2.txt
Optimized Deck: 9 units: 86.6667: Dracorex Hivelord, Astral Strutter, Stonewall Garrison, Living Dam, Barracus Redeemed, Vile Emergence #2, Oluth's Volition, Nettle Miscreant, Atomic Wardriver
Optimized Deck: 10 units: 100%: Dracorex Hivelord, Astral Strutter, Stonewall Garrison, Living Dam, Barracus Redeemed, Vile Emergence #2, Oluth's Volition, Nettle Miscreant, Atomic Wardriver
and the results that I'm getting:
E:\Programs\Tyrant Unleashed Optimizer>(
SET STR=%~26, 6
call :GetWinChance
)
Going to try and explain what I want
I want it so I can have in the first code sample that I get
Dracorex Hivelord, VE, SG, OV, AW, NM, Living Dam, BR, EV, VE #2
Silus the Corrupt, EV, OS, EB, VE, BR, DH, BV
as the values to be used while in the for loop.
In the second code sample I want to get it so I have the win chance which is contained in the 6 characters after the first 26 like so:
"86.666"
" 100: "
so I can use my function :GetWinChance (which I've tested with a variable that is set to a string to interpret the text into a percentage of win.