This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-10-27 13:21:44

poopo
Scratcher
Registered: 2009-09-20
Posts: 1000+

Batch programming

Does anyone have a good tutorial for batch programming?
I'd love to make text based versions of minecraft for example.  smile


http://i45.tinypic.com/28rnqki.jpg

Offline

 

#2 2011-10-27 13:24:34

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Batch programming

Good luck with that minecraft project. Batch is really not made for advanced scripting: you should try C++ instead! It even compiles into an EXE  tongue

As for tutorials, I have a really heavy black and white book called MS DOS 6.0 published in the 20th century that dedicates 300 pages to the batch syntax. I doubt that many still have it though, so an online tutorial might be better  wink

Offline

 

#3 2011-10-27 13:33:10

poopo
Scratcher
Registered: 2009-09-20
Posts: 1000+

Re: Batch programming

LS97 wrote:

Good luck with that minecraft project. Batch is really not made for advanced scripting: you should try C++ instead! It even compiles into an EXE  tongue

As for tutorials, I have a really heavy black and white book called MS DOS 6.0 published in the 20th century that dedicates 300 pages to the batch syntax. I doubt that many still have it though, so an online tutorial might be better  wink

Thanks!  smile  I am learning Java so no need for C++ YET. I found a number of tutorials for MSDOS 6.0
but they where for windows 95. XD Has the syntax changed at all?


http://i45.tinypic.com/28rnqki.jpg

Offline

 

#4 2011-10-27 13:35:30

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Batch programming

poopo wrote:

LS97 wrote:

Good luck with that minecraft project. Batch is really not made for advanced scripting: you should try C++ instead! It even compiles into an EXE  tongue

As for tutorials, I have a really heavy black and white book called MS DOS 6.0 published in the 20th century that dedicates 300 pages to the batch syntax. I doubt that many still have it though, so an online tutorial might be better  wink

Thanks!  smile  I am learning Java so no need for C++ YET. I found a number of tutorials for MSDOS 6.0
but they where for windows 95. XD Has the syntax changed at all?

Some commands have been added (such as shutdown support which was not possible in older PCs) and some have been removed (such as dosshell since we have win explorer).

Offline

 

#5 2011-10-27 23:39:52

meowmeow55
Scratcher
Registered: 2008-12-24
Posts: 1000+

Re: Batch programming

Well, there's the Wikipedia page of DOS commands, and there's also this page which explains variables, ifs, pipes/redirection, and things like that.


Yawn.

Offline

 

#6 2011-10-28 22:13:12

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Batch programming

Well, I suggest experimenting with multiple commands. Like the ECHO and SET commands:

Code:

echo @off :: Turns off the echo commands so it doesn't show "echo Welcome!" then "Welcome!" it only shows "Welcome!"
echo Welcome! :: Echo command
SET /P name=Hello! What is your name? :: SET sets a variable ( SET var=value ) the /P is basically the "ASK 'question' and wait" in Scratch
echo Hello %name%! :: %var% just shows the value of 'var' or in this case 'name'

Batch is not something to program in, especially games and making Minecraft in it would be extremely hard, harder than in Scratch. Though I did make a small game in it, though it is VERY basic.

Code:

@echo off

SET level=1
SET /A maxEXP=%level%*5
SET exp=0
SET /A maxHP=%level%*10
SET health=%maxHP%
SET lives=2
SET gold=0

SET /A mhp=%level%*5

SET /P name=Hello! What is your name? 

GOTO START

:START
ECHO Hello %name%! Welcome to this game!
ECHO Type HELP to learn more about the commands.
GOTO GETCMD

:BACKFROMTHEDEAD
IF %lives% LEQ 0 GOTO END
SET /A lives=%lives% - 1
ECHO You have been brought back from the dead. Someone walks up to you and says "You have %lives% more time(s) to die."
GOTO GETCMD

:GETCMD
IF %exp% GEQ %maxEXP% (
 SET /A level=%level%+1
 ECHO You leveled up! You are now level %level%!
 SET /A exp=%exp%-%maxEXP%
 SET /A maxHP=%level%*10
 SET /A mhp=%level%*5
 SET /A maxEXP=%level%*5 )
SET /P cmd=Command: 
GOTO RUNCMD

