SWAG98

create_array function

Mar 7th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.74 KB | None | 0 0
  1. ::prerequirement: create_string function
  2. @echo off
  3. goto :main
  4.  
  5. :set_index
  6.  
  7.     call create_string %~1[%~2] "!%~3!"
  8.  
  9. goto :eof
  10.  
  11. :main
  12.  
  13.     call create_string delimiter %2
  14.     call create_string content %3
  15.    
  16.     set /a offset=0
  17.     set /a index=0
  18.    
  19.     for /l %%g in ( 0, 1, %content_lenght% ) do (
  20.         set character=!content:~%%g,1!
  21.        
  22.         if "!character!" equ "!delimiter!" (
  23.             set /a lenght=%%g-!offset!
  24.             call :set_index %1 !index! "content:~!offset!,!lenght!"
  25.            
  26.             set /a offset=%%g + 1
  27.             set /a index=!index! + 1
  28.         )
  29.     )
  30.     call :set_index %1 !index! content:~%offset%,%content_lenght%
  31.     set /a %1_lenght=%index% + 1
  32.     set %1=%content%
  33.    
  34.     set content=
  35.     set lenght=
  36.     set offset=
  37.     set character=
  38.     set delimiter=
  39.     set index=
  40.    
  41. goto :eof
Advertisement
Add Comment
Please, Sign In to add comment