based on
https://stackoverflow.com/questions/583 ... batch-file
below is my code to find out string length of a variable called
Code: Select all
SET trace_log_script_name_prefix=%until_number%_%scn_or_sequence%_%source_host_db%_%log_datetime%_%rman_script_prefix%
call :strlen result trace_log_script_name_prefix
REM ********* function *****************************
:strlen <resultVar> <stringVar>
(
setlocal EnableDelayedExpansion
echo argument %~2
exit /b
(set^ tmp=!%~2!)
if defined tmp (
set "len=1"
for %%P in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do (
if "!tmp:~%%P,1!" NEQ "" (
set /a "len+=%%P"
set "tmp=!tmp:~%%P!"
)
)
) ELSE (
set len=0
)
)
(
endlocal
set "%~1=%len%"
exit /b
)
Code: Select all
setlocal EnableDelayedExpansion
echo argument C:\PROGRA~1\avs\bin
exit /b
(set tmp=!C:\PROGRA~1\avs\bin! )
if defined tmp (
set "len=1"
for %P in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do (if "!tmp:~%P,1!" NEQ "" (
set /a "len+=%P"
set "tmp=!tmp:~%P!"
) )
) ELSE (set len=0 )
)
argument C:\PROGRA~1\avs\bin
so how do I access the argument passed in a function? It seems that no matter how I setlocal, arguments seems to equate the the glocal value.
many thanks in advance!