Some Explaination on these
Posted: 07 Jul 2013 23:37
My very first thread on Dostips
Hi,i'm looking for some explaination on few of the code blocks here
Source : http://www.zhihua-lai.com/acm/get-strin ... ows-batch/
How can the loop manage to exit properly?
from what i can understand, there is no change on
the var _subs (apart from substracting the first character)
Only _len is changing (increment for every loop.)
this is from dostips string manipulation section.
in particular
what does this two lines do?
and can we really use CALL SET (some examples if possible)
i thought call is for only calling
labels and external files.

Hi,i'm looking for some explaination on few of the code blocks here
Source : http://www.zhihua-lai.com/acm/get-strin ... ows-batch/
Code: Select all
@echo off
:: strlen.bat
:: http://acm.zhihua-lai.com
if [%1] EQU [] goto end
:loop
if [%1] EQU [] goto end
set _len=0
set _str=%1
set _subs=%_str%
:getlen
if not defined _subs goto result
:: remove first letter until empty
set _subs=%_subs:~1%
set /a _len+=1
goto getlen
:result
echo strlen("%1")=%_len%
shift
goto loop
:end
How can the loop manage to exit properly?
from what i can understand, there is no change on
the var _subs (apart from substracting the first character)
Only _len is changing (increment for every loop.)

this is from dostips string manipulation section.
Code: Select all
REM ---- Example 1: Translate name of month into two digit number ----
SET v=Mai
SET map=Jan-01;Feb-02;Mar-03;Apr-04;Mai-05;Jun-06;Jul-07;Aug-08;Sep-09;Oct-10;Nov-11;Dec-12
CALL SET v=%%map:*%v%-=%%
SET v=%v:;=&rem.%
ECHO.%v%
REM ---- Example 2: Translate abbreviation into full string ----
SET v=sun
set map=mon-Monday;tue-Tuesday;wed-Wednesday;thu-Thursday;fri-Friday;sat-Saturday;sun-Sunday
CALL SET v=%%map:*%v%-=%%
SET v=%v:;=&rem.%
ECHO.%v%
in particular
Code: Select all
CALL SET v=%%map:*%v%-=%%
SET v=%v:;=&rem.%
what does this two lines do?
and can we really use CALL SET (some examples if possible)
i thought call is for only calling
labels and external files.