:RUNCMD
IF /I %cmd%==HELP GOTO HELP
IF /I %cmd%==QUIT GOTO END
IF /I %cmd%==EXPLORE GOTO EXPLORE
IF /I %cmd%==SHOP GOTO SHOP
IF /I %cmd%==INFO GOTO DETAILS
ECHO No command %cmd% & GOTO GETCMD


:HELP
ECHO Command : Description
ECHO HELP    : Shows help page.
ECHO EXPLORE : You can explore the world.
ECHO SHOP    : Shop for items to increase the chance of your survival
ECHO INFO    : Displays info about your character.
ECHO QUIT    : Exit the game.
GOTO GETCMD

:RANDOM
set ran=%random:~-1%
GOTO %return%

:EXPLORE
SET return=EXPLORE2
GOTO RANDOM

:EXPLORE2
IF %ran% == 0 SET /A gold=%gold% + 1 & ECHO You found a gold piece! & GOTO GETCMD
IF %ran% == 1 SET /A gold=%gold% + 1 & ECHO You found a gold piece! & GOTO GETCMD
IF %ran% == 2 SET /A gold=%gold% + 1 & ECHO You found a gold piece! & GOTO GETCMD
::IF %ran% == 3 GOTO ATTACKED & GOTO GETCMD
::IF %ran% == 4 GOTO ATTACKED & GOTO GETCMD
::IF %ran% == 5 GOTO ATTACKED & GOTO GETCMD
::IF %ran% == 6 GOTO ATTACKED & GOTO GETCMD
IF %ran% == 7 GOTO ATTACKED & GOTO GETCMD
IF %ran% == 8 GOTO ATTACKED & GOTO GETCMD
IF %ran% == 9 GOTO ATTACKED & GOTO GETCMD
ECHO You found nothing while exploring.
GOTO GETCMD

:DETAILS
ECHO Name  : %name%
ECHO Health: %health%/%maxHP%
ECHO Level : %level%
ECHO Exp   : %exp%/%maxEXP%
ECHO Gold  : %gold%
GOTO GETCMD

:SHOP
ECHO Item ID : Price : Item Details
ECHO 0       : 0     : Leave Shop
ECHO 1       : 1     : Health Potion - Restores HP
ECHO 2       : 2     : Monster Attraction - Attracts a monster

SET /P cmd=What would you like to buy? 

IF %cmd%==0 ECHO Come again! & GOTO GETCMD

IF %cmd%==1 (
 IF %gold% LEQ 0 ECHO Not enough money! & GOTO GETCMD
 SET /A gold=%gold% - 1
 ECHO Health restored!
 SET health=%maxHP%
 GOTO GETCMD )

IF %cmd%==2 (
 IF %gold% LEQ 1 ECHO Not enough money! & GOTO GETCMD
 SET /A gold=%gold%-2
 ECHO A monster appears!
 GOTO ATTACKED3 & GOTO GETCMD )

IF %cmd%==3 (
 IF %gold% LEQ 2 ECHO Not enough money! & GOTO GETCMD
 SET /A gold=%gold%-3
 SET /A lives=%lives%+1
 ECHO You have gained a life!
 GOTO GETCMD )

ECHO No such item!
GOTO GETCMD

:ATTACKED
SET return=ATTACKED2
GOTO RANDOM

:ATTACKED2
ECHO You were attacked by a monster and lost %ran% health!
SET /A health= %health% - %ran%
IF %health% LEQ 0 ECHO You died! & GOTO BACKFROMTHEDEAD
ECHO You have %health% left!
SET return=ATTACKED3
GOTO RANDOM

:ATTACKED3
ECHO You hit the monster and made him loose %ran% health!
SET /A mhp=%mhp% - %ran%
IF %mhp% LEQ 0 ECHO You killed the monster and found one gold piece and gained some expierence from the fight! & SET mhp=5 & SET /A gold=%gold% + 1 & SET /A exp=%exp% + 1 & GOTO GETCMD
SET return=ATTACKED2
GOTO RANDOM

:END
ECHO The End!

The battle system is not very good, sadly. Though it is a start, especially for something I made in about four hours over two days.

Hopefully that can help you get started on learning Batch.  smile

Offline

 

#7 2011-10-28 22:22:37

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: Batch programming

I'm trying to learn this too.

The "help" command is helpful and type "/?" after any command to learn what it does. Wiki Page.

Here's a program I quickly came up with, it's not very good but:

Code:

@ECHO off
Title Options
color 3
ECHO Welcome to system commands!
Choice /c LSIRHC /n /m "L=Log off, S=Shutdown, I=Instant Shut Down, R=Restart, 
H=Hibernate, C=Close All Programs"
If %ERRORLEVEL%==1 shutdown /l
If %ERRORLEVEL%==2 shutdown /s
If %ERRORLEVEL%==3 shutdown /p
If %ERRORLEVEL%==4 shutdown /r
If %ERRORLEVEL%==5 shutdown /h
If %ERRORLEVEL%==6 shutdown /f
Exit

Offline

 

#8 2011-10-29 05:31:53

nathanprocks
Scratcher
Registered: 2011-04-14
Posts: 1000+

Re: Batch programming

this might be useful for calling other batch files:

test1.bat:

Code:

@echo off
set /p name=What is your name? 
test2 %name%

test2.bat:

Code:

@echo off
echo Hello %1%!
pause

note that these are two seperate batch files  tongue


http://carrot.cassiedragonandfriends.org/Scratch_Signature/randomsig.php
http://trinary.site40.net/images/scratchrank.php?username=nathanprocks&display=small

Offline

 

#9 2011-11-06 14:36:19

Servine
Scratcher
Registered: 2011-03-19
Posts: 1000+

Re: Batch programming

Im more of a VBS guy, but:

Code:

ECHO Trolls be trolling.
GOTO WAFFLEMAN

::WAFLLEMAN
ECHO U MAD BRO?
pause

I literally just thought of that on the top of my head.


http://bluetetrarpg.x10.mx/usercard/?name=Servine

Offline

 

#10 2011-11-06 14:49:07

Servine
Scratcher
Registered: 2011-03-19
Posts: 1000+

Re: Batch programming

Servine wrote:

Im more of a VBS guy, but:

Code:

ECHO Trolls be trolling.
GOTO WAFFLEMAN

::WAFLLEMAN
ECHO U MAD BRO?
pause

I literally just thought of that on the top of my head.

wrong. this was meant for the 'Batch' topic


http://bluetetrarpg.x10.mx/usercard/?name=Servine

Offline

 

#11 2012-06-27 14:40:05

Pecola
Scratcher
Registered: 2011-01-21
Posts: 9

Re: Batch programming

Magnie wrote:

Well, I suggest experimenting with multiple commands. Like the ECHO and SET commands:

Code:

echo @off :: Turns off the echo commands so it doesn't show "echo Welcome!" then "Welcome!" it only shows "Welcome!"
echo Welcome! :: Echo command
SET /P name=Hello! What is your name? :: SET sets a variable ( SET var=value ) the /P is basically the "ASK 'question' and wait" in Scratch
echo Hello %name%! :: %var% just shows the value of 'var' or in this case 'name'

Batch is not something to program in, especially games and making Minecraft in it would be extremely hard, harder than in Scratch. Though I did make a small game in it, though it is VERY basic.

Code:

@echo off

SET level=1
SET /A maxEXP=%level%*5
SET exp=0
SET /A maxHP=%level%*10
SET health=%maxHP%
SET lives=2
SET gold=0

SET /A mhp=%level%*5

SET /P name=Hello! What is your name? 

GOTO START

:START
ECHO Hello %name%! Welcome to this game!
ECHO Type HELP to learn more about the commands.
GOTO GETCMD

:BACKFROMTHEDEAD
IF %lives% LEQ 0 GOTO END
SET /A lives=%lives% - 1
ECHO You have been brought back from the dead. Someone walks up to you and says "You have %lives% more time(s) to die."
GOTO GETCMD

:GETCMD
IF %exp% GEQ %maxEXP% (
 SET /A level=%level%+1
 ECHO You leveled up! You are now level %level%!
 SET /A exp=%exp%-%maxEXP%
 SET /A maxHP=%level%*10
 SET /A mhp=%level%*5
 SET /A maxEXP=%level%*5 )
SET /P cmd=Command: 
GOTO RUNCMD

:RUNCMD
IF /I %cmd%==HELP GOTO HELP
IF /I %cmd%==QUIT GOTO END
IF /I %cmd%==EXPLORE GOTO EXPLORE
IF /I %cmd%==SHOP GOTO SHOP
IF /I %cmd%==INFO GOTO DETAILS
ECHO No command %cmd% & GOTO GETCMD


:HELP
ECHO Command : Description
ECHO HELP    : Shows help page.
ECHO EXPLORE : You can explore the world.
ECHO SHOP    : Shop for items to increase the chance of your survival
ECHO INFO    : Displays info about your character.
ECHO QUIT    : Exit the game.
GOTO GETCMD

:RANDOM
set ran=%random:~-1%
GOTO %return%

:EXPLORE
SET return=EXPLORE2
GOTO RANDOM

:EXPLORE2
IF %ran% == 0 SET /A gold=%gold% + 1 & ECHO You found a gold piece! & GOTO GETCMD
IF %ran% == 1 SET /A gold=%gold% + 1 & ECHO You found a gold piece! & GOTO GETCMD
IF %ran% == 2 SET /A gold=%gold% + 1 & ECHO You found a gold piece! & GOTO GETCMD
::IF %ran% == 3 GOTO ATTACKED & GOTO GETCMD
::IF %ran% == 4 GOTO ATTACKED & GOTO GETCMD
::IF %ran% == 5 GOTO ATTACKED & GOTO GETCMD
::IF %ran% == 6 GOTO ATTACKED & GOTO GETCMD
IF %ran% == 7 GOTO ATTACKED & GOTO GETCMD
IF %ran% == 8 GOTO ATTACKED & GOTO GETCMD
IF %ran% == 9 GOTO ATTACKED & GOTO GETCMD
ECHO You found nothing while exploring.
GOTO GETCMD

:DETAILS
ECHO Name  : %name%
ECHO Health: %health%/%maxHP%
ECHO Level : %level%
ECHO Exp   : %exp%/%maxEXP%
ECHO Gold  : %gold%
GOTO GETCMD

:SHOP
ECHO Item ID : Price : Item Details
ECHO 0       : 0     : Leave Shop
ECHO 1       : 1     : Health Potion - Restores HP
ECHO 2       : 2     : Monster Attraction - Attracts a monster

SET /P cmd=What would you like to buy? 

IF %cmd%==0 ECHO Come again! & GOTO GETCMD

IF %cmd%==1 (
 IF %gold% LEQ 0 ECHO Not enough money! & GOTO GETCMD
 SET /A gold=%gold% - 1
 ECHO Health restored!
 SET health=%maxHP%
 GOTO GETCMD )

IF %cmd%==2 (
 IF %gold% LEQ 1 ECHO Not enough money! & GOTO GETCMD
 SET /A gold=%gold%-2
 ECHO A monster appears!
 GOTO ATTACKED3 & GOTO GETCMD )

IF %cmd%==3 (
 IF %gold% LEQ 2 ECHO Not enough money! & GOTO GETCMD
 SET /A gold=%gold%-3
 SET /A lives=%lives%+1
 ECHO You have gained a life!
 GOTO GETCMD )

ECHO No such item!
GOTO GETCMD

:ATTACKED
SET return=ATTACKED2
GOTO RANDOM

:ATTACKED2
ECHO You were attacked by a monster and lost %ran% health!
SET /A health= %health% - %ran%
IF %health% LEQ 0 ECHO You died! & GOTO BACKFROMTHEDEAD
ECHO You have %health% left!
SET return=ATTACKED3
GOTO RANDOM

:ATTACKED3
ECHO You hit the monster and made him loose %ran% health!
SET /A mhp=%mhp% - %ran%
IF %mhp% LEQ 0 ECHO You killed the monster and found one gold piece and gained some expierence from the fight! & SET mhp=5 & SET /A gold=%gold% + 1 & SET /A exp=%exp% + 1 & GOTO GETCMD
SET return=ATTACKED2
GOTO RANDOM

:END
ECHO The End!

The battle system is not very good, sadly. Though it is a start, especially for something I made in about four hours over two days.

Hopefully that can help you get started on learning Batch.  smile

Cool game good job on it  smile

Offline

 

#12 2012-06-27 15:05:24

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Batch programming

Thank you.  smile

Offline

 

#13 2012-07-04 06:27:46

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Batch programming

poopo wrote:

Does anyone have a good tutorial for batch programming?
I'd love to make text based versions of minecraft for example.  smile

Poopo, I am fluent in batch programming  big_smile
I can help you with anything you need!
smile


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

Board footer