Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Q. April
- Posts: 19
- Joined: 27 Jan 2018 14:36
- Location: Mayatopia
#1
Post
by Q. April » 04 Feb 2018 11:52
I want to make a dictionary that takes string from dic.txt but there is some problem, can someone help me ....
Code: Select all
@echo off
title Dictionary
:menu
cls
set /p wrd=
echo %wrd%
:: Option 1 confusing
:: FOR /F "tokens=* delims=" %%x in (dic.txt) DO FOR /L %%a IN (%wrd%,1,.) DO ECHO :: %%a & set data=%%a
:: Option 2 stuck
For /f "tokens=x delims=." %%A in (dic.txt) do echo %%A
echo %dic%
pause
goto menu
dic.txt
Code: Select all
cat(xxxxxxxxx).dog(xxxxxxxxx).chicken(xxxxxxxxx).
if i set wrd=dog output I want , dog(xxxxxxxxx)
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#2
Post
by aGerman » 04 Feb 2018 13:39
It's not a good idea to have everything in only one line. It makes processing difficult and there is a limit of 8191 characters for a string in Batch. Is there any possibility to write your dict.txt in a way to have a line for each pair?
Steffen
-
Q. April
- Posts: 19
- Joined: 27 Jan 2018 14:36
- Location: Mayatopia
#3
Post
by Q. April » 05 Feb 2018 16:24
i tried this method and it worked ,but only read single line,do you know how to made it read multiple line ?
Code: Select all
@echo off
Title Dictionary
:start
cls
set /p data=<Dic.txt&set /p w=
call set w=%%data:*%w%(=%%
set m=%w:)=&rem.%
If /i %m% == start (goto nf)
echo %m%
pause
goto start
:nf
echo.
echo Not Found
echo.
pause
goto start
Dic.txt
Code: Select all
start> cat(.cat.)dog(.dog.)chicken(.chicken.)
black(.black.)white(.white.)