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

#1 2011-05-21 13:16:22

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Basic Batch cheat sheet

echo (message): echo meesage

set /p VarName=Message: variable prompt; message: Message, variable: VarName

help (command): how to use command

(                 :
commands   : execute commands
)                 :

if (test) (command): execute command if test is true

:labelName : label named labelName

goto (label): go to label

%VarName%: Read VarName

color (hex): set color to hex

echo.: echo a blank line

ren <old name> <new name>: rename <old name> to <new name>

del <file>: delete <file>

title <text>: sets title to text
------------------------------------------------------------
Don't get something? Reply to this post.

Last edited by ThePCKid (2011-05-21 13:19:33)

Offline

 

#2 2011-05-21 13:17:39

TornFusion
Scratcher
Registered: 2010-09-03
Posts: 1000+

Re: Basic Batch cheat sheet

this was for me, wasnt it

Offline

 

#3 2011-05-21 13:18:08

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: Basic Batch cheat sheet

TornFusion wrote:

this was for me, wasnt it

I thought of others, too.  smile

Offline

 

#4 2011-05-21 13:23:09

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Basic Batch cheat sheet

set /p (var) = Question

if "%(var)%"=="Answer" (

)


http://i46.tinypic.com/dw7zft.png

Offline

 

#5 2011-05-21 13:29:54

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: Basic Batch cheat sheet

SeptimusHeap wrote:

set /p (var) = Question

if "%(var)%"=="Answer" (

)

The equals sign has to be connected. Also, variable names are not enclosed in quotes and percent signs. Also, variable names cannot contain parentheses.
Fixed code:

Code:

set /p var="Question "
if %var%==Answer (
)

It's good to enclose the prompt in between quotes and add a space. You could also do a line break in between Question and the prompt:

Code:

echo Question
set /p var=
if %var%==Answer (
)

Also, if you are only doing one command in a if statement, it's good practice to not use parentheses.

Offline

 

#6 2011-05-21 13:33:16

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Basic Batch cheat sheet

ThePCKid wrote:

SeptimusHeap wrote:

set /p (var) = Question

if "%(var)%"=="Answer" (

)

The equals sign has to be connected. Also, variable names are not enclosed in quotes and percent signs. Also, variable names cannot contain parentheses.
Fixed code:

Code:

set /p var="Question "
if %var%==Answer (
)

It's good to enclose the prompt in between quotes and add a space. You could also do a line break in between Question and the prompt:

Code:

echo Question
set /p var=
if %var%==Answer (
)

Also, if you are only doing one command in a if statement, it's good practice to not use parentheses.

Uum...

if "%var%"=="Answer" works.


http://i46.tinypic.com/dw7zft.png

Offline

 

#7 2011-05-21 17:01:45

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: Basic Batch cheat sheet

SeptimusHeap wrote:

ThePCKid wrote:

SeptimusHeap wrote:

set /p (var) = Question

if "%(var)%"=="Answer" (

)

The equals sign has to be connected. Also, variable names are not enclosed in quotes and percent signs. Also, variable names cannot contain parentheses.
Fixed code:

Code:

set /p var="Question "
if %var%==Answer (
)

It's good to enclose the prompt in between quotes and add a space. You could also do a line break in between Question and the prompt:

Code:

echo Question
set /p var=
if %var%==Answer (
)

Also, if you are only doing one command in a if statement, it's good practice to not use parentheses.

Uum...

if "%var%"=="Answer" works.

Oh. I didn't know that.  tongue

Offline

 

Board footer