part two of stringparsing.bat problems
Ok so everything's working with my stringparsing.bat program, i can successfully create, encode, and display the text files. However now the problem arises that it will not decode the the text file after encoding it. Say if the encoded text file contains:
20 18 1 9 14 19
When i decode it using this script:
@echo off
cls
echo.
echo.
echo.
echo.
echo.
echo Decoding Your Language File... Please Wait...
echo.
echo.
echo.
for /f "delims=" %%i in (!name1!.txt) do (
set var1=%%i
set var1=!var1:1 =a !
set var1=!var1:2 =b !
set var1=!var1:3 =c !
set var1=!var1:4 =d !
set var1=!var1:5 =e !
set var1=!var1:6 =f !
set var1=!var1:7 =g !
set var1=!var1:8 =h !
set var1=!var1:9 =i !
set var1=!var1:10 =j !
set var1=!var1:11 =k !
set var1=!var1:12 =l !
set var1=!var1:13 =m !
set var1=!var1:14 =n !
set var1=!var1:15 =o !
set var1=!var1:16 =p !
set var1=!var1:17 =q !
set var1=!var1:18 =r !
set var1=!var1:19 =s !
set var1=!var1:20 =t !
set var1=!var1:21 =u !
set var1=!var1:22 =v !
set var1=!var1:23 =w !
set var1=!var1:24 =x !
set var1=!var1:25 =y !
set var1=!var:26 =z !
set var1=!var1:27 =. !
set var1=!var1:28 =, !
echo Verifying Content...
)
echo %var1% > %name1%.txt
echo Decoding Complete!
TIMEOUT /t 1 /nobreak > nul
I get:
t 1h a i 1d 1i
Because when the program decodes the letter r (which is 18) it mistakes the 8 in 18 for the letter h and therefore puts 1h... so is there a way to make it a specific search and replace? (similar to if your typing a path to a file with spaces in it,you would put quotes around the path and file name) If so what would the format be?
EDIT Heres the current script for the stringparsing.bat program:
@echo off
setlocal enabledelayedexpansion
title BETA
cls
cd /d F:\script\st
echo.
echo.
echo.
echo Setting Variables...
echo Loading Language Database...
set beepset=true
:: ###################################################################################
:: CALLING VARIABLE DATABASE CALLING VARIABLE DATABASE CALLING VARIABLE DATABASE
:: ###################################################################################
TIMEOUT /t 5 /nobreak > nul
goto MAIN
:MAIN
cls
IF %beepset%==true echo
echo =================================================================================
echo.
echo Please type a name for your new language file:
echo =================================================================================
set /p name=
cls
echo.
echo.
echo.
echo ==============================================================
echo ##############################################################
echo #============================================================#
echo # #
echo # - Create the file you would like to encode. #
echo # #
echo ##############################################################
echo # #
echo # - How many lines of text will your file have? #
echo # #
echo #============================================================#
echo ##############################################################
echo ==============================================================
set /p linecount=
cls
set foo=0
set linenumber=0
:lineset
set /a linenumber=linenumber+=1
set /p line1=%linenumber%
echo. >> %name%.txt
echo %line1% >> %name%.txt
set /a foo=foo+1
IF %foo%==%linecount% goto MAIN123
goto lineset
:ENCODE
title Step 2
cls
echo.
echo.
echo.
echo. =================================================================================
echo.
echo Please type a name of the File you want to Encode:
echo.
echo. =================================================================================
set /p name2=
echo.
echo.
echo.
echo.
echo.
echo Encoding Your Language File... Please Wait...
echo.
echo.
echo.
for /f "delims=" %%i in (!name2!.txt) do (
set var=%%i
set var=!var:a=1 !
set var=!var:b=2 !
set var=!var:c=3 !
set var=!var:d=4 !
set var=!var:e=5 !
set var=!var:f=6 !
set var=!var:g=7 !
set var=!var:h=8 !
set var=!var:i=9 !
set var=!var:j=10 !
set var=!var:k=11 !
set var=!var:l=12 !
set var=!var:m=13 !
set var=!var:n=14 !
set var=!var:o=15 !
set var=!var:p=16 !
set var=!var:q=17 !
set var=!var:r=18 !
set var=!var:s=19 !
set var=!var:t=20 !
set var=!var:u=21 !
set var=!var:v=22 !
set var=!var:w=23 !
set var=!var:x=24 !
set var=!var:y=25 !
set var=!var:z=26 !
set var=!var:.=27 !
echo Verifying Content...
)
echo %var% > %name2%.txt
echo Encoding Complete!
TIMEOUT /t 1 /nobreak > nul
goto MAIN123
:DECODE
title Decode...
echo.
echo.
echo.
echo =================================================================================
echo.
echo Please type a name of the File you want to decode:
echo.
echo ===========开发者_如何学Go======================================================================
set /p name1=
:decoderscript
cls
echo.
echo.
echo.
echo.
echo.
echo Decoding Your Language File... Please Wait...
echo.
echo.
echo.
for /f "delims=" %%i in (!name1!.txt) do (
set var1=%%i
set var1=!var1:1 =a !
set var1=!var1:2 =b !
set var1=!var1:3 =c !
set var1=!var1:4 =d !
set var1=!var1:5 =e !
set var1=!var1:6 =f !
set var1=!var1:7 =g !
set var1=!var1:8 =h !
set var1=!var1:9 =i !
set var1=!var1:10 =j !
set var1=!var1:11 =k !
set var1=!var1:12 =l !
set var1=!var1:13 =m !
set var1=!var1:14 =n !
set var1=!var1:15 =o !
set var1=!var1:16 =p !
set var1=!var1:17 =q !
set var1=!var1:18 =r !
set var1=!var1:19 =s !
set var1=!var1:20 =t !
set var1=!var1:21 =u !
set var1=!var1:22 =v !
set var1=!var1:23 =w !
set var1=!var1:24 =x !
set var1=!var1:25 =y !
set var1=!var:26 =z !
set var1=!var1:27 =. !
set var1=!var1:28 =, !
echo Verifying Content...
)
echo %var1% > %name1%.txt
echo Decoding Complete!
TIMEOUT /t 1 /nobreak > nul
goto MAIN123
:DISPLAY
cls
echo.
echo.
echo.
echo Please type the name of the file you want to display:
set /p displayfile=
type %displayfile%.txt
echo.
echo hit enter to go to Main Menu...
pause > nul
goto MAIN123
:END
cls
title SHUTTING DOWN...
echo.
echo.
echo.
echo Terminating service stream...
echo.
echo.
echo.
echo.
echo Done! Thank you for using this program!
TIMEOUT /t 2 /nobreak > nul
::(%xx%) -1 I/O Stream= "SHELL.dll"
:: IF EXIST [&1[Parser_2009]] exit
Exit
I get:
t 1h a i 1d 1i
Because when the program decodes the letter r (which is 18) it mistakes the 8 in 18 for the letter h and therefore puts 1h... so is there a way to make it a specific search and replace? (similar to if your typing a path to a file with spaces in it,you would put quotes around the path and file name) If so what would the format be?
Aha, you got the problem. And you see the cause. The 18 is replaced by the line
set var1=!var1:8 =h !
before the correct line can replace it
set var1=!var1:18 =r !
If you can't solve the problem, then there's no room for hope. :-)
精彩评论