Description: |
call:ExtractFunction func |
Script: |
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17.
|
:ExtractFunction func -- extracts a function by label
:: -- func [in] - name of the function to be extracted
:$created 20060101 :$changed 20080219
:$source https://www.dostips.com
SETLOCAL ENABLEDELAYEDEXPANSION
set func=%~f0
set /a b=2000000000
set /a e=2000000000
for /f "tokens=1,* delims=:" %%a in ('"findstr /n /b /c:"%~1 " "%func%""') do set /a b=%%a
for /f "tokens=1,* delims=:" %%a in ('"findstr /n /b /c:"EXIT /b" "%func%""') do (
if /i %b% LSS %%a if /i %%a LSS !e! set /a e=%%a
)
SETLOCAL DISABLEDELAYEDEXPANSION& rem --disabling preserves excamation marks in %%b
for /f "tokens=1,* delims=[]" %%a in ('"find /n /v "" "%func%""') do (
if /i %b% LEQ %%a if /i %%a LEQ %e% echo.%%b
)
EXIT /b
|
|