Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch Programs Thread.  (Read 659813 times)

0 Members and 1 Guest are viewing this topic.

Lemonilla



    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: Batch Programs Thread.
« Reply #570 on: June 05, 2013, 08:56:00 PM »
Finds the number of arguments
Code: [Select]
@echo off
setlocal EnableDelayedExpansion
set num_args=0
:loop
set findArg_value=%1
set f |find "findArg_value" 1>nul 2>&1
if "%errorlevel%"=="0" (
set /a num_args+=1
shift
goto loop
)
set findArg_value=
echo %num_args%
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: Batch Programs Thread.
« Reply #571 on: June 06, 2013, 07:27:48 AM »
You don't need to use delayed expansion as it's not being used in your script.  That would allow it to use ! as a parameter.

Lemonilla



    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: Batch Programs Thread.
« Reply #572 on: June 06, 2013, 04:56:24 PM »
Oops, forgot to remove it. That was the 5th attempt, the others used for /l loops (until I remembered about 'shift').
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

crisis13



    Newbie

    • Experience: Familiar
    • OS: Windows XP
    Re: Batch Programs Thread.
    « Reply #573 on: September 05, 2013, 10:13:33 AM »
    I made this Batchfile to compress a (small) file in severall ways and then delete  the results EXEPT the smallest solution.
    I hope it is usefull and i am sure it can be done (much) better, so if you like to comment please , do so !!
    its just a 'dirty concept' but it works (for me)

    you will need:
    exomizer :
    http://hem.bredband.net/magli143/exo/
    hem.bredband.net/magli143/exo/exomizer207.zip

    zx7  : http://www.worldofspectrum.org/infoseekid.cgi?id=0027996
    ftp://ftp.worldofspectrum.org/pub/sinclair/games-extras/ZX7_(WindowsExecutable).zip

    rcs : http://www.worldofspectrum.org/infoseek.cgi?regexp=^Reverse+Computer+Screen$
    ftp://ftp.worldofspectrum.org/pub/sinclair/games-extras/RCS_(WindowsExecutable).zip


    Code: [Select]
    @echo %%A
    echo off
    echo.
    echo This file is :
    echo %~dpnx0
    echo.
    echo This file compresses all BIN found if less then 13825 bytes
    echo via RCS with Exomizer and ZX7 for Z80 use
    echo the final result is stored in the map SMALL
    echo.
    if not exist zx7.exe (
     echo you need to install zx7
     echo http://www.worldofspectrum.org/infoseekid.cgi?id=0027996
     pause 1
     goto :eof
    )
    if not exist exomizer.exe (
     echo you need to install Exomizer
     echo http://hem.bredband.net/magli143/exo/
     pause 1
     goto :eof
    )
    if not exist rcs.exe (
     echo you need to install RCS
     echo http://www.worldofspectrum.org/infoseek.cgi?regexp=^Reverse+Computer+Screen$
     pause 1
     goto :eof
    )

    if exist sleep.exe do sleep 60

    set Q=%%A
    set X=.rcs
    set Y=.zx7
    set Z=.exo
    set R=%Q%%X%
    set S=%Q%%Y%
    set T=%Q%%Z%

    mkdir small

    FOR %Q% IN (*.bin) DO (
    set Q=%%A
    set X=.rcs
    set Y=.zx7
    set Z=.exo
    set R=%Q%%X%
    set S=%Q%%Y%
    set T=%Q%%Z%

    VERIFY OTHER 2>nul REM create an error
    setlocal enableextentions
    IF ERRORLEVEL 1 echo Unable to enable extensions
    VERIFY OTHER 2>nul REM create an error
    setlocal enabledelayedexpansion
    IF ERRORLEVEL 1 echo Unable to enable delayed expansion

    set Q=%%A
    set X=.rcs
    set Y=.zx7
    set Z=.exo
    set R=%Q%%X%
    set S=%Q%%Y%
    set T=%Q%%Z%

    cls
    echo file: %Q% startlength: %%~zA
    rcs.exe %Q%
    zx7.exe %Q%
    exomizer raw -q %Q% -o %T%
    zx7.exe %R%
    exomizer raw -q %R% -o %R%%Z%

    move %R% small/%R%
    move %S% small/%S%
    move %T% small/%T%
    move %R%%Y% small/%R%%Y%
    move %R%%Z% small/%R%%Z%

    cd small
    echo.
    set I=0
    for /f "delims=" %%O in ('dir /Os /b %Q%.*') do (
    echo File %%O %%~zO bytes
    call :recurse
    echo.
    )
    rem move *.* ..
    cd ..
    rem echo remove map
    rem RD small
    endlocal
    )
    goto :eof

    :recurse
    set I=0
    cd
    REM view all files, EXCEPT directories.
    FOR /f "tokens=*" %%P IN ('dir /Os /A-d /b %Q%.*') do (call :showfiles "%%P")
    set count=%I%
    echo Filecount: %count%
    REM echo recurse I %I% C %count% %Q%

    goto :eof

    :showfiles
    set /a I+=1
    if "%I%" GTR "1" (
     del %1
     echo %1 deleted
     ) ELSE (
     echo SMALLEST FOUND = %1
    )
    goto :eof


    its all related to:
    reversed computer screen
     http://www.worldofspectrum.org/forums/showthread.php?t=42176
    zx7
     http://www.worldofspectrum.org/forums/showthread.php?t=42037&highlight=zx7
    exomizer
     http://www.worldofspectrum.org/forums/showthread.php?t=41523&highlight=exomizer


    « Last Edit: September 05, 2013, 10:50:40 AM by crisis13 »

    Lemonilla



      Apprentice

    • "Too sweet"
    • Thanked: 70
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: Batch Programs Thread.
    « Reply #574 on: September 06, 2013, 06:04:58 PM »
    Searches every file on drive for a binary copy of the input file.

    Code: [Select]
    @echo off
    if "%1"=="-debug" (
    shift
    echo on
    )
    setlocal EnableDelayedExpansion

    set "output= "
    set "drv=%cd:~0,1%:"
    set counter=0

    ::ADD MODIFYERS AND HELP MENU LATER
    :mod
    if "%1"=="/f" (
    set "p=%~pdnx2"
    shift
    shift
    goto :mod
    )
    if "%1"=="/l" (
    set "output=%2> echo %%1"
    shift
    shift
    goto :mod
    )
    if "%1"=="/d" (
    set "drv=%2"
    shift
    shift
    goto :mod
    )
    if "%1"=="/F" (
    set "p=%~pdnx2"
    shift
    shift
    goto :mod
    )
    if "%1"=="/L" (
    set "output=%2> echo %%1"
    shift
    shift
    goto :mod
    )
    if "%1"=="/D" (
    set "drv=%2"
    shift
    shift
    goto :mod
    )
    if "%1"=="/?" goto :help



    set "p=%~pdnx1"

    ::Find Matches
    echo.
    for /r %drv%\ %%A in (*.*) do (
    fc /b /LB0 "%p%" "%%A" >nul 2>&1
    if !errorlevel! EQU 0 call :match %%A
    )
    echo.
    echo Done, %counter% matches were found.
    exit /b

    :match
    if "%~pdnx1"=="%p%" goto :eof
    %output%
    echo %1
    set /a counter+=1
    goto :eof

    :help
    echo Searches drive for any copies of the input file.
    echo.
    echo FINDMATCH ^[^/d drive:^] ^[^/l filename1^] ^[^/f filename2^]
    echo.
    echo.  /F         Specifies the file.
    echo.  /L         Logs the output in a file.
    echo.  /D         Specifies the drive to search.
    echo.
    exit /b
    Quote from: patio
    God Bless the DOS Helpers...
    Quote
    If it compiles, send the files.

    Lemonilla



      Apprentice

    • "Too sweet"
    • Thanked: 70
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: Batch Programs Thread.
    « Reply #575 on: September 16, 2013, 05:33:02 PM »
    Calendar

    WINDOWS 7 ONLY.



    cal.bat
    Code: [Select]
    :: Verison 1.5
    :: Windows 7 program, use under any other OS at your own risk.

    @echo off
    if "%1"=="-debug" (
    shift
    echo on
    )
    timeout /t 0 >nul || goto :error.2
    set "root=%~pd0"
    SETLOCAL EnableDelayedExpansion
    for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
      set "DEL=%%a"
    )
    for /f "tokens=1,2 delims==" %%A in ('wmic path win32_localtime get day^,dayofweek^,weekinmonth^,month^,year /value') do (
    if not "%%A"=="" if not "%%B"=="" set %%A=%%B
    )

    ::Constants
    set TodaysColor=0f

    set a=0
    set b=0
    set dow=%DayOfWeek%
    set wim=%WeekInMonth%
    set m=%month%
    set /a m1=%m%-1
    set today=%day%
    set mod=%~1

    if not "%mod%"=="" goto :modifyers
    call :make.cal
    goto :end



    :make.Cal
    if "%m%"=="1" set end=31
    if "%m%"=="2" set end=28
    if "%m%"=="3" set end=31
    if "%m%"=="4" set end=30
    if "%m%"=="5" set end=31
    if "%m%"=="6" set end=30
    if "%m%"=="7" set end=31
    if "%m%"=="8" set end=31
    if "%m%"=="9" set end=30
    if "%m%"=="10" set end=31
    if "%m%"=="11" set end=30
    if "%m%"=="12" set end=31

    if "%m%"=="1"  set "m.name=          January (1)"
    if "%m%"=="2"  set "m.name=         February (2)"
    if "%m%"=="3"  set "m.name=           March (3)"
    if "%m%"=="4"  set "m.name=           April (4)"
    if "%m%"=="5"  set "m.name=            May (5)"
    if "%m%"=="6"  set "m.name=           June (6)"
    if "%m%"=="7"  set "m.name=           July (7)"
    if "%m%"=="8"  set "m.name=          August (8)"
    if "%m%"=="9"  set "m.name=         September (9)"
    if "%m%"=="10" set "m.name=         October (10)"
    if "%m%"=="11" set "m.name=        November (11)"
    if "%m%"=="12" set "m.name=        December (12)"

    if "%m1%"=="1" set past=31
    if "%m1%"=="2" set past=28
    if "%m1%"=="3" set past=31
    if "%m1%"=="4" set past=30
    if "%m1%"=="5" set past=31
    if "%m1%"=="6" set past=30
    if "%m1%"=="7" set past=31
    if "%m1%"=="8" set past=31
    if "%m1%"=="9" set past=30
    if "%m1%"=="10" set past=31
    if "%m1%"=="11" set past=30
    if "%m1%"=="12" set past=31


    :loop.diw
    if %dow% EQU 1 goto :loop.wim
    set /a dow-=1
    set /a day-=1
    goto :loop.diw


    :loop.wim
    set /a wim-=1
    set /a day-=7
    if %day% LSS 0 (
    set /a day=%past%%day%
    set b=1
    goto :loop.end
    )
    goto :loop.wim
    :loop.end

    echo.
    echo.%m.name%
    echo Mon  Tue  Wed  Thu  Fri  Sat  Sun
    echo ---  ---  ---  ---  ---  ---  ---
    echo.

    :loop.week
    set input=0
    if "%day:~1,1%"=="" set day=0%day%

    if not %input% EQU 1 for /f "tokens=1,2,3 delims=:" %%A in (h.txt) do if %year% EQU %%A if %m% EQU %%B if %day% EQU %%C call :ColorText 0c "%day%" && set input=1 && 0>nul set /p"=.  "

    if not %input% EQU 1 if %day%==%today% call :ColorText %todaysColor% "%day%" && set input=1 && 0>nul set /p"=.  "

    if not %input% EQU 1 if exist %~pd0\d.txt for /f "tokens=1,2 delims=:" %%A in (d.txt) do if %m% EQU %%A if %day% EQU %%B call :ColorText 05 "%day%" && set input=1 && 0>nul set /p"=.  "

    if not %input% EQU 1 if not %day%==%today% 0>nul set /p"=%day%.  "

    if "%day:~0,1%"=="0" set day=%day:~1,1%
    set /a day+=1
    set /a dow+=1

    if %dow% GTR 7 (
    set dow=1
    set /a wim+=1
    echo.
    if %a%==1 if %b%==0 goto :loop.end
    )
    if %b%==0 if %day% GTR %end% (
    set day=1
    set /a m+=1
    set a=1
    )
    if %b%==1 if %day% GTR %past% (
    set day=1
    set b=0
    )
    goto :loop.week
    :loop.end
    echo.
    goto :eof


    :ColorText
    <nul set /p ".=%DEL%" > "%~2"
    findstr /v /a:%1 /R "^$" "%~2" nul
    del "%~2" > nul 2>&1
    goto :eof


    :modifyers
    set output=0


    if "%mod:~0,3%"=="/a:" (
    call :make.cal

    for /f "tokens=1-3 delims=:" %%A in ("!mod:~3!") do (
    set b_=%%B
    if "!b_:~1,1!"=="" set b_=0!b_!
    echo %%A:!b_!:%%C >>%root%\d.txt && echo Date Added.
    )
    goto :end
    )



    if "%mod:~0,3%"=="/r:" if exist %root%\d.txt (
    call :make.cal

    for /f "tokens=1,2 delims=:" %%A in ("!mod:~3!") do (
    set b_=%%B
    if "!b_:~1,1!"=="" set b_=0!b_!
    for /f "tokens=1,2,3 delims=:" %%U in ('type "%root%\d.txt"') do (
    if not "%%U:%%V"=="%%A:!b_!" echo %%U:%%V:%%W >>"%root%\d2.txt"
    if "%%U:%%V"=="%%A:!b_!" echo Date Removed.
    )
    )
    del /f "%root%d.txt"
    if exist %root%\d2.txt rename "%root%d2.txt" "d.txt"
    goto :end
    ) else (
    call :make.cal

    echo No dates entered.
    goto :end
    )


    if "%mod:~0,3%"=="/d:" if exist %root%\d.txt (
    call :make.cal

    for /f "tokens=1,2 delims=:" %%A in ("%mod:~3%") do (
    set b_=%%B
    if "!b_:~1,1!"=="" set b_=0!b_!
    for /f "tokens=1-3 delims=:" %%G in ('type "%root%\d.txt"') do (
    if "%%G:%%H"=="%%A:!b_!" if not "%%I"=="" (set I=%%I && set I=!I:_= ! && echo !I!) else (echo No Comment)
    )
    for /f "tokens=1-4 delims=:" %%W in ('type "%root%\h.txt"') do (
    if "%%W:%%X:%%Y"=="%year%:%%A:!b_!" if not "%%Z"=="" (set Z=%%Z && set Z=!Z:_= ! && echo !Z!) else (echo No Comment)
    )
    )
    goto :end
    )

    if "%mod%"=="-b" goto :bug

    REM Find Specific Day
    call :make.cal

    if "%mod%"=="/code" (
    set output=1
    SHIFT
    )

    for /f "tokens=1,2 delims=:" %%A in ("%mod:~1%") do (
    set dayToFind=%%A
    set WeekToFind=%%B
    )

    if "%dayToFind%"=="Su" ( set dayToFind_=7 && set daytofind+=Sunday) else (
    if "%dayToFind%"=="Mo" ( set dayToFind_=1 && set daytofind+=Monday) else (
    if "%dayToFind%"=="Tu" ( set dayToFind_=2 && set daytofind+=Tuesday) else (
    if "%dayToFind%"=="We" ( set dayToFind_=3 && set daytofind+=Wednesday) else (
    if "%dayToFind%"=="Th" ( set dayToFind_=4 && set daytofind+=Thursday) else (
    if "%dayToFind%"=="Fr" ( set dayToFind_=5 && set daytofind+=Friday) else (
    if "%dayToFind%"=="Sa" ( set dayToFind_=6 && set daytofind+=Saturday) else (
    goto :error
    )))))))

    :loop.dow2
    if %dow% LSS %dayToFind_% (
    set /a dow+=1
    set /a day+=1
    )
    if %dow% GTR %dayToFind_% (
    set /a dow-=1
    set /a day-=1
    )
    if not %dow% EQU %daytofind_% goto :loop.dow2

    :loop.wim2
    if %wim% LSS %WeekToFind% (
    set /a wim+=1
    set /a day+=7
    )
    if %wim% GTR %WeekToFind% (
    set /a wim-=1
    set /a day-=7
    )
    if %wim% GTR 8 goto :error
    if %wim% LSS 0 goto :error
    if not %wim% EQU %weekToFind% goto :loop.wim2

    if %output%==0 (
    if %weekToFind% == 1 echo The first %dayToFind+% occures on the %day%.
    if %weekToFind% == 2 echo The second %dayToFind+% occures on the %day%.
    if %weekToFind% == 3 echo The third %dayToFind+% occures on the %day%.
    if %weekToFind% == 4 echo The forth %dayToFind+% occures on the %day%.
    if %weekToFind% == 5 echo The fifth %dayToFind+% occures on the %day%.
    if %weekToFind% == 6 echo The sixth %dayToFind+% occures on the %day%.
    ) else (
    echo %day%
    )
    goto :end

    :Bug
    echo Known bugs:
    echo.  1. /a does not support spaces or quotation marks.
    echo.  2. /day does not work if the first instance of the given day appears
    echo.      on a week with the previous mounths, It gives the next instance instead.
    echo.
    goto :end

    :error
    echo Produces a calendar or date of a specific day.
    echo.
    echo cal [{/code} /Day:#] [/a:m:n:Note] [/r:m:n]
    echo.
    echo.   /Day:#      Finds the date for the specified day. Day is the first two
    echo.                letters of the day you wish to locate.
    echo.                # corresponds to the week of the month.
    echo.   /code       Reformats the output to a more code friendly format.
    echo.                /code must come before /Day:#.
    echo.   /a:m:n:Note Creates a date that will appear on the calendar. m is the
    echo.                month, n is the day. Note is optional and will act as a
    echo.                reminder if you forget what happens on the date.
    echo.                Replace all instances of ^<space^> with underscore ^"_^".
    echo.   /r:m:n      Removes an existing date from the calendar. m is the month
    echo.                and n is the day.
    echo.   /d:m:n      Displays the comment corresponding with the date. m is the month
    echo.                and n is the day.
    echo.   -b          Displays Known errors.
    echo.
    echo cal color codes certain dates. The colors and their meanings are below.
    echo.
    call :colortext %todayscolor% "   Today"
    echo.
    call :colortext 0c "   National Holiday"
    echo.
    call :colortext 02 "   Daylight Savings Time"
    echo.
    call :colortext 05 "   Saved Date"
    echo.
    echo.
    echo Examples:
    echo.   cal
    echo.   cal /Su:2
    echo.   cal /code /Th:1
    echo.   cal /a:9:03:Birthday
    echo.   cal /r:9:3
    echo.   cal /d:9:03
    :error.2
    echo.
    echo.(cal is a Windows 7 program and is not backwards compatible.)
    echo.
    :end

    with Helper file "h.txt" (This example holds US holidays for 2013 and 2014, you can replace them with your native country's holidays by following the same format.)

    Syntax:
    Year:Month:Day:Discription
    or
    ::::COMMENT
    Code: [Select]
    ::::US Holidays
    ::::As shown on opm.gov

    ::::2013
    2013:1:01:New_Years_Day
    2013:1:21:Birthday_of_Dr_King_Jr
    2013:2:18:Washingtons_Birthday
    2013:5:27:Memorial_Day
    2013:7:04:Independence_Day
    2013:9:02:Labor_Day
    2013:10:14:Columbus_Day
    2013:11:03:Veterans_Day
    2013:11:28:Thanksgiving_Day
    2013:12:25:Christmas_Day


    ::::2014
    2014:1:01:New_Years_Day
    2014:1:20:Birthday_of_Dr_King_Jr
    2014:2:17:Washingtons_Birthday
    2014:5:26:Memorial_Day
    2014:7:04:Independence_Day
    2014:9:01:Labor_Day
    2014:10:13:Columbus_Day
    2014:11:11:Veterans_Day
    2014:11:27:Thanksgiving_Day
    2014:12:25:Christmas_Day




    Example output:

    T:\cal>cal /d:9:02

             September (9)
    Mon  Tue  Wed  Thu  Fri  Sat  Sun
    ---  ---  ---  ---  ---  ---  ---

    26.  27.  28.  29.  30.  31.  01.
    02.  03.  04.  05.  06.  07.  08.
    09.  10.  11.  12.  13.  14.  15.
    16.  17.  18.  19.  20.  21.  22.
    23.  24.  25.  26.  27.  28.  29.
    30.  01.  02.  03.  04.  05.  06.

    Labor Day
    Quote from: patio
    God Bless the DOS Helpers...
    Quote
    If it compiles, send the files.

    spivee



      Rookie

    • illo gaude
    • Thanked: 5
    • Experience: Familiar
    • OS: Windows 7
    Re: Batch Programs Thread.
    « Reply #576 on: September 29, 2013, 10:34:39 AM »
    Yay, I was hoping for this thread to exist.
    I'm working on an engine for text based adventures, called the dream engine,
    I'm pretty proud of it,

    Code: [Select]
    @echo off

    rem for /f "delims==" %%f in ('set') do (
    rem set %%f=
    rem )

    call language.bat

    title The Dream Engine
    echo What file do you want to use?
    set /p name=^
    >

    set interpret.type[nul]=0

    for /f "tokens=1* delims=." %%f in ("%name%") do (set test=%%g)
    if "%test%"=="" (if not exist "%name%" (set name=%name%.txt))
    set purpose=root
    set layer=0
    for /f "tokens=* usebackq delims=~" %%f in ("%name%") do (call :readline .%%f)
    set indent=0
    call :readline.lowerindent

    title The %place%.
    echo You are in a %place%.

    :Inputloop
    set input=
    set /p input=^
    >
    if "%input%"=="" goto :inputloop
    call :interpret %input%
    goto :Inputloop

    :debug
    set debug
    set interpret
    set console
    set hook
    set type
    set object
    set event
    goto :eof

    :look
    set look.counter=
    set look.seen=
    call :look.loop
    goto :eof

    :look.loop
    set /a look.counter=look.counter+1
    set list=
    call :set id=%%object[%look.counter%]%%
    call :set name=%%console.type[%id%]%%
    call :set location=%%object.location[%look.counter%]%%
    if "%name%"=="" (if "%look.test%"=="%objectcounter%" (goto :eof) else (goto :look.loop) )
    rem set perspective[%look.seen%]=%look.counter%
    rem set /a look.seen=look.seen+1
    call :set mprop=%%type[%id%].properties%%
    set prop=0
    call :look.adj.loop
    echo There is a %list%%name% %location%.
    set look.test=%look.counter%
    goto :look.loop

    :look.adj.loop
    if "%prop%"=="%mprop%" (goto :eof)
    set /a prop=prop+1
    call :set adj=%%object[%look.counter%].property[%prop%]%%
    call :set adj=%%console.type[%id%].property[%prop%].adjective[%adj%]%%
    if not "%adj%"=="" (set list=%list%%adj% )
    goto :look.adj.loop

    :hook.handle
    for /f "tokens=1,2,3" %%f in ("%*") do (
    set verb=%%f
    set direct=%%g
    set indirect=%%h
    )
    call :set directis=%%object[%direct%]%%
    if "%indirect%"=="" (
    set punc=.
    set indirectis=
    ) else (
    set punc=.
    call :set indirectis=%%object[%indirect%]%%
    )
    call :set event=%%hook.action[%verb%].using[%directis%%punc%%indirectis%]%%
    call :event %event% %hook.controlgroup% %direct% %indirect%
    goto :eof



    :event
    for /f "tokens=1,2,3,4" %%a in ("%*") do (
    set $id=%%a
    set $part[0]=%%b
    set $part[1]=%%c
    set $part[2]=%%d
    )
    call :set $sb=%%object[%$part[0]%]%%
    call :set $ob=%%object[%$part[1]%]%%
    call :set $in=%%object[%$part[2]%]%%
    call :set $sb=%%console.type[%$sb%]%%
    call :set $ob=%%console.type[%$ob%]%%
    call :set $in=%%console.type[%$in%]%%
    call :set $script=%%event[%$id%]%%
    set $task=action
    :event.scriptloop
    set $char=%$script:~0,1%
    set $script=%$script:~1%
    call :event.script.track[%$task%]
    if not "%$script%"=="" goto :event.scriptloop
    goto :eof

    :event.script.track[action]
    if "%$char%"=="?" (set $task=getterm
    set $purpose=lhs)
    if "%$char%"=="!" (set $task=getterm
    set $purpose=dataleft)
    if "%$char%"=="~" (set $task=number
    set $purpose=delete)
    if "%$char%"==":" (set $task=number
    set $purpose=speak)
    if "%$char%"=="{" (
    if "%$purpose%"=="testelse" (set /a $nest=$nest+1
    call :set $layer[%%$nest%%]=else)
    if "%$purpose%"=="skipelse" (set $task=skipbrace
    set $brace=1
    set $purpose=else)
    )
    set $num=
    if "%$char%"=="}" (call :event.script.track[action].handlenest)
    goto :eof

    :event.script.track[action].handlenest
    call :set $layer=%%$layer[%$nest%]%%
    if "%$layer%"=="if" (set $purpose=skipelse) else (set $purpose=)
    goto :eof

    :event.script.track[getterm]
    if "%$char%"=="@" (set $task=partnum)
    if "%$char%"=="#" (if not "%$purpose%"=="dataleft" (
    set $task=number))
    goto :eof

    :event.script.track[partnum]
    if "%$char%"=="." (set $task=field
    call :set $rid=%%$part[%$part%]%%
    set $part=
    goto :eof
    )
    set $part=%$part%%$char%
    goto :eof

    :event.script.track[field]
    if "%$char%"=="$" (set $task=getslotid
    set $dtype=property
    goto :eof)
    if "%$char%"=="!" (set $task=getslotid
    set $dtype=state
    goto :eof)
    if "%$char%"=="#" (set $task=getslotid
    set $dtype=value
    goto :eof)
    if "%$char%"=="@" (set $task=closeterm.id
    goto :eof)
    if "%$char%"=="." (set $hold=%$rid%
    call :set $rid=%%object[%$rid%].pointer[%$point%]%%
    set $pslot=%$point%
    set $point=
    goto :eof
    )
    set $point=%$point%%$char%
    goto :eof

    :event.script.track[getslotid]
    if "%$purpose%"=="lhs" (
    if "%$char%"=="=" (goto :event.script.track[closeterm])
    if "%$char%"=="~" (goto :event.script.track[closeterm])
    )
    if "%$purpose%"=="rhs" (if "%$char%"=="{" (goto :event.script.track[closeterm]))
    if "%$purpose%"=="dataright" (if "%$char%"==";" (goto :event.script.track[closeterm]))
    if "%$purpose%"=="dataleft" (
    if "%$char%"=="=" (goto :event.script.track[close[dataleft]])
    if "%$char%"=="+" (goto :event.script.track[close[dataleft]])
    if "%$char%"=="-" (goto :event.script.track[close[dataleft]])
    )
    set $slotid=%$slotid%%$char%
    goto :eof

    :event.script.track[number]
    if "%$purpose%"=="lhs" (
    if "%$char%"=="=" (goto :event.script.track[closeterm])
    if "%$char%"=="~" (goto :event.script.track[closeterm])
    )
    if "%$purpose%"=="rhs" (if "%$char%"=="{" (goto :event.script.track[close[rhs]]))
    if "%$purpose%"=="speak" (if "%$char%"==";" (goto :event.script.track[close[speak]]))
    if "%$purpose%"=="delete" (if "%$char%"==";" (goto :event.script.track[close[delete]]))
    if "%$purpose%"=="dataright" (if "%$char%"==";" (goto :event.script.track[close[dataright]]))
    set $num=%$num%%$char%
    goto :eof

    :event.script.track[closeterm]
    call :set $num=%%object[%$rid%].%dtype%[%$slotid%]%%
    if not "%$purpose%"=="dataleft%" (set $slotid=)
    if "%$num%"=="" set $num=0
    goto :event.script.track[close[%$purpose%]]

    :event.script.track[closeterm.id]
    set $num=%$rid%
    if "%$purpose%"=="dataleft" (set $slotid=@)
    goto :event.script.track[close[%$purpose%]]

    :event.script.track[close[lhs]]
    if "%$char%"=="=" (set $lhs.if=true) else (set $lhs.if=false)
    set $lhs=%$num%
    set $num=
    set $purpose=rhs
    set $task=getterm
    goto :eof

    :event.script.track[close[rhs]]
    if "%$num%"=="%$lhs%" (set $num=true) else (set $num=false)
    if "%$num%"=="%$lhs.if%" (set /a $nest=$nest+1
    set $task=action
    call :set $layer[%%$nest%%]=if) else (
    set $task=skipbrace
    set $brace=1
    set $purpose=if)
    goto :eof

    :event.script.track[skipbrace]
    if "%$char%"=="{" (set /a $brace=$brace+1)
    if "%$char%"=="}" (set /a $brace=$brace-1)
    if "%$brace%"=="0" (set $task=action
    if "%$purpose%"=="if" (set $purpose=testelse) else (set $purpose=))
    goto :eof

    :event.script.track[close[dataleft]]
    if "%$slotid%"=="@" (set $target.slot=%$pslot%
    set $target.id=%$hold%
    set $dtype=pointer
    ) else (
    set $target.id=%$rid%
    set $target.slot=%$slotid%
    )
    call :set $num=%%object[%$target.id%].%$dtype%[%$slotid%]%%
    if "%$char%"=="="(set /a $base=) else (
    if "%$char%"=="+"(set /a $base=$num) else (
    if "%$char%"=="-"(set /a $base=$num*-1)))
    set $num=
    set $slotid=
    set $purpose=dataright
    set $task=getterm
    goto :eof

    :event.script.track[close[dataright]]
    set /a object[%$target.id%].%dtype%[%$target.slot%]=$base+$num
    set $num=
    set $part=
    set $slotid=
    set $task=action
    set $purpose=
    goto :eof

    :event.script.track[close[speak]]
    call :set $output=%%event[%$id%].output[%$num%]%%
    call :set $output=%%$output:$ob=%$ob%%%
    call :set $output=%%$output:$sb=%$sb%%%
    if not "%$in%"=="" (call :set $output=%%$output:$in=%$in%%%)
    echo %$output%
    set $task=action
    set $purpose=
    set $num=
    goto :eof

    :event.script.track[close[delete]]
    call :set $num=%%$part[%$num%]%%
    call :destroy %$num%
    set $task=action
    set $purpose=
    set $num=
    goto :eof

    :destroy
    for /f "tokens=1 delims==" %%f in ('set object[%*]') do (
    set %%f=)
    goto :eof

    :interpret
    set $string=%*
    call :token 1 $verb=%$string%
    call :set $command=%%interpret.hook.command[%$verb%]%%
    if "%$command%"=="1" (goto :look)
    if "%$command%"=="2" (goto :debug)
    call :set $verb=%%interpret.hook.action[%$verb%]%%
    set $parse=2
    call :interpret.getobject
    if "%$error%"=="1" (echo There doesn't seem to be any of those
    goto :eof)
    if "%$error%"=="2" (echo There is more than one of those
    goto :eof)
    set $direct=%$return%

    call :token %$parse% $trans=%$string%
    if "%$trans%"=="" (set $indirect=
    call :hook.handle %$verb% %$direct%
    goto :eof)
    call :set $trans=%%interpret.lang.transterm[%$trans%]%%
    set /a $parse=$parse+1
    call :interpret.getobject
    if "%$error%"=="1" (echo There doesn't seem to be any of those
    goto :eof)
    if "%$error%"=="2" (echo There is more than one of those
    goto :eof)
    set $indirect=%$return%
    call :hook.handle %$verb% %$direct% %$indirect%
    goto :eof

    :interpret.getobject
    set $error=0
    set $isexp=true
    call :token %$parse% $choicetype=%$string%
    call :set $choicetype=%%interpret.lang.choicetype[%$choicetype%]%%
    if "%$choicetype%"=="" (set $choicetype=1) else (set /a $parse=$parse+1)
    set $transcheck=%$parse%
    call :interpret.getobject.transloop
    set /a $transcheck=$transcheck-1
    call :token %$transcheck% $noun=%$string%
    call :set $type=%%interpret.type[%$noun%]%%
    if "%$transcheck%"=="%$parse%" (set $isexp=) else (call :interpret.getobject.adjloop)
    set /a $parse=$parse+1
    set $success=0
    for /f "tokens=1* delims==" %%f in ('set object[') do (
    for /f "tokens=2,3 delims=[]" %%h in ("%%f") do (set $test=%%h
    set $junk=%%i)
    set $testtype=%%g
    call :interpret.getobject.compare)
    if "%$success%"=="0" (set $error=1
    goto :eof)
    call :interpret.getobject.type[%$choicetype%]
    for /f "tokens=1 delims==" %%f in ('set $success') do (
    set %%f=
    )
    goto :eof

    :interpret.getobject.type[1]
    if not "%$success%"=="1" (set $error=2
    goto :eof)
    :interpret.getobject.type[2]
    call :set $return=%%$success[1]%%
    goto :eof

    :interpret.getobject.type[3]
    call :random $success=1 %$success%
    call :set $return=%%$success[%$success%]%%
    goto :eof

    :interpret.getobject.compare
    if not "%$junk%"=="" (goto :eof)
    if not "%$testtype%"=="%$type%" goto :eof
    set $failed=0
    if "%$isexp%"=="true" (
     for /f "tokens=1* delims==" %%f in ('set $describe[') do (set $lhs=%%f
     set $rhs=%%g
     call :interpret.getobject.compare.test)
    )
    if "%$failed%"=="0" (set /a $success=$success+1
    call :set $success[%%$success%%]=%$test%)
    goto :eof

    :interpret.getobject.compare.test
    for /f "tokens=2 delims=[]" %%f in ("%$lhs%") do (set $lhs=%%f)
    call :set $lhs=%%object[%$test%].property[%$lhs%]%%
    if not "%$lhs%"=="%$rhs%" set $failed=1
    goto :eof


    :interpret.getobject.adjloop
    if "%$parse%"=="%$transcheck%" goto :eof
    call :token %$parse% $adjective=%$string%
    call :set $property=%%interpret.adjective[%$adjective%].type[%$type%].property%%
    call :set $adjective=%%interpret.adjective[%$adjective%].type[%$type%]%%
    set $describe[%$property%]=%$adjective%
    set /a $parse=$parse+1
    goto :interpret.getobject.adjloop


    :interpret.getobject.transloop
    set /a $transcheck=$transcheck+1
    set $attempt=
    call :token %$transcheck% $attempt=%$string%
    if "%$attempt%"=="" goto :eof
    call :set $attempt=%%interpret.lang.transterm[%$attempt%]%%
    if not "%$attempt%"=="" goto :eof
    goto :interpret.getobject.transloop





    :type.giveproperty
    for /f "tokens=1,2*" %%f in ("%*") do (set $type=%%f
    set $property=%%g
    set $list=%%h
    )
    call :set $type=%%interpret.type[%$type%]%%
    call :set $props=%%type[%$type%].properties%%
    set /a $props=$props+1
    set type[%$type%].properties=%$props%
    set debug.type[%$type%].property[%$property%]=%$props%
    set debug.type[%$type%].property[%$props%].name=%$property%
    set $value=
    :type.giveproperty.adjloop
    for /f "tokens=1* delims=, " %%f in ("%$list%") do (
    set $adj=%%f
    set $list=%%g
    )
    set /a $value=$value+1
    set interpret.adjective[%$adj%].type[%$type%]=%$value%
    set interpret.adjective[%$adj%].type[%$type%].property=%$props%
    set console.type[%$type%].property[%$props%].adjective[%$value%]=%$adj%
    if not "%$list%"=="" goto :type.giveproperty.adjloop
    set type[%$type%].property[%$props%].highest=%$value%
    goto :eof


    :type.givestate
    for /f "tokens=1,2,3,4" %%f in ("%*") do (set $type=%%f
    set $state=%%g
    set $zero=%%h
    set $one=%%i
    )
    call :set $type=%%interpret.type[%$type%]%%
    call :set $states=%%type[%$type%].states%%
    set /a $states=$states+1
    set type[%$type%].states=%$states%
    set debug.type[%$type%].state[%$state%]=%$states%
    set debug.type[%$type%].state[%$states%].name=%$state%

    set interpret.adjective[%$zero%].type[%$type%]=0
    set interpret.adjective[%$zero%].type[%$type%].state=%$states%
    set console.type[%$type%].state[%$states%].adjective[0]=%$zero%
    set interpret.adjective[%$one%].type[%$type%]=1
    set interpret.adjective[%$one%].type[%$type%].state=%$states%
    set console.type[%$type%].state[%$states%].adjective[1]=%$one%

    goto :eof

    :type.givevalue
    for /f "tokens=1,2*" %%f in ("%*") do (set $type=%%f
    set $value=%%g
    )
    call :set $type=%%interpret.type[%$type%]%%
    call :set $values=%%type[%$type%].values%%
    set /a $values=$values+1
    set type[%$type%].values=%$values%
    set debug.type[%$type%].value[%$value%]=%$values%
    set debug.type[%$type%].value[%$values%].name=%$value%
    set $value=
    goto :eof

    :type.givepointer
    for /f "tokens=1,2*" %%f in ("%*") do (set $type=%%f
    set $pointer=%%g
    set $pointtype=%%h
    )
    call :set $type=%%interpret.type[%$type%]%%
    call :set $pointid=%%interpret.type[%$pointtype%]%%
    call :set $points=%%type[%$type%].pointers%%
    set /a $points=$points+1
    set type[%$type%].pointers=%$points%
    set debug.type[%$type%].pointer[%$pointer%]=%$points%
    set debug.type[%$type%].pointer[%$points%].name=%$pointer%
    set type[%$type%].pointer[%$points%]=%$pointid%
    goto :eof

    :type.expand
    set type[%2].super=%1
    call :set type[%1].sub=%%type[%1].sub%%%2;
    set $counter=
    call :set $max=%%type[%1].properties%%
    call :type.expand.property %*
    set type[%2].properties=%$max%

    set $counter=
    call :set $max=%%type[%1].states%%
    call :type.expand.state %*
    set type[%2].states=%$max%

    set $counter=
    call :set $max=%%type[%1].values%%
    call :type.expand.value %*
    set type[%2].values=%$max%

    set $counter=
    call :set $max=%%type[%1].pointers%%
    call :type.expand.pointer %*
    set type[%2].pointers=%$max%

    goto :eof

    :type.expand.property
    if "%$counter%"=="%$max%" goto :eof
    set /a $counter=$counter+1
    set $adjcounter=
    call :set $adjmax=%%type[%1].property[%$counter%].highest%%
    :type.expand.property.value
    set /a $adjcounter=$adjcounter+1
    call :set $term=%%console.type[%1].property[%$counter%].adjective[%$adjcounter%]%%
    set interpret.adjective[%$term%].type[%2]=%$adjcounter%
    set interpret.adjective[%$term%].type[%2].property=%$counter%
    set console.type[%2].property[%$counter%].adjective[%$adjcounter%]=%$term%
    if not "%$adjcounter%"=="%$adjmax%" goto :type.expand.property.value
    set type[%2].property[%$counter%].highest=%$adjmax%
    call :set $debug=%%debug.type[%1].property[%$counter%].name%%
    set debug.type[%2].property[%$debug%]=%$counter%
    set debug.type[%2].property[%$counter%].name=%$debug%
    goto :type.expand.property

    :type.expand.state
    if "%$counter%"=="%$max%" goto :eof
    set /a $counter=$counter+1
    call :set $term=%%console.type[%1].state[%$counter%].adjective[0]%%
    set interpret.adjective[%$term%].type[%2]=0
    set interpret.adjective[%$term%].type[%2].state=%$counter%
    set console.type[%2].state[%$counter%].adjective[0]=%$term%
    call :set $term=%%console.type[%1].state[%$counter%].adjective[1]%%
    set interpret.adjective[%$term%].type[%2]=1
    set interpret.adjective[%$term%].type[%2].state=%$counter%
    set console.type[%2].state[%$counter%].adjective[1]=%$term%
    call :set $debug=%%debug.type[%1].state[%$counter%].name%%
    set debug.type[%2].state[%$debug%]=%$counter%
    set debug.type[%2].state[%$counter%].name=%$debug%
    goto :type.expand.state

    :type.expand.value
    if "%$counter%"=="%$max%" goto :eof
    set /a $counter=$counter+1
    call :set $debug=%%debug.type[%1].value[%$counter%].name%%
    set debug.type[%2].value[%$debug%]=%$counter%
    set debug.type[%2].value[%$counter%].name=%$debug%
    goto :type.expand.value

    :type.expand.pointer
    if "%$counter%"=="%$max%" goto :eof
    set /a $counter=$counter+1
    call :set $debug=%%debug.type[%1].pointer[%$counter%].name%%
    set debug.type[%2].pointer[%$debug%]=%$counter%
    set debug.type[%2].pointer[%$counter%].name=%$debug%
    call :set type[%2].pointer[%$counter%]=%%type[%1].pointer[%$counter%]%%
    goto :type.expand.pointer

    :token
    for /f "tokens=1*" %%f in ("%*") do (
    set token.num=%%f
    set token.remainder=%%g
    )
    for /f "tokens=1* delims==" %%f in ("%token.remainder%") do (
    set token.var=%%f
    set token.remainder=%%g
    )
    for /f "tokens=%token.num%" %%f in ("%token.remainder%") do (set %token.var%=%%f)
    goto :eof

    :random
    for /f "tokens=1* delims==" %%f in ("%*") do (
    set random.var=%%f
    set random.max=%%g
    )
    for /f "tokens=1*" %%f in ("%random.max%") do (
    set random.min=%%f
    set random.max=%%g
    )
    set /a %random.var%=(random.max-random.min+1)*%random%/32768+random.min
    set random.var=
    set random.min=
    set random.max=
    goto :eof

    :set
    set %*
    goto :eof

    :pexit
    if not "%*"=="" (echo %*)
    echo Press any key to exit . . .
    pause>nul
    exit

    rem ### File Reader ###

    :readline
    set steeze=%*
    set steeze=%steeze:~1%
    title %steeze%
    set indent=0
    call :readline.indent
    if %indent% gtr %layer% goto :eof
    if %indent% lss %layer% call :readline.lowerindent
    goto :readline.seek[%purpose%]

    :readline.indent
    set bit=%steeze:~0,1%
    if not "%bit%"==" " goto :eof
    set /a indent=indent+1
    set steeze=%steeze:~1%
    goto :readline.indent

    :readline.lowerindent
    call :set last=%%layer[%layer%]%%
    call :readline.close[%purpose%]
    set /a layer=layer-1
    if %indent% lss %layer% goto :readline.lowerindent
    call :set purpose=%%purpose[%layer%]%%
    goto :eof

    :readline.seek[root]
    for /f "tokens=1*" %%f in ("%steeze%") do (set name=%%f
    set steeze=%%g)
    set purpose[0]=root
    if "%name%"=="type" (goto :readline.open[typedata])
    if "%name%"=="event" (goto :readline.open[eventdata])
    if "%name%"=="reality" (set place=%steeze%
    set purpose=reality
    set purpose[0]=reality
    goto :eof)
    call :pexit How does do %steeze%?

    :readline.open[typedata]
    set /a layer=layer+1
    set layer[%layer%]=%steeze%
    set super=%this%
    set this=%steeze%
    if "%super%"=="" (set super=nul)
    call :set superid=%%interpret.type[%super%]%%
    set /a dream.environment.types=dream.environment.types+1
    set thisid=%dream.environment.types%
    set interpret.type[%this%]=%thisid%
    set console.type[%thisid%]=%this%
    call :type.expand %superid% %thisid%
    set safe=true
    set purpose=typedata
    set purpose[%layer%]=typedata
    goto :eof

    :readline.seek[typedata]
    for /f "tokens=1*" %%f in ("%steeze%") do (set token=%%f
    set steeze=%%g)
    if "%token%"=="property" (call :type.giveproperty %this% %steeze%
    goto :eof)
    if "%token%"=="state" (call :type.givestate %this% %steeze%
    goto :eof)
    if "%token%"=="value" (call :type.givevalue %this% %steeze%
    goto :eof)
    if "%token%"=="pointer" (call :type.givepointer %this% %steeze%
    goto :eof)
    if "%token%"=="type" (goto :readline.open[typedata])
    call :pexit What's a %token%?

    :readline.close[typedata]
    set safe=
    set this=%super%
    set thisid=%superid%
    call :set superid=%%type[%thisid%].super%%
    call :set super=%%console.type[%superid%]%%
    goto :eof

    :readline.open[eventdata]
    for /f "tokens=1,2,3,4" %%a in ("%steeze%") do (
    set name=%%a
    set subject=%%b
    set object=%%c
    set instrument=%%d)
    set layer=1
    set layer[1]=
    set /a dream.environment.events=dream.environment.events+1
    set name[0]=%steeze%
    set this=%steeze%
    set purpose=eventdata
    set purpose[1]=eventdata
    set part[subject]=0
    set part[object]=1
    call :set type[0]=%%interpret.type[%subject%]%%
    call :set type[1]=%%interpret.type[%object%]%%
    set event[%dream.environment.events%].subject=%type[0]%
    set event[%dream.environment.events%].object=%type[1]%
    if not "%instrument%"=="" (
    call :set type[2]=%%interpret.type[%instrument%]%%
    set part[instrument]=2
    set event[%dream.environment.events%].instrument=%type[2]%
    )
    set debug.event[%name%]=%dream.environment.events%
    goto :eof

    :readline.seek[eventdata]
    for /f "tokens=1*" %%f in ("%steeze%") do (set token=%%f
    set steeze=%%g)
    if "%token%"=="if" (goto :readline.event.if)
    if "%token%"=="destroy" (goto :readline.event.destroy)
    rem if "%token%"=="make" (goto :readline.event.make)
    if "%token%"=="print" (goto :readline.event.print)
    if "%token%"=="define" (goto :readline.event.set.basic)
    if "%token%"=="align" (goto :readline.event.set.dynamic)
    if "%token%"=="set" (set op==
    goto :readline.event.set.value)
    if "%token%"=="increase" (set op=+
    goto :readline.event.set.value)
    if "%token%"=="decrease" (set op=-
    goto :readline.event.set.value)
    if "%token%"=="else" (if "%else%"=="true" (
    set code=%code%{
    set /a layer=layer+1
    call :set layer[%%layer%%]=else
    call :set purpose[%%layer%%]=eventdata
    goto :eof
    ))
    call :pexit How does expect %token%?

    :readline.close[eventdata]
    if not "%last%"=="" (
    set code=%code%}
    if "%last%"=="if" (set else=true) else (set else=)
    goto :eof)
    set event[%dream.environment.events%]=%code%
    set code=
    set event.outputcounter=
    goto :eof

    :readline.event.if
    set code=%code%?
    for /f "tokens=1-2,3*" %%a in ("%steeze%") do (
     if "%%b"=="not" (
      set useop=~
      set steeze=%%a %%c
     ) else (
      set useop==
     )
    )
    for /f "tokens=1,2,3*" %%h in ("%steeze%") do (
    set lhs=%%h
    set compareop=%%i
    set rhs=%%j
    set junk=%%k
    )
    set /a layer=layer+1
    set layer[%layer%]=if
    set purpose[%layer%]=eventdata
    if "%compareop%"=="mirrors" goto :readline.event.if.dynamic
    if "%compareop%"=="equals" goto :readline.event.if.direct
    call :readline.event.giveterm %lhs% %rhs%
    if "%compareop%"=="is" (set code=%code%=) else (
      call :pexit Which way is %compareop%?
    )
    call :readline.event.closeterm
    set code=%code%{
    goto :eof

    :readline.event.if.dynamic
    call :readline.event.giveterm %lhs%
    set code=%code%%useop%
    call :readline.event.giveterm %rhs%
    set code=%code%{
    goto :eof

    :readline.event.if.direct
    call :readline.event.giveterm %lhs%
    set code=%code%%useop%#%rhs%{
    goto :eof

    :readline.event.destroy
    set code=%code%~
    for /f "tokens=1,2" %%f in ("%steeze%") do (
     set part=%%f
     set discard=%%g
    )
    if not "%discard%"=="" (
    call :pexit Kill a %part% what?
    )
    if "%part%"=="object" (set code=%code%1) else (
     if "%part%"=="instrument" (set code=%code%2) else (
      call :pexit Which one is the %part%?
     )
    )
    set code=%code%;
    goto :eof



    :readline.event.print
    set /a event.outputcounter=event.outputcounter+1
    set event[%dream.environment.events%].output[%event.outputcounter%]=%steeze%
    set code=%code%:%event.outputcounter%;
    goto :eof

    :readline.event.set.basic
    set code=%code%!
    for /f "tokens=1,2,3*" %%a in ("%steeze%") do (
    set left=%%a
    if "%%b"=="as" (set right=%%c) else (set right=%%b)
    )
    call :readline.event.giveterm %left% %right%
    set code=%code%=
    call :readline.event.closeterm
    set code=%code%;
    goto :eof

    :readline.event.set.dynamic
    set code=%code%!

    for /f "tokens=1,2,3*" %%a in ("%steeze%") do (
    set left=%%a
    if "%%b"=="with" (set right=%%c) else (set right=%%b)
    )
    call :readline.event.giveterm %left%
    set code=%code%=
    call :readline.event.giveterm %right%set code=%code%;
    goto :eof

    :readline.event.set.value
    set code=%code%!
    if "%op%"=="=" (set read=to) else (set read=by)
    for /f "tokens=1,2,3*" %%a in ("%steeze%") do (
    set left=%%a
    if "%%b"=="%read%" (set right=%%c) else (set right=%%b)
    )
    call :readline.event.giveterm %left%
    set code=%code%%op%#%right%
    set code=%code%;
    goto :eof



    :readline.event.giveterm
    for /f "tokens=1* delims=." %%f in ("%1") do (
    set partname=%%f
    set array=%%g
    )
    set code=%code%@
    call :readline.event.givepart %partname%
    call :set cid=%%type[%part%]%%
    call :readline.event.giveterm.pointloop %2
    if "%2"=="" (goto :eof)
    call :set property=%%interpret.adjective[%2].type[%cid%].property%%
    if not "%property%"=="" (set code=%code%.$%property%
    call :set property=%%interpret.adjective[%2].type[%cid%]%%
    goto :eof
    )
    call :set property=%%interpret.adjective[%2].type[%cid%].state%%
    if not "%property%"=="" (set code=%code%.$%property%
    call :set property=%%interpret.adjective[%2].type[%cid%]%%
    goto :eof
    )
    call :pexit What's a %2?


    :readline.event.giveterm.pointloop
    if "%array%"=="" goto :eof
    for /f "tokens=1* delims=." %%f in ("%array%") do (
    set pointname=%%f
    set array=%%g
    )
    if "%array%"=="" if "%1"=="" (goto :readline.event.giveterm.pointloop.test)
    call :set pointid=%%debug.type[%cid%].pointer[%pointname%]%%
    call :set cid=%%type[%cid%].pointer[%pointid%]%%
    set code=%code%.%pointid%
    goto :readline.event.giveterm.pointloop

    :readline.event.giveterm.pointloop.test
    if "%pointname%"=="type" (set value=%cid%
    set code=%code%.*
    )
    call :readline.event.giveterm.pointloop.testvalue $ property
    if not "%value%"=="" goto :eof
    call :readline.event.giveterm.pointloop.testvalue ! state
    if not "%value%"=="" goto :eof
    call :readline.event.giveterm.pointloop.testvalue # value
    if not "%value%"=="" goto :eof
    call :set code=%code%.%%debug.type[%cid%].pointer[%pointname%]%%.@
    goto :eof

    :readline.event.giveterm.pointloop.testvalue
    call :set value=%%debug.type[%cid%].%2[%pointname%]%%
    if "%value%"=="" (goto :eof)
    set code=%code%.%1%value%
    goto :eof


    :readline.event.closeterm
    set code=%code%#%property%
    goto :eof

    :readline.event.givepart
    call :set part=%%part[%*]%%
    if "%part%"=="" (call :pexit Which one is a %*?)
    set code=%code%%part%
    goto :eof

    :readline.seek[reality]
    for /f "tokens=1*" %%f in ("%steeze%") do (set type=%%f
    set debug=%%g
    )
    if "%type%"=="controlhook" (
    call :set hook.controlgroup=%%debug.object[%debug%]%%
    set purpose=hook
    goto :eof)
    call :set id=%%interpret.type[%type%]%%
    if "%id%"=="" (call :pexit what's a %type%?)
    set purpose=defineobject
    set /a dream.environment.objects=dream.environment.objects+1
    set object[%dream.environment.objects%]=%id%
    set debug.object[%debug%]=%dream.environment.objects%
    set /a layer=layer+1
    set purpose[%layer%]=defineobject
    goto :eof

    :readline.close[defineobject]
    goto :eof

    :readline.seek[defineobject]
    for /f "tokens=1*" %%f in ("%steeze%") do (set head=%%f
    set foot=%%g)

    set dtype=value
    call :set slot=%%debug.type[%id%].value[%head%]%%
    set data=%foot%
    if not "%slot%"=="" goto :readline.defineobject

    set dtype=pointer
    call :set slot=%%debug.type[%id%].pointer[%head%]%%
    call :set data=%%debug.object[%foot%]%%
    if not "%slot%"=="" (if "%data%"=="" (call :pexit What %foot%?) else (goto :readline.defineobject))
    call :set data=%%interpret.adjective[%head%].type[%id%]%%

    set dtype=state
    call :set slot=%%interpret.adjective[%head%].type[%id%].state%%
    if not "%slot%"=="" goto :readline.defineobject

    set dtype=property
    call :set slot=%%interpret.adjective[%head%].type[%id%].property%%
    if not "%slot%"=="" goto :readline.defineobject

    call :pexit What kind of thing is %head%?
    :readline.defineobject
    if "%dtype%"=="pointer" call :readline.defineobject.test
    set object[%dream.environment.objects%].%dtype%[%slot%]=%data%
    goto :eof

    :readline.defineobject.test
    call :set test=%%object[%data%]%%
    call :set right=%%type[%id%].pointer[%slot%]%%
    :readline.defineobject.test.loop
    if "%test%"=="%right%" goto :eof
    call :set test=%%type[%test%].super%%
    if "%test%"=="0" (call :pexit What kind of %right% is a %%object[%data%]%%?
    goto :readline.defineobject.test.loop

    :readline.close[hook]
    goto :eof

    :readline.seek[hook]
    for /f "tokens=1*" %%f in ("%steeze%") do (
    set verb=%%f
    set eventname=%%g
    )
    call :set event=%%debug.event[%eventname%]%%
    if "%event%"=="" (call :pexit How do I %eventname%?)
    call :set action=%%interpret.hook.action[%verb%]%%
    if "%action%"=="" (set /a hook.actions=hook.actions+1
    call :set action=%%hook.actions%%)
    set interpret.hook.action[%verb%]=%action%
    call :set ob=%%event[%event%].object%%
    call :set in=%%event[%event%].instrument%%
    if "%in%"=="" (call :readline.seek.hook.ob
    goto :eof)
    call :readline.seek.hook.in
    call :readline.seek.hook.ob
    set in.touse=
    goto :eof


    :readline.seek.hook.ob.mark
    if "%ob.tosub%"=="" goto :eof
    for /f "tokens=1* delims=;" %%f in ("%ob.tosub%") do (set ob=%%f
    set ob.tosub=%%g
    )

    :readline.seek.hook.ob
    call :readline.seek.hook.roll
    call :set ob.sub=%%type[%ob%].sub%%
    set ob.tosub=%ob.tosub%%ob.sub%
    goto :readline.seek.hook.ob.mark



    :readline.seek.hook.in.mark
    if "%in.tosub%"=="" goto :eof
    for /f "tokens=1* delims=;" %%f in ("%in.tosub%") do (set in=%%f
    set in.tosub=%%g
    )

    :readline.seek.hook.in
    call :set in.sub=%%type[%in%].sub%%
    set in.tosub=%in.tosub%%in.sub%
    set in.touse=%in.touse%%in.sub%
    goto :readline.seek.hook.in.mark

    :readline.seek.hook.roll
    if "%in.touse%"=="" (set hook.action[%action%].using[%ob%.]=%event%
    goto :eof)
    set touse=%in.touse%
    :readline.seek.hook.rolling
    for /f "tokens=1* delims=;" %%f in ("%touse%") do (set in=%%f
    set touse=%%g
    )
    set hook.action[%action%].using[%ob%,%in%]=%event%
    if "%touse%"=="" goto :eof
    goto :readline.seek.hook.rolling

    That's version 0.3.1, I have some documentation and stuff if anyone is actually interested
    I'm not narcissistic, I just actually am brilliant.

    millergram



      Rookie

      • Experience: Beginner
      • OS: Windows Vista
      Re: Batch Programs Thread.
      « Reply #577 on: January 07, 2014, 01:39:33 PM »
      Hey guys. I really like RPS (Rock Paper Scissors) so here is another one.

      Code: [Select]
      @Echo off
      rem RPS by ChaviusMiller


      rem this is the Title line
      title RPS
      rem this line defines user/AI information
      set UC=
      set AIC=
      set User=
      set TW=0
      set TL=0
      rem "UC" is user choice "AIC" is AI choice "User" username "TW" times won "TL" times lost
      set /p User=Username=
      rem above line prompts for what to specific value "User" as
      :main
      rem above line specifies the beggining of the part of the script that will be recalled
      cls
      echo.Welcome %User%
      echo.
      echo.This is Rock Paper Scissors(RPS).
      echo.
      echo.Please choose a stance R=rock P=paper S=scissors
      echo.
      echo.Computer %TL% %User% %TW%
      set /p UC=RPS!:
      if /i "%UC%"=="debug" goto debug
      if /i "%UC%"=="r" goto rock
      if /i "%UC%"=="p" goto paper
      if /i "%UC%"=="s" goto scissor
      if /i "%UC%"=="%UC%" goto main
      rem above lines filter "UC" for its choices
      rem last line for "if /i "US"=="%UC%" goto main" says if none of the above options are not chosen then by default it goes back to the beggining
      :rock
      rem below sets Aic to equal a random number between 1-3
      set UC=1
      set /a AIC=%random% %%3 + 1
      goto calculateR
      :paper
      set UC=2
      set /a AIC=%random% %%3 + 1
      goto calculateP
      :scissor
      set UC=3
      set /a AIC=%random% %%3 + 1
      goto calculateS
      :calculateR
      if "%AIC%"=="1" goto tie
      if "%AIC%"=="2" goto loss
      if "%AIC%"=="3" goto win
      :calculateP
      if "%AIC%"=="1" goto win
      if "%AIC%"=="2" goto tie
      if "%AIC%"=="3" goto loss
      :calculateS
      if "%AIC%"=="1" goto loss
      if "%AIC%"=="2" goto win
      if "%AIC%"=="3" goto tie
      :loss
      set /a TL=%TL%+1
      Echo.Sorry you loose!
      echo.
      echo.Computer %TL% %User% %TW%
      pause
      goto main
      :win
      set /a TW=%TW%+1
      echo.You win!
      echo.
      echo.Computer %TL% %User% %TW%
      pause
      goto main
      :tie
      echo.You tied!
      echo.
      echo.Computer %TL% %User% %TW%
      pause
      goto main
      :debug
      set /a AIC=%random% %%3 + 1
      echo.%AIC%
      goto debug

      Also this may be my best yet.
      Wondering what to do now that RPS is understood ???

      spivee



        Rookie

      • illo gaude
      • Thanked: 5
      • Experience: Familiar
      • OS: Windows 7
      Re: Batch Programs Thread.
      « Reply #578 on: January 11, 2014, 06:18:48 PM »
      Quote
      Also this may be my best yet.
      Wondering what to do now that RPS is understood ???

      You could make this more dynamical... else when I have no projects to work on, I usually make subroutines that I might want to use later.
      I'm not narcissistic, I just actually am brilliant.

      Geek-9pm


        Mastermind
      • Geek After Dark
      • Thanked: 1026
        • Gekk9pm bnlog
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: Batch Programs Thread.
      « Reply #579 on: January 11, 2014, 07:36:27 PM »
      Your main batch can call other batch files and pass parameters. This makers a job of writing  new programs easier.  :)
      You may wish to adopt a naming convention that reminds your that a batch file is meant to be called as a subroutine with parameters. Underscore works.
      Example:
      rummy.bat
      poker.bat
      _random.bat
      _rank.bat
      _score.bat

      This first two are main program files. The  others are subroutines  used by loth of the main programs. If the subroutines are generalized, such  can be used again in other game programs. Creating  meaningful names helps.  No, not the computer - it helps you remember what it does.  8)

      simplyTechy100



        Rookie

        Thanked: 1
        • Experience: Expert
        • OS: Windows 7
        Re: Batch Programs Thread.
        « Reply #580 on: March 06, 2014, 08:43:09 PM »
        @echo off
        set /p dir=Directory path:
        if %dir% == 'C:/' echo %date% %time% - Attempt to access root drive > prg.log else goto sw
        :sw
        echo Use the help given below for switches. Make sure to include this character:
        type chr/special/forsl.txt
        echo.
        dir /?
        set /p sw=Switchs:
        if sw = '' dir %dir% /4 else dir %dir% %sw%
        Yes, that is my code..
        I know its messy...
        And chr/special/forsl.txt is just a / xD
        And btw I can't get this script to work :( :||x :||

        Lemonilla



          Apprentice

        • "Too sweet"
        • Thanked: 70
        • Computer: Specs
        • Experience: Experienced
        • OS: Windows 7
        Re: Batch Programs Thread.
        « Reply #581 on: March 07, 2014, 06:57:54 PM »
        I wrote a simple Tower Defense game.  I may get around to adding other things to it, but probable not, so I figured I'd post it for anyone else.

        Code: (def.bat) [Select]
        @echo off
        setlocal EnableDelayedExpansion
        title Turret Defense

        echo Installing. . .
        if not exist def_bin md def_bin
        cd def_bin
        if not exist path for %%A in (-2.4\1 -1.4\2 1.4\3 2.4\4 3.4\5 4.4\6 4.3\7 4.2\8 4.1\9 5.1\10 6.1\11 7.1\12 8.1\13 8.2\14 8.3\15 8.4\16 8.5\17 8.6\18 9.6\19 10.6\20 11.6\21 12.6\22 13.6\23 14.6\24 14.5\25 14.4\26 15.4\27 16.4\28 17.4\29 18.4\30 18.3\31 19.3\32 20.3\33 20.4\34 20.5\35 21.5\36 22.5\37 23.5\38 23.4\39 24.4\40 25.4\41 26.4\42) do echo %%A >>path
        cls


        set range=10
        set turn=1
        set life=9
        set error=
        set wave.size=5
        set wave.spacing=3
        set turn.delay=1
        set color.flash=6
        set color.norm=7
        set hp.multip=2
        set turret.cost=30
        set /a gold.plus=%turret.cost%/2

        call :new_game
        :loop
        call :turn
        :end_turn
        call :wave
        :end_wave
        set /a turn+=1
        goto :loop

        :new_game
        for /f "delims=" %%A in ('dir turret* /b') do del /f %%A
        for /l %%Y in (1,1,7) do (
        for /l %%X in (1,2,26) do (
        set "cord.%%X.%%Y=."
        )
        for /l %%X in (0,2,26) do (
        set "cord.%%X.%%Y= "
        )
        )
        for %%A in (1.4 2.4 3.4 4.4 4.3 4.2 4.1 5.1 6.1 7.1 8.1 8.2 8.3 8.4 8.5 8.6 9.6 10.6 11.6 12.6 13.6 14.6 14.5 14.4 15.4 16.4 17.4 18.4 18.3 19.3 20.3 20.4 20.5 21.5 22.5 23.5 23.4 24.4 25.4 26.4) do set "cord.%%A="
        for /l %%P in (1,1,42) do set "path.%%P=0"
        set gold=30
        set turret=1
        goto :eof

        :map
        REM pause
        cls
        :load_map
        if "%life:~2,1%"=="" (
        if not "%life:~1,1%"=="" (
        set "life.backSpace="
        set "life.backSpace2=."
        ) else (
        set "life.backSpace=."
        set "life.backSpace2=."
        )
        ) else (
        set "life.backspace2="
        set "life.backspace="
        )
        set "lin.01=  A B C D E F G H I J K L M"
        set "lin.02=# . . . . . . . . . . . . . #%turn%"
        set "lin.03=###############################"
        set "lin.1=# %cord.1.1%%cord.2.1%%cord.3.1%%path.9%%path.10%%path.11%%path.12%%path.13%%cord.9.1%%cord.10.1%%cord.11.1%%cord.12.1%%cord.13.1%%cord.14.1%%cord.15.1%%cord.16.1%%cord.17.1%%cord.18.1%%cord.19.1%%cord.20.1%%cord.21.1%%cord.22.1%%cord.23.1%%cord.24.1%%cord.25.1%%cord.26.1%#..1"
        set "lin.2=# %cord.1.2%%cord.2.2%%cord.3.2%%path.8%%cord.5.2%%cord.6.2%%cord.7.2%%path.14%%cord.9.2%%cord.10.2%%cord.11.2%%cord.12.2%%cord.13.2%%cord.14.2%%cord.15.2%%cord.16.2%%cord.17.2%%cord.18.2%%cord.19.2%%cord.20.2%%cord.21.2%%cord.22.2%%cord.23.2%%cord.24.2%%cord.25.2%%cord.26.1%#..2"
        set "lin.3=# %cord.1.3%%cord.2.3%%cord.3.3%%path.7%%cord.5.3%%cord.6.3%%cord.7.3%%path.15%%cord.9.3%%cord.10.2%%cord.11.3%%cord.12.2%%cord.13.3%%cord.14.3%%cord.15.3%%cord.16.3%%cord.17.3%%path.31%%path.32%%path.33%%cord.21.3%%cord.22.3%%cord.23.3%%cord.24.3%%cord.25.3%%cord.26.3%#..3"
        set "lin.4=%path.1%%path.2%%path.3%%path.4%%path.5%%path.6%%cord.5.4%%cord.6.4%%cord.7.4%%path.16%%cord.9.4%%cord.10.4%%cord.11.4%%cord.12.4%%cord.13.4%%path.26%%path.27%%path.28%%path.29%%path.30%%cord.19.4%%path.34%%cord.21.4%%cord.22.4%%path.39%%path.40%%path.41%%path.42%%life%%life.backSpace%%life.backSpace2%4"
        set "lin.5=# %cord.1.5%%cord.2.5%%cord.3.5%%cord.4.5%%cord.5.5%%cord.6.5%%cord.7.5%%path.17%%cord.9.5%%cord.10.5%%cord.11.5%%cord.12.5%%cord.13.5%%path.25%%cord.15.5%%cord.16.5%%cord.17.5%%cord.18.5%%cord.19.5%%path.35%%path.36%%path.37%%path.38%%cord.24.5%%cord.25.5%%cord.26.5%#..5"
        set "lin.6=# %cord.1.6%%cord.2.6%%cord.3.6%%cord.4.6%%cord.5.6%%cord.6.6%%cord.7.6%%path.18%%path.19%%path.20%%path.21%%path.22%%path.23%%path.24%%cord.15.6%%cord.16.6%%cord.17.6%%cord.18.6%%cord.19.6%%cord.20.6%%cord.21.6%%cord.22.6%%cord.23.6%%cord.24.6%%cord.25.6%%cord.26.6%#..6"
        set "lin.7=# %cord.1.7%%cord.2.7%%cord.3.7%%cord.4.7%%cord.5.7%%cord.6.7%%cord.7.7%%cord.8.7%%cord.9.7%%cord.10.7%%cord.11.7%%cord.12.7%%cord.13.7%%cord.14.7%%cord.15.7%%cord.16.7%%cord.17.7%%cord.18.7%%cord.19.7%%cord.20.7%%cord.21.7%%cord.22.7%%cord.23.7%%cord.24.7%%cord.25.7%%cord.26.7%#..7"
        set "lin.8=################################"

        :draw_map
        echo %lin.01%
        echo %lin.02%
        echo %lin.03%
        echo %lin.1%
        echo %lin.2%
        echo %lin.3%
        echo %lin.4%
        echo %lin.5%
        echo %lin.6%
        echo %lin.7%
        echo %lin.8%

        goto :eof

        :turn

        call :map
        echo Gold: %gold%g
        echo.%error%
        echo.
        echo.  buy ^<X.Y^> %turret.cost%g Buys a turret and installs it to (X,Y).
        echo.  sell ^<X.Y^> %gold.plus%g Sells the turret at (X,Y).
        echo.  pass Ends the buying/selling phase.
        set /p cmd=^>
        echo. Processing Command. Please wait. . .
        for /f "delims= " %%A in ("%cmd%") do call :%%A
        goto :turn

        :buy
        set /a gold-=%turret.cost%
        if %gold% LSS 0 (
        set /a gold+=%turret.cost%
        ) else (
        for /f "tokens=2 delims= " %%S in ("%cmd%") do (
        for /f "tokens=1,2 delims=." %%A in ("%%S") do (

        if /i "%%A"=="a" set A=1
        if /i "%%A"=="b" set A=3
        if /i "%%A"=="c" set A=5
        if /i "%%A"=="d" set A=7
        if /i "%%A"=="e" set A=9
        if /i "%%A"=="f" set A=11
        if /i "%%A"=="g" set A=13
        if /i "%%A"=="h" set A=15
        if /i "%%A"=="i" set A=17
        if /i "%%A"=="j" set A=19
        if /i "%%A"=="k" set A=21
        if /i "%%A"=="l" set A=23
        if /i "%%A"=="m" set A=25

        if defined cord.!A!.%%B set cord.!A!.%%B=T
        if "%%B"=="" (
        set /a gold+=%turret.cost%
        set error=Wrong Syntax
        goto :eof
        )
        if "!A!"=="" (
        set /a gold+=%turret.cost%
        set error=Wrong Syntax
        goto :eof
        )
        echo !A!.%%B >turret%turret%
        call :Func_TurretRange !A! %%B
        set /a turret+=1
        )
        )
        )
        set error=
        goto :eof

        :sell
        for /f "tokens=2 delims= " %%S in ("%cmd%") do (
        for /f "tokens=1,2 delims=." %%A in ("%%S") do (

        if /i "%%A"=="a" set A=1
        if /i "%%A"=="b" set A=3
        if /i "%%A"=="c" set A=5
        if /i "%%A"=="d" set A=7
        if /i "%%A"=="e" set A=9
        if /i "%%A"=="f" set A=11
        if /i "%%A"=="g" set A=13
        if /i "%%A"=="h" set A=15
        if /i "%%A"=="i" set A=17
        if /i "%%A"=="j" set A=19
        if /i "%%A"=="k" set A=21
        if /i "%%A"=="l" set A=23
        if /i "%%A"=="m" set A=25


        set sell=0
        for /f "delims=" %%G in ('dir turret* /b') do (
        set /p loc=<%%G
        if "!loc!"=="!A!.%%B " (
        del /f %%G
        set /a gold+=!gold.plus!
        set "cord.!A!.%%B=."
        set sell=1
        )
        REM echo "!loc!"=="!A!.%%B"
        )
        )
        )
        if "%sell%"=="0" set error=No Turret Exists There.
        goto :eof

        :pass
        goto :end_turn

        :wave
        :wave.setup
        for /l %%A in (1,1,%wave.size%) do (
        set /a creap%%A.hp=%turn%*%hp.multip%
        if !creap%%A.hp! GTR 9 (
        set creap%%A.sym=+
        ) else (
        set creap%%A.sym=!creap%%A.hp!
        )
        set /a creap%%A.pos=%%A-%wave.size%
        set /a creap%%A.pos*=%wave.spacing%
        )


        :wave.start
        REM Define Creap HP
        for /f "tokens=1 delims==" %%A in ('set creap ^| find ".sym"') do (
        for /f "tokens=1 delims=." %%B in ("%%A") do (
        for /f "tokens=2 delims=p" %%C in ("%%B") do (
        if !creap%%C.hp! GTR 9 (
        set creap%%C.sym=+
        ) else (
        set creap%%C.sym=!creap%%C.hp!
        ) 2>nul
        ) 2>nul
        ) 2>nul
        ) 2>nul



        REM Move creaps
        for /f "tokens=1,2 delims==" %%A in ('set creap ^| find ".pos"') do (
        set /a %%A=%%B+1
        REM echo set /a %%A=%%B+1
        for /f "tokens=2 delims=." %%G in ("%%A") do (
        if %%B EQU 42 (
        for /f "tokens=1 delims=." %%I in ("%%A") do (
        for /f "tokens=2 delims=p" %%H in ("%%I") do (
        set /a life-=!creap%%H.hp!
        set creap%%H.hp=
        set creap%%H.pos=
        set creap%%H.sym=
        ) 2>nul
        ) 2>nul
        ) 2>nul
        ) 2>nul
        ) 2>nul

        REM Kill Creaps
        for /l %%A in (1,1,%wave.size%) do (
        if "!creap%%A.hp!"=="0" (
        set creap%%A.hp=
        set creap%%A.pos=
        set creap%%A.sym=
        set /a gold.gain=%turn%/5
        set /a gold+=%gold.gain%
        ) 2>nul
        ) 2>nul

        REM Define new path variables
        for /l %%A in (0,1,42) do set path.%%A=0
        for /f "tokens=1,2 delims==" %%H in ('set creap ^| find ".pos"') do (
        for /f "tokens=1 delims=." %%A in ("%%H") do (
        for /f "tokens=2 delims=p" %%B in ("%%A") do (
        set path.%%I=!creap%%B.sym!
        ) 2>nul
        ) 2>nul
        ) 2>nul

        call :map


        REM Fire Turrets
        for /f "delims=" %%T in ('dir turret* /b') do (
        for /f "skip=1" %%N in (%%T) do (
        if not "!path%%N!"=="0" (
        for /f "tokens=1,2 delims==" %%C in ('set creap ^| find ".pos"') do (
        if "%%D"=="%%N" (
        for /f "tokens=1 delims=." %%X in ("%%C") do (
        for /f "tokens=2 delims=p" %%Z in ("%%X") do (
        set /a creap%%Z.hp-=1
        color 0%color.flash%
        set flash=1
        ) 2>nul
        ) 2>nul
        ) 2>nul
        if "!flash!"=="1" (
        ping localhost -n 1 >nul 2>&1
        ping localhost -n 1 >nul 2>&1
        :: ping localhost -n 1 >nul 2>&1
        color 0%color.norm%
        call :map
        set flash=0
        ) 2>nul
        ) 2>nul
        ) 2>nul
        ) 2>nul
        ) 2>nul


        if %life% LEQ 0 goto :endgame


        ping localhost -n %turn.delay% >nul


        set creap>nul 2>&1 || (
        set /a life.gain=%turn%/5
        set /a life+=!life.gain!
        goto :end_wave
        )
        goto :wave.start

        :endgame
        set "life=0"
        call :map
        echo.
        echo You lose on turn %turn%.
        pause>nul
        exit

        :Func_TurretRange
        set startx=%1
        set starty=%2
        for /l %%A in (0,1,30) do (
        for /l %%B in (0,1,10) do (
        call :Func_TurretRange.check %%A %%B
        )
        )
        set startx=
        set starty=
        goto :eof
        :Func_TurretRange.check
        set /a workingx=%startx%-%1
        set /a workingy=%starty%-%2
        if %workingx% LSS 0 set workingx=%workingx:~1%
        if %workingy% LSS 0 set workingy=%workingy:~1%
        set /a working=%workingx%+%workingy%
        REM if %working% LSS %range% if %working% GTR 0 echo %1.%2 >>turret%turret%
        if %working% LSS %range% if %working% GTR 0 for /f "tokens=1,2 delims=\" %%H in (path) do if /i "%1.%2"=="%%H" echo %%I >>turret%turret%
        set working=
        set workingx=
        set workingy=
        goto :eof

        It will create a folder named def_bin as well as a file named "path" (with no extension).  Either of these can be deleted at any time.

        Enjoy!
        Quote from: patio
        God Bless the DOS Helpers...
        Quote
        If it compiles, send the files.

        foxidrive



          Specialist
        • Thanked: 268
        • Experience: Experienced
        • OS: Windows 8
        Re: Batch Programs Thread.
        « Reply #582 on: March 07, 2014, 09:15:26 PM »
        I wrote a simple Tower Defense game.

        title Turret Defense


        Don't pass on your first move. :D

        Lemonilla



          Apprentice

        • "Too sweet"
        • Thanked: 70
        • Computer: Specs
        • Experience: Experienced
        • OS: Windows 7
        Re: Batch Programs Thread.
        « Reply #583 on: March 07, 2014, 09:44:59 PM »
        Don't pass on your first move. :D
        I laughed so hard that I almost fell out of my chair.
        If you change the global variable hp.multip to 1 you won't lose.  I set it to lose for testing and forgot to turn it back.
        Quote from: patio
        God Bless the DOS Helpers...
        Quote
        If it compiles, send the files.

        foxidrive



          Specialist
        • Thanked: 268
        • Experience: Experienced
        • OS: Windows 8
        Re: Batch Programs Thread.
        « Reply #584 on: March 07, 2014, 10:08:59 PM »
        :D    I changed that variable...

        but I can't figure out what's what.  is an 0 a turret?  What's with all the numbers going along the stream?  Is that a ray gun?

        I bought a turret at G.6 and nothing changed, except the ray gun stopped part way through and the screen colour changed to grey on black.