| 1. |
Solve : Script terminating without error? |
|
Answer» So my program is stopping without telling me the error (if there is one). So my program is stopping without telling me the error (if there is one). Replace that ::------------ line with PAUSE. See if it executes the pause or not. If it does then PLACE PAUSE further down. The call set command doesn't need a call though, does it?@No need for 'call set' No I guess it doesn't, good catch. @pause It does execute the pause, just not anything after it. Is there a limit on how many else if statements you can use? Code: [Select]pause if "!arg%a%!"=="/s" ( pause does first pause, not 2nd. EDIT: I managed to get it to run. It still isn't doing what it's suppose to though. Code: [Select]if "!arg%a%!"=="/c" set /a b=%a%+1 if "!arg%a%!"=="/c" call set "cordinate=!arg%b%!" if "!arg%a%!"=="/c" set /a c=%a%+2 if "!arg%a%!"=="/c" if not "!arg%c%:~0,1!"=="/" ( set arg%a%=!arg%c%! set arg%b%=!arg%c%! ) || ( set /a c+=2 if not "!arg%c%:~0,1!"=="/" ( set arg%a%=!arg%c%! set arg%b%=!arg%c%! ) || ( set /a c-=4 if not "!arg%c%:~0,1!"=="/" ( set arg%a%=!arg%c%! set arg%b%=!arg%c%! ) ) ) set c=0 It is suppose to look to the right and left 2 arguments and copy those. so '_graph.bat 1.3 /c o' would change "/c o" to "1.3 1.3"So I jumped through some hoops for this one, but I got it working. Code: [Select]@echo off setlocal EnableDelayedExpansion REM Declare default signs set cordinate=+ set space=- set zero=^& REM Find the number of arguments 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 set arg!num_args!=%1 shift goto loop ) set findArg_value= REM Check for modifyers goto :Modifyers.start :Modifyers.end REM Seperate coordinates into X and Y values set a=0 :find_argX/argY set /a a+=1 for /f "tokens=1,2 delims=." %%B in ('call echo !arg%a%!') do ( set argX%a%=%%B set argY%a%=%%C ) if not "%num_args%"=="%a%" goto :find_argX/argY set a= REM Find the max X and Y values set argX_max=0 set argY_max=0 set a=0 :find_argX.max/argY.max set /a a+=1 call set workingArgX=!argX%a%! call set workingArgY=!argY%a%! if %workingArgX% GTR %argX_max% set argX_max=%workingArgX% if %workingArgY% GTR %argY_max% set argY_max=%workingArgY% if not "%a%"=="%num_args%" goto :find_argX.max/argY.max set workingArgX= set workingArgY= set a= REM Find the min X and Y values set argX_min=0 set argY_min=0 set a=0 :find_argX.min/argY.min set /a a+=1 call set workingArgX=!argX%a%! call set workingArgY=!argY%a%! if %workingArgX% LSS %argX_min% set argX_min=%workingArgX% if %workingArgY% LSS %argY_min% set argY_min=%workingArgY% if not "%a%"=="%num_args%" goto :find_argX.min/argY.min set workingArgX= set workingArgY= set a= REM Create coordinate veriables for /l %%D in (%argX_min%,1,%argX_max%) do ( for /l %%E in (%argY_min%,1,%argY_max%) do ( set cordx=%%D set cordy=%%E set "cord!cordx!.!cordy!=!space!" ) ) set cordx= set cordy= REM assign 0 for /l %%A in (%argX_min%,1,%argX_max%) do ( for /l %%B in (%argY_min%,1,%argY_max%) do ( if %%A == 0 set "cord%%A.%%B=%zero%" if %%B == 0 set "cord%%A.%%B=%zero%" ) ) REM Assign arguments to coordinates set a=-1 :cord.arg.loop set /a a+=1 call set cord!arg%a%!=!cordinate! if not "%a%"=="%num_args%" goto :cord.arg.loop set a= REM Display table set /a y=%argY_max%+1 :display_y.loop echo. set /a y-=1 set /a x=%argX_min%-1 :display_x.loop set /a x+=1 0>nul set /p"=!cord%x%.%y%! " if not "%x%"=="%argX_max%" goto :display_x.loop if not "%y%"=="%argY_min%" goto :display_y.loop set y= set x= echo. REM Remove veriables from memory and exit ::for /f "tokens=1 delims==" %%Y in ('set a ^| find "arg"') do ( :: set %%Y= ::) ::for /f "tokens=1 delims==" %%Z in ('set c ^| find "cord"') do ( :: set %%Z= ::) ::set space= ::set zero= endlocal goto :end :Modifyers.start set a=1 set b=0 set c=0 set err=0 :: Help if "!arg%a%!"=="/?" goto :help :: No arguments if not defined arg%a% goto :help call :loop.findpoint :check.loop :: Space Char if "!arg%a%!"=="/s" set /a b=%a%+1 if "!arg%a%!"=="/s" set "space=!arg%b%!" if "!arg%a%!"=="/s" set /a c=%a%+2 if "!arg%a%!"=="/s" ( set arg%a%=%arg_rep% set arg%b%=%arg_rep% ) set c=0 set b=0 set err=0 :: Coord Char if "!arg%a%!"=="/c" set /a b=%a%+1 if "!arg%a%!"=="/c" set "cordinate=!arg%b%!" if "!arg%a%!"=="/c" set /a c=%a%+2 if "!arg%a%!"=="/c" ( set arg%a%=%arg_rep% set arg%b%=%arg_rep% ) set c=0 :: Zero Char if "!arg%a%!"=="/z" set /a b=%a%+1 if "!arg%a%!"=="/z" set "zero=!arg%b%!" if "!arg%a%!"=="/z" set /a c=%a%+2 if "!arg%a%!"=="/z" ( set arg%a%=%arg_rep% set arg%b%=%arg_rep% ) set c=0 set /a a+=1 if not "%a%"=="%num_args%" goto :check.loop set a= goto :Modifyers.end :loop.findPoint for /f "tokens=1,2 delims==" %%A in ('set arg') do ( call :findpoint %%A %%B ) goto :loop.findpoint.end :findpoint for /f "tokens=1,2 delims=." %%B in ("%2") do ( if not "%%C"=="" set arg_rep=%2 ) goto :eof :loop.findpoint.end goto :eof :help echo Graphs coordinates on a coordinate plane. echo. echo Graph ^[^/c ^<char^>^] ^[^/s ^<char^>^] ^[^/z ^<char^>^] x.y x.y x.y ... echo. echo /c Defines what character the coordinates will be shown as. echo /s Defines what character the empty spaces will be shown as. echo /z Defines what character the axis will be shown as. echo. echo %%^^^&^)^=^|^;^"^<^>^,^! Cannot be used with /c, /s or /z. goto :end :end exit /b Ex: Code: [Select] C:\Macros\In The Works>_graph 1.2 -5.3 7.0 9.5 0.-3 - - - - - & - - - - - - - - + - - - - - & - - - - - - - - - + - - - - & - - - - - - - - - - - - - - & + - - - - - - - - - - - - - & - - - - - - - - - & & & & & & & & & & & & + & & - - - - - & - - - - - - - - - - - - - - & - - - - - - - - - - - - - - + - - - - - - - - - C:\Macros\In The Works> That's a neat batch. |
|