Advertisement
IcarusLives

New %plot% function

Jun 7th, 2017
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.19 KB | None | 0 0
  1. set ^"LF=^
  2.  
  3. ^" Above empty line is required - do not remove
  4. set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"
  5.  
  6.  
  7. REM Old method
  8. REM usage: call :plot x y @
  9. REM ------------------------------------------------------------------------------------------------------------------------------
  10. :plot x y
  11.     setlocal
  12.         set "c=%~3"
  13.         set /a "_y=%~2", "_x=%~1", "_x2=%~1 + 1"
  14.         (endlocal
  15.             set "_[%_y%]=!_[%_y%]:~0,%_x%!%c:~0,1%!_[%_y%]:~%_x2%!"
  16.         )
  17. goto :eof
  18. REM ------------------------------------------------------------------------------------------------------------------------------
  19.  
  20. REM New method approx. 60% faster
  21. REM usage: %plot% x y @
  22. REM ------------------------------------------------------------------------------------------------------------------------------
  23. set plot=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-3" %%1 in ("^!args^!") do (%\n%
  24.     set /a "_y=%%2", "_x=%%1", "_x2=%%1 + 1"%\n%
  25.     for /f "tokens=1-4" %%a in ("_y ^!_y^! ^!_x^! ^!_x2^!") do set "_[^!%%a^!]=^!_[%%b]:~0,%%c^!%%3^!_[%%b]:~%%d^!"%\n%
  26. )) else set args=
  27. REM ------------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement