Batch

The ubiquitous operating system, discussion of its (many) flaws, and how to mitigate the risks of those flaws

Re: Batch

Post by mutants_r_us_guild on Sun Jul 27, 2008 8:20 pm
([msg=8479]see Re: Batch[/msg])

Well since you can't use arrays in DOS (as far as I know.. however I have discovered how to make animations and store and retrieve variables from external txt files) sooo... im guessing you just used perl from command line.
Image
Image
Image
User avatar
mutants_r_us_guild
Poster
Poster
 
Posts: 246
Joined: Fri May 30, 2008 7:56 pm
Blog: View Blog (0)


Re: Batch

Post by mutants_r_us_guild on Sun Jul 27, 2008 8:28 pm
([msg=8481]see Re: Batch[/msg])

W00t!!
ANIMATION IN DOS!! *warning: this uses 100% of your CPU!

Code: Select all
@echo off
:main
set num=0
set num2=0
set num3=0
set color=1
:main5
if "%num3%" == "700" goto end5
set /a num3=%num3% + 1
goto main5
:end5
color 02
title You
echo                       #     #               
echo                        #   #    ####   #    #
echo                         # #    #    #  #    #
echo                          #     #    #  #    #
echo                          #     #    #  #    #
echo                          #     #    #  #    #
echo                          #      ####    ####
:main1
if "%num%" == "700" goto end1
set /a num=%num% + 1
goto main1
:end1
cls
color 04
title You Got
echo                       #     #               
echo                        #   #    ####   #    #
echo                         # #    #    #  #    #
echo                          #     #    #  #    #
echo                          #     #    #  #    #
echo                          #     #    #  #    #
echo                          #      ####    ####
echo                        #####                 
echo                        #     #   ####    #####
echo                        #        #    #     # 
echo                        #  ####  #    #     # 
echo                        #     #  #    #     # 
echo                        #     #  #    #     # 
echo                         #####    ####      # 
:main2
if "%num%" == "1400" goto end2
set /a num=%num% + 1
goto main2
:end2
cls
color 01
title You Got Owned
echo                       #     #               
echo                        #   #    ####   #    #
echo                         # #    #    #  #    #
echo                          #     #    #  #    #
echo                          #     #    #  #    #
echo                          #     #    #  #    #
echo                          #      ####    ####
echo                        #####                 
echo                        #     #   ####    #####
echo                        #        #    #     # 
echo                        #  ####  #    #     # 
echo                        #     #  #    #     # 
echo                        #     #  #    #     # 
echo                         #####    ####      #   
echo               #######                               
echo               #     #  #    #  #    #  ######  #####
echo               #     #  #    #  ##   #  #       #    #
echo               #     #  #    #  # #  #  #####   #    #
echo               #     #  # ## #  #  # #  #       #    #
echo               #     #  ##  ##  #   ##  #       #    #
echo               #######  #    #  #    #  ######  #####
:main3
if "%num%" == "2100" goto end3
set /a num=%num% + 1
goto main3
:end3
cls
:text
if "%num2%" == "300" goto main
if "%color%" == "9" set color=1
title You Got Owned
color 0%color%
echo                       #     #               
echo                        #   #    ####   #    #
echo                         # #    #    #  #    #
echo                          #     #    #  #    #
echo                          #     #    #  #    #
echo                          #     #    #  #    #
echo                          #      ####    ####
echo                        #####                 
echo                        #     #   ####    #####
echo                        #        #    #     # 
echo                        #  ####  #    #     # 
echo                        #     #  #    #     # 
echo                        #     #  #    #     # 
echo                         #####    ####      #   
echo               #######                               
echo               #     #  #    #  #    #  ######  #####
echo               #     #  #    #  ##   #  #       #    #
echo               #     #  #    #  # #  #  #####   #    #
echo               #     #  # ## #  #  # #  #       #    #
echo               #     #  ##  ##  #   ##  #       #    #
echo               #######  #    #  #    #  ######  #####
cls
set /a num2=%num2% + 1
set /a color=%color% +1
goto text




Last edited by mutants_r_us_guild on Sun Jul 27, 2008 8:43 pm, edited 1 time in total.
Image
Image
Image
User avatar
mutants_r_us_guild
Poster
Poster
 
Posts: 246
Joined: Fri May 30, 2008 7:56 pm
Blog: View Blog (0)


Re: Batch

Post by anonHacker on Sun Jul 27, 2008 8:33 pm
([msg=8482]see Re: Batch[/msg])

mutants_r_us_guild wrote:Well since you can't use arrays in DOS (as far as I know.. however I have discovered how to make animations and store and retrieve variables from external txt files) sooo... im guessing you just used perl from command line.

Actually, it's pure batch. Also, I've handwritten several variations on arrays in batch scripts at times. I assure you it's doable. If you finish programming 1, I'll show you my code. :-)
Last edited by anonHacker on Sun Jul 27, 2008 8:36 pm, edited 1 time in total.
anonHacker
Experienced User
Experienced User
 
Posts: 76
Joined: Sun Jul 27, 2008 10:51 am
Blog: View Blog (0)


Re: Batch

Post by mutants_r_us_guild on Sun Jul 27, 2008 8:34 pm
([msg=8483]see Re: Batch[/msg])

can you at least show me how to use arrays in DOS?

*edit* My code earlier.. it was supposed to say you got owned
but it formatted it all wrong
animation still kinda works though.
Image
Image
Image
User avatar
mutants_r_us_guild
Poster
Poster
 
Posts: 246
Joined: Fri May 30, 2008 7:56 pm
Blog: View Blog (0)


Re: Batch

Post by anonHacker on Sun Jul 27, 2008 8:41 pm
([msg=8484]see Re: Batch[/msg])

Arrays don't exist, but there are ways to use the mutable nature of batch scripts to obtain similar functionality.

One version would be:
Code: Select all
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET T=1
SET A%T%=Something
SET /A T+=1
SET A%T%=else
SET /A T+=1
SET A%T%=altogether
ECHO !A%T%!


Also, use code tags. It helps maintain formatting. ;)
anonHacker
Experienced User
Experienced User
 
Posts: 76
Joined: Sun Jul 27, 2008 10:51 am
Blog: View Blog (0)


Re: Batch

Post by mutants_r_us_guild on Sun Jul 27, 2008 8:44 pm
([msg=8485]see Re: Batch[/msg])

hmmm... Ill have to look at this. BTW, you forgot to add
end local
to the end. :P


*edit*

also... what happened here?

SET /A T+=1


dont you mean

set /a T=%T%+1
Last edited by mutants_r_us_guild on Sun Jul 27, 2008 8:48 pm, edited 1 time in total.
Image
Image
Image
User avatar
mutants_r_us_guild
Poster
Poster
 
Posts: 246
Joined: Fri May 30, 2008 7:56 pm
Blog: View Blog (0)


Re: Batch

Post by anonHacker on Sun Jul 27, 2008 8:46 pm
([msg=8486]see Re: Batch[/msg])

No, I didn't. ;)
EoF serves as an automatic ENDLOCAL. Please do be aware you are speaking to possibly one of the worst abusers of batch syntax, etc. in the world. I've done a lot of crap with batch script no sane person would use a batch script for.

Also, +=1 is the same as =%T%+1

Have fun!
anonHacker
Experienced User
Experienced User
 
Posts: 76
Joined: Sun Jul 27, 2008 10:51 am
Blog: View Blog (0)


Re: Batch

Post by mutants_r_us_guild on Sun Jul 27, 2008 9:01 pm
([msg=8487]see Re: Batch[/msg])

im not getting anything from it.. it only echoes the word "altogether"
Image
Image
Image
User avatar
mutants_r_us_guild
Poster
Poster
 
Posts: 246
Joined: Fri May 30, 2008 7:56 pm
Blog: View Blog (0)


Re: Batch

Post by anonHacker on Sun Jul 27, 2008 9:13 pm
([msg=8489]see Re: Batch[/msg])

Yes, that's the only part it's meant to echo.
anonHacker
Experienced User
Experienced User
 
Posts: 76
Joined: Sun Jul 27, 2008 10:51 am
Blog: View Blog (0)


Re: Batch

Post by mutants_r_us_guild on Sun Jul 27, 2008 9:32 pm
([msg=8490]see Re: Batch[/msg])

Oh... okay... sooo.. how does this help me.. How can DOS take input and break each letter into a variable? This is all I can do with it:

Code: Select all
@Echo Off
SetLocal EnableDelayedExpansion
echo.
set t=1
Set var%t%=something
set /a t=%t% + 1
Set var%t%=else
set /a t=%t% + 1
Set var%t%=altogether
set max=3
For /L %%i in (1,1,%max%) Do Echo !var%%i!
EndLocal
echo.
echo.
echo.
pause
exit
Image
Image
Image
User avatar
mutants_r_us_guild
Poster
Poster
 
Posts: 246
Joined: Fri May 30, 2008 7:56 pm
Blog: View Blog (0)


PreviousNext

Return to Microsoft Windows

Who is online

Users browsing this forum: No registered users and 0 guests