Sinisterly
Batch. The Ultimate Tutorial. - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Coding (https://sinister.ly/Forum-Coding--71)
+--- Thread: Batch. The Ultimate Tutorial. (/Thread-Batch-The-Ultimate-Tutorial)

Pages: 1 2 3 4


RE: Batch. The Ultimate Tutorial. - chipp - 08-22-2011

Quote:Remember, one ">" is to create the file, and two ">" is to append to the file. To save time, you may want to assign the file that you are creating or appending to to a variable.

i just notice it, so i want to clarify, ">>" is to append, and if the file is not exist yet, it will create the file...


RE: Batch. The Ultimate Tutorial. - hackerexecute_mybb_import6869 - 10-23-2011

Very nice tut. I wouldn't say copy and paste though. I would practice typing the codes by heart/memory to analyze them better.


RE: Batch. The Ultimate Tutorial. - Diabolic666 - 11-21-2011

Great tutorial, really usefull Smile


RE: Batch. The Ultimate Tutorial. - ArkPhaze - 11-27-2011

Quote:[spoiler=4. Conditional Statements]

Conditional statements can be very complicated to a newbie in programming languages. But luckily, in Batch, conditional statements are only sand compared to the full beaches of C, C++, Python, and other various Programming Languages.

Try this code!

Code:
@echo off :question echo What's 1+1? set /p input= if '%input%' = '2' goto correct if not '%input%' = '2' goto false :correct cls echo Good job! pause :false echo You are one dumbass. echo Try again echo. goto question

Let's analyze the code!

if: Tells the interpreter to do a command if certain conditions are met. The main conditional statement. What's the variable being used? "Input"! That's right! The ' are optional but highly recommended.

if not: Tells the interpreter to do a command if certain conditions are NOT met.

echo.: Just makes a blank line.

cls: Clears the screen.

[/spoiler]

That is wrong. For a stickied thread there should be no errors in the code lol, but there is unfortunately.

Code:
@echo off :question echo What's 1+1? set /p input= if '%input%' = '2' goto correct if not '%input%' = '2' goto false :correct cls echo Good job! pause :false echo You are one dumbass. echo Try again echo. goto question

You use "=" instead of "==" on these lines:
Code:
if '%input%' = '2' goto correct if not '%input%' = '2' goto false

And why not demonstrate the else part?

Another error I see in this is that, even if you get it correct, there's no goto to define where to go after :correct, meaning it goes to :false right after displaying the correct message, displaying a false echo after saying "Good job!" lol

This:
Code:
:correct cls echo Good job! pause

Should have been:
Code:
:correct cls echo Good job! pause goto:question

And if you wanted a better demonstration of an if logic statement I would have written that like this:
Code:
@echo off echo What is 1 + 1? set /p input= if "%input%"=="2" ( echo Correct! ) else ( echo Wrong... ) pause exit

Please correct the errors.


RE: Batch. The Ultimate Tutorial. - junaidnazir123 - 02-26-2012

Great Sharing ! Keep it up


RE: Batch. The Ultimate Tutorial. - Kaiser Dash - 04-30-2012

Nice, I love it. I already knew batch, but this was a nice refresher.


RE: Batch. The Ultimate Tutorial. - Mr Naj - 04-30-2012

A well detailed tutorial. I'm fully qualified in Batch and It's my strongest language. This definitely covers all basiscs.


RE: Batch. The Ultimate Tutorial. - NgativeZero - 10-05-2012

Wow, this helped out a lot, thanks man, I look forward to more threads on the subject.


RE: Batch. The Ultimate Tutorial. - Mazech - 12-05-2012

ok..nice one...try to swallow the tut..hehe


RE: Batch. The Ultimate Tutorial. - Heartless - 01-05-2013

I have a lots of knowledge thanks bro .....