Thank you for the reply.
So for example, the strings are in a file.
I have the way to grab each string line by line now I need to process each byte,so in say, FILE.txt there is.
Line 1 This is a string Hello world
Line2 The quick brown fox jumped over the lazy dog.
Now we need to get each byte in all the tokens and all the whites spaces and then compare them as we go along.
So some sort of function to get byte L then i then n then e etc...
And a block of if statements to compare them to so if tokens Line = Line check byte 1 or 2. This needs to be done on a line per line bases not as a whole.
Code Snippet:
Code: Select all
@echo off
setlocal
:: BEGIN_FUNCTION
set val=1
:BeginLoop
set Str=Hello World.
call set "StrByte=%%Str:~0,%val%%%"
echo.%StrByte%
if /i "%StrByte%"=="%Str%" (
goto :Script
)
set /a val=%val%+1
goto :BeginLoop
:: END_FUNCTION
:Script
echo.String=%Str%
echo.Bytes=%val%
Just adds 1 to the value as it goes along, so if there was an if statement that said if %strbyte%==w echo.found w
would not work because at the given time the actual string is Hello W not just W
The above produces output like so,
H
He
Hel
Hell
Hello
Hello
Hello W
Hello Wo
Hello Wor
Hello Worl
Hello World
Hello World.
String=Hello World.
Bytes=12
-----------------------------------------
Where as it should produce like so,
H
e
l
l
o
W
o
r
l
d
.
String=Hello World.
Bytes=12
So to solve this problem I do this
Code: Select all
set val=1
:BeginLoop1
set Str1=Hello World.
call set "StrByte=%%Str1:~0,%val%%%"
set Str2=%StrByte%
call set "StrChar=%Str2:~-1%"
if /i "%StrChar%"=="W" echo.Found W
echo.%StrChar%
if /i "%StrByte%"=="%Str1%" (
goto :Script
)
set /a val=%val%+1
goto :BeginLoop1
Which gives me the desired result.
Now I am wondering if there are some other work arounds for accomplishing this as in a neater nicer function, or just some other ideas.