[Scripting] Coding Simple Things

View previous topic View next topic Go down

[Scripting] Coding Simple Things

Post  Tricks on Fri Dec 25, 2009 5:59 am

This is a simple tutorial on how to code diffrent types of languages. I might or might not update this.

+ Creating Loops
+ How to make a Password Protected Batch File

Batch:

Making a Batch File
1.) Open Notepad
2.) You don't have to type anything in, click "File" > "Save As"
3.) Name: Test.bat, Filetype: All files.
4.) Save to the Desktop

The file should look something like this:


Editing a Batch File
Once you have your batch file ready (Making a Batch File) do the following;
1.) Right click your batch file.
2.) Click Edit
3.) Notepad should open, you are currently editing your batch file.



Adding and showing a simple String
Questions:
What does string mean?
Text. For example; Your currently reading a string.

Make sure you have you batch file, and your currently in editing mode (Follow; Making a Batch File, Editing a Batch File). Type the following script;

Code:

@echo off

echo Hello, Im currently testing a string
echo.
echo My name is Tricks

pause >nul

Discribe:

@echo off - If this is not put on the top of a batch file, every command you enter will echo; Which means, every command will repeat itself as a string and show where it was executed from. This causes random and unwanted string.

echo - Basically an typing a string into the batch window.
echo.- A space between the strings

pause >nul - The main command for this sub command is "pause". Pause lets you pause the script so you can view it. If we didn't include pause above, the script would read itself and exit automatically because it dosnt know what else to do. If you press a key while the batch file is currently in pause state, it was proceed forward.

Example;

Code:

@echo off

echo Hello
pause >nul
echo Your coding batch!
pause >nul

This script will cause the prompt(batch file) to react in such ways;

First it will say :
"Hello"
Then once you press any key on the keyboard, it would say :
"Your coding batch!"
Once you press another key again, the script dosnt know what else to do, so it closes.

If the first "pause >nul" wasn't on the script, it would react like this;

First it would say :
"Hello"
"Your coding Batch"
Then once you press a key, it would close because it has nothing else to do.

Now you would want to actually view your script in a Prompt(Batch File Window).
Save the script:



Then open "Test.bat":
Click to view image

Read this over again or ask questions on "Adding and showing a simple string" if you don't understand the use of "@echo off", "pause >nul", "echo", or "echo.".

How to make a Password Protected Batch File

Code:
@echo off

set /p password=Please Enter Password:

if %password%==123 (
echo You have entered the correct password.
pause >nul
exit
) else (
echo You have entered the wrong password.
pause >nul
exit
)

Define:

"set /p <text>=<text2>" - In our case "set /p password=Please Enter Password: ", this makes a little place for the user who opens the batch file to type in their text. 'text2' is the text that will appear right before the editable string.

"if %password%==123 (" - If password (set /p password) equals 123 then do the following things("(")

") else (" - If none of the "If commands" fit, then this is what the script will do. So in our case, ) else ( is used when the password(123) is not typed in correctly.

Creating Loops

The main command used here is ':<text>', and 'goto <text>'
Example:

Code:

@echo off

:willms
echo hello
goto willms

As you might of noticed, the code above has no pause. This is because since its always looping, it needs no pause.

How does this script work?
':willms' Creates a playback point in your script. With playback points you can go back to that part of the script at anytime. What our script does is; First creates a playback point, then echos hello, then finally it sends us back to the playback point and repeats itself.

Will add examples of .vbs and etc later on if I have time.


Last edited by Tricks on Fri Dec 25, 2009 7:50 pm; edited 8 times in total
avatar
Tricks
Coder
Coder

Posts : 68
Points : 2599
Reputation : 15
Join date : 2009-12-22

View user profile

Back to top Go down

Re: [Scripting] Coding Simple Things

Post  Grand Fonic Hymn on Fri Dec 25, 2009 6:46 am

You might want to dumb it down a little more for the people who don't understand the technical terms.
avatar
Grand Fonic Hymn
Spammer
Spammer

Posts : 2385
Points : 1947
Reputation : -80
Join date : 2009-07-26
Age : 24
Location : Sydney

View user profile

Back to top Go down

Re: [Scripting] Coding Simple Things

Post  Tricks on Fri Dec 25, 2009 6:48 am

Equilibrium wrote:You might want to dumb it down a little more for the people who don't understand the technical terms.

I would, I just don't know what to dumb down. Could you help me out?
avatar
Tricks
Coder
Coder

Posts : 68
Points : 2599
Reputation : 15
Join date : 2009-12-22

View user profile

Back to top Go down

Re: [Scripting] Coding Simple Things

Post  Grand Fonic Hymn on Fri Dec 25, 2009 6:50 am

Pictures help.
avatar
Grand Fonic Hymn
Spammer
Spammer

Posts : 2385
Points : 1947
Reputation : -80
Join date : 2009-07-26
Age : 24
Location : Sydney

View user profile

Back to top Go down

Re: [Scripting] Coding Simple Things

Post  Tricks on Fri Dec 25, 2009 6:50 am

Your right. Thanks I will add pictures right away.
avatar
Tricks
Coder
Coder

Posts : 68
Points : 2599
Reputation : 15
Join date : 2009-12-22

View user profile

Back to top Go down

Re: [Scripting] Coding Simple Things

Post  House on Fri Dec 25, 2009 6:56 am

I think it's quite understandable. It's already easy enough.

_________________
PREVIOUSLY REFERRED TO AS: HOUSE


To customize your v62's in-game experience!
avatar
House
Moderator
Moderator

Posts : 1313
Points : 3523
Reputation : 102
Join date : 2009-07-21
Age : 23
Location : Peru

View user profile

Back to top Go down

Re: [Scripting] Coding Simple Things

Post  Settler11 on Fri Dec 25, 2009 5:07 pm

Jup,
I already know it. :P
+1

Greetz,

Will

_________________
WillMS R.I.P. 14-01-2010

avatar
Settler11
Admin.
Admin.

Posts : 3002
Points : 5381
Reputation : 136
Join date : 2009-06-07
Age : 26
Location : The Netherlands

View user profile http://willms.omgforum.net

Back to top Go down

Re: [Scripting] Coding Simple Things

Post  Grand Fonic Hymn on Sat Dec 26, 2009 12:34 pm

You broke it down pretty good.
Imaginary +1 ( Negative Rep, can't actually rep you )
Nothing I don't already know though :]
avatar
Grand Fonic Hymn
Spammer
Spammer

Posts : 2385
Points : 1947
Reputation : -80
Join date : 2009-07-26
Age : 24
Location : Sydney

View user profile

Back to top Go down

Re: [Scripting] Coding Simple Things

Post  MERLIN on Fri Jan 08, 2010 3:30 pm

Thats a realy good explination
I think it works for usernames aswell doesnt it? it would be the same but u add a few more steps? im just learning how to do it so if i get it wrong tell me politely not go
YOUR WRONG and not justify your reason ty
Tom

MERLIN
Member
Member

Posts : 35
Points : 50
Reputation : 1
Join date : 2009-12-11
Location : At Home... In A House

View user profile

Back to top Go down

Re: [Scripting] Coding Simple Things

Post  Aran on Sun Feb 07, 2010 11:56 pm

CMD for dummies.. Can you post some more useful commands in? I would. But i don't have much spare time naw :(
avatar
Aran
GM-Donator/FBI
GM-Donator/FBI

Posts : 88
Points : 123
Reputation : 8
Join date : 2009-12-17
Age : 24
Location : England

View user profile http://aran.omgforums.net

Back to top Go down

Re: [Scripting] Coding Simple Things

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum