00:00
00:00
Newgrounds Background Image Theme

TheADHX just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Batch programming

1,410 Views | 24 Replies
New Topic Respond to this Topic

Batch programming 2008-10-03 19:39:14


Batch, if you know it you love it... But why should you use it? It is one of the best "Starter" langauges, it is incredably easy and useful.

I will show you some starter codes to get the "Batch Noobs" started.

ECHO - command that will display a text

ECHO iamrunegecko

would return:
iamrunegecko in the command prompt.

Title - code used to name the command prompt insance

Title iamrunegecko

would turn the title of the instance to iamrunegecko

SET /P c= - used for promting a users answer or text

set /p c=Choose a fruit:

would return "Choose a fruit:"
this code allows the user to type text, this text can be used in variables to set choices for complex programs coded in batch. the C in the code represents the varriable to save the text entered to.

VARRIABLES:

All varriables in coding should be surrounded in % markers, IE %C%.

varriables can be used for almost anything in batch, from choosing a menu or internal program to Run programs and even more complex things.

for an example RSWS (Runescape/Runegecko World Switcher) utilizes the varriables function to choose detail modes and worlds.

i will show an example code and explain use of varibles.

:RSWS NG CODE
echo for use on NG only
echo this will explain varriables....
echo .
echo choose a world
set /p world=Choose a world:
start http://world%world%.RSURL.END
echo opened world %world%
goto RSWS NG CODE

this echo's, uses set text's, and uses a start command to open a url with varriables.

as you can see batch is a very simple language

To download projects and other things goto
Runegecko.tripod.com/rhb

more tutorials to come

Response to Batch programming 2008-10-03 20:00:19


Batches are also incredibly useless to use, especially with Python around.
In other words, we have no use for batch "language" tutorials.


BBS Signature

Response to Batch programming 2008-10-03 20:13:02


I like this, I never knew how to get user input in batch programs :p (I never researched it though ^^)
But some years ago I wrote a whole 'Windows for dos' ASII interface for dos completely made out of batch programs.
All filled with echo statements

good times ^^

Response to Batch programming 2008-10-03 20:49:36


Batch script is great.... I have used it for some times in command prompt.
Since I switched to Linux, I now use the "bash shell", which is more simple.

How to you loop through files in a directory and run a command on it?
I did not remember if bash can do that.

This is an example on bash:

for i  in *; do echo The file name is $i; done

Any equivalent on batch script file?

If you like batch programming, you may also like:
- AutoIt script or...
- AutoHotHey (open source)
Both are free and have similar functions... But with way different syntax.

Response to Batch programming 2008-10-04 01:59:16


Wow thanks for this post.


sig made by Pr3mo

BBS Signature

Response to Batch programming 2008-10-04 08:50:02


At 10/3/08 08:49 PM, theDtTvB wrote: Batch script is great.... I have used it for some times in command prompt.
Since I switched to Linux, I now use the "bash shell", which is more simple.

How to you loop through files in a directory and run a command on it?
I did not remember if bash can do that.

This is an example on bash:

for i in *; do echo The file name is $i; done

Any equivalent on batch script file?

the equavalent for the coding you post above is

:FOR USE ON NG ONLY
cd c:/
dir
goto FOR USE ON NG ONLY

This goes to the c:/ drive and shows you all of the files and directories within. after you have made it to the c:/ dirve you can delete move and make documents.

Response to Batch programming 2008-10-04 09:19:05


At 10/4/08 08:50 AM, iamrunegecko wrote:
FOR USE ON NG ONLY
cd c:/
dir
goto FOR USE ON NG ONLY

That is not the equivalent.
This is like making a bash script that does ls instead of the whole for i in * thing.
What he did here is manually looping through each file and outputting it's file name, which allows more flexibility if you want certain types of files not to be show etc.


BBS Signature

Response to Batch programming 2008-10-04 10:11:50


At 10/4/08 08:50 AM, iamrunegecko wrote: This goes to the c:/ drive and shows you all of the files and directories within. after you have made it to the c:/ dirve you can delete move and make documents.

Nope.... How can I process each file?
Like... how can I open all .txt file in Notepad?
notepad *.txt does not work.

Response to Batch programming 2008-10-04 12:03:35


I guess this is something fun to do if you're really bored.... like, REALLY REALLY BORED.

But how do I get CMD to stay open, when not doing it from the command line?

And how do I get it to stop saying what it's doing before it does it?


n/a

Response to Batch programming 2008-10-04 12:36:48


At 10/4/08 12:03 PM, ZiggyZack99 wrote: I guess this is something fun to do if you're really bored.... like, REALLY REALLY BORED.

But how do I get CMD to stay open, when not doing it from the command line?

And how do I get it to stop saying what it's doing before it does it?

If what I have remembered is right, type @echo off for the first line.

Response to Batch programming 2008-10-04 13:37:24


Batch isn't programming, it's just commands to do stuff you can do yourself using the built in file viewing stuff. The windows CMD is incredibly lame, compared to the Linux console (which is necessary for any 'advanced' users of Linux to use) which allows you to do pretty much anything, and it's easier than using the windows.. e.g. rather than going through synaptec package manager to download + install a program, just do:

sudo apt-get install Kate

Or, if you're unsure about something..

Kate
Kate is not installed, you can install Kate by typing sudo apt-get install Kate

So easy.


Sup, bitches :)

BBS Signature

Response to Batch programming 2008-10-04 13:49:54


At 10/4/08 01:37 PM, liaaaam wrote: Stuff about apt

But that is dependable on the fact that you run a Debian based (or Debian itself) distro (in this case i guess you got Ubuntu)
There are many other systems (one of them is Pacman used by Arch) and some distributions don't even use a package manager.
So you really do need to specify the distro when you start talking about things like apt.


BBS Signature

Response to Batch programming 2008-10-04 14:02:47


Actually you can program a shell script to be a CGI application.

I tried that already:

#!/bin/bash
echo "Content-Type: text/html"
echo ""
echo "Serving you content!"

Response to Batch programming 2008-10-04 16:30:19


At 10/4/08 12:03 PM, ZiggyZack99 wrote: I guess this is something fun to do if you're really bored.... like, REALLY REALLY BORED.

But how do I get CMD to stay open, when not doing it from the command line?

And how do I get it to stop saying what it's doing before it does it?

you have to use the command puase or the CMD will close, i like to prompt the user if they would like to start again using the SET /P VARIABLE=start again? command.

Response to Batch programming 2008-10-04 16:32:04


i will be making a tutorial page on my website for batch so you can choose what tutorials you would like to veiw

Response to Batch programming 2008-10-06 15:25:37


I am proud of the turnout to this post and am posting my new tutorial, Sending text to a document:

Start out codes:

echo TEXT>>sample.txt
echo %Variable%>>%Variable2%.txt
echo NG is pwng>>ng.newgroundsfile

ok, now for the basics. this tutorial will teach you how to use a batch to send a string of text to a document. this has many uses.

ok first make something like this:

:1
@echo off
echo this is a tutorial ment for Newgrounds.

now after you have entered this into the text editor of your choice, write some thing like this ender the last string of code:

echo this tutorial is awesome>>Iamrunegecko.txt

Now use your Text editors save as funtion to save this file as NGTUT.BAT
after you have saved it goto the location where you saved it and open NGTUT.BAT, it will make a text document called Iamrunegecko containing the text this tutorial is awesome.

Now i will teach how to change the file type the This tutorial is awesome will be sent to.

echo this tutorial is awesome>>Iamrunegecko.<Your choice>

this Will work.

as i stated above i will teach you how to work variables into this function.

:1
echo USE ON NG OR RUNEGECKO.TRIPOD.COM ONLY!!
set /p text=What text would you like?
set /p name=What filename would you like?
set /p ext=What file extension would you like?
echo %text%>>%name%.%ext%

This will save the designated text to the name and extension you chose.

Please comment on my tutorial.

Response to Batch programming 2008-10-06 19:20:33


At 10/6/08 03:25 PM, iamrunegecko wrote: Please comment on my tutorial.

Microsoft has better tutorials. THeir always the firs port of call for anything I need to know when using windows. But thats the obvious thing! http://social.technet.microsoft.com/Sear ch/en-US/?query=Batch%20programming&ac=8 And from their you can target specific things without having to even go into any depth, and thats all batch stuff is really good for.


PHP Main :: C++ Main :: Java Main :: Vorsprung durch Technik

irc.freenode.net #ngprogramming

BBS Signature

Response to Batch programming 2008-10-07 16:26:31


yes, but i find their tuorials a bit confusing. please dont bash my tutorial lol

Response to Batch programming 2008-10-09 16:26:30


ok, i am making my tutorial site right now the link will beHERE

If the link returns a tripod error it is because i have not published yet, i am currently doing that.

Thankyou for veiwing my BATCH forum/tutorial

Response to Batch programming 2008-10-09 17:49:42


Where in my post did I "bash" anything you said? Also if you find that confusing then whats the point of making a tutorial site if you dont fully understand what your trying to teach others. From the microsoft site you can get basic tutorials and build your way up to more ocmplex stuff. But honestly it only goes so deep with Batch programs.


PHP Main :: C++ Main :: Java Main :: Vorsprung durch Technik

irc.freenode.net #ngprogramming

BBS Signature

Response to Batch programming 2008-11-17 18:33:12


Ok, my website on Batch is official opened... i am constantly thinking up and adding tutorials. you can visit it HERE

I currently have tutorials for beginners and Experts so don't hesitate to click that link =)

Response to Batch programming 2008-11-21 18:28:25


Current Tutorials:
Beginning codes
Sending text
Fake Virus's
Free Batch source code downloads
Colors
Almost all commands
Much more to come!

Response to Batch programming 2008-11-21 19:06:33


Stop bumping.


BBS Signature

Response to Batch programming 2008-12-03 12:19:04


Should check my Batch Code Generator for making simple batch files


Applejuice ftw

BBS Signature

Response to Batch programming 2008-12-05 07:02:25


At 12/3/08 12:19 PM, ovi1 wrote: Should check my Batch Code Generator for making simple batch files

i have been working on a EXEcutable to do this but i never considered flash.