It's programming time!/Batch/Echo/More

From Create Your Own Story

< It's programming time! | Batch | Echo(Difference between revisions)
m (Echo/More)
m (Echo/More)
 
Line 13: Line 13:
  rem use echo. to add a blank line to the output.
  rem use echo. to add a blank line to the output.
   
   
-
  echo Where'd this text go^? > "Oh here it is.txt"
+
  echo Where'd this text go? > "Oh here it is.txt"
-
  echo You can store variables using the '''set''' command and ^= operator.
+
  echo You can store variables using the '''set''' command and = operator.
  set myVar=This is a variable.
  set myVar=This is a variable.
  echo.
  echo.
Line 23: Line 23:
   
   
  echo You can also use '''echo''' to write to files.
  echo You can also use '''echo''' to write to files.
-
  echo This stuff is in newFile^.txt >> "newFile.txt"
+
  echo This stuff is in newFile.txt >> "newFile.txt"
  echo You can then use '''type''' to read files.
  echo You can then use '''type''' to read files.
  type newFile.txt
  type newFile.txt
   
   
  pause
  pause
-
+
<div>You can run this file more than once to see how '''>''' and '''>>''' work differently.</div>
 +
 
*[[It's_programming_time!/Batch/Echo|Let's go back to the basics of "'''echo'''".]]
*[[It's_programming_time!/Batch/Echo|Let's go back to the basics of "'''echo'''".]]
*[[It's_programming_time!/Batch/Type|Why do I need '''type'''. I want to use '''echo''' for everything.]]
*[[It's_programming_time!/Batch/Type|Why do I need '''type'''. I want to use '''echo''' for everything.]]
 +
*[[It's_programming_time!/Batch/Variable|I need to '''set''' variables to different values. Tell me how.]]
*[[It's_programming_time!/Batch/Redirection Operators|What about those '''>''' and '''>>''' operators? Explain.]]
*[[It's_programming_time!/Batch/Redirection Operators|What about those '''>''' and '''>>''' operators? Explain.]]
-
*[[It's_programming_time!/Batch/Escaping Characters|What's the '''^''' for?]]
 
[[Category:It's programming time!|Batch]]
[[Category:It's programming time!|Batch]]
[[Category:It's programming time!/Batch|Echo]]
[[Category:It's programming time!/Batch|Echo]]

Current revision as of 16:29, 19 July 2016

Echo/More

There are all kinds of ways you can use echo. Let's try some cool stuff with it.

This example outputs some files. Be careful not to overwrite something accidentally.

You should have the hang of making batch files by now:

@echo OFF
echo Time for some fun with echo.
echo.
rem use echo. to add a blank line to the output.

echo Where'd this text go? > "Oh here it is.txt"
echo You can store variables using the set command and = operator.
set myVar=This is a variable.
echo.
echo And you can display variables using the echo command.
echo %myVar%
echo.
pause

echo You can also use echo to write to files.
echo This stuff is in newFile.txt >> "newFile.txt"
echo You can then use type to read files.
type newFile.txt

pause
You can run this file more than once to see how > and >> work differently.
Personal tools