Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Echo Off
- setlocal DisableDelayedExpansion
- (set LF=^
- %= Newline =%)
- Set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"
- (Set "Operate=Endlocal ^& Set /A ""%%G%%H=%%I"""
- %= 'Tunnels' variable value, Allows Definition of Arithmetic within Macro =%)
- Set @M=for /L %%n in (1 1 2) do if %%n==2 (%\n%
- for /F "tokens=1,2,3 delims=, " %%G in ("!argv!") do (%\n%
- %Operate%%\n%
- %= Display value of variable. Effective when Macro is accessed from code blocks =%
- Call Echo(%%G: %%%%G%%%\n%
- ) %\n%
- ) ELSE setlocal enableDelayedExpansion ^& set argv=,
- REM macro can be used to define as well as modify variables
- REM output of macro can be redirected to nul (hidden) like so:
- REM (%@M% hp + 50)>nul
- Setlocal EnableDelayedExpansion
- %@M% hp + 50
- (%@M% heal + 30)>nul
- %@M% hp - 30
- %= Multiple values / operations can be combined. Spaces Not Permitted =%
- %@M% hp + 2*heal
- %@M% hp * 2
- %@M% hp / 3
- %@M% hp + heal
- %@M% heal - 10
- %@M% hp + heal
- For /L %%A in (1,1,300) do (%@M% hp + 1)>nul
- Echo(hp: %hp%
- %= demonstrates variable is updated during code block operation =%
- For /L %%A in (2,2,40) do (If not !hp! LSS 100 (%@M% hp - %%A))
- pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement