Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Hello World! is boring, anyone know how to expand on it?


  • Please log in to reply
9 replies to this topic

#1 Purplegill10

Purplegill10

  • Members
  • 90 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Somewhere in the 4th wall
  • Local time:04:25 PM

Posted 18 August 2012 - 12:43 AM

So basically I found out what a batch file really was and found that .bat files could be used for the Hello World! program.
I was wondering, how can I take that and then assign different keys to say different things?

From a curious--Gilroy

EDIT: Not exactly sure this is in the right forum :/

Edited by Blade, 18 August 2012 - 12:45 PM.
Moved to Programming

Even if you are a minority of one, the truth is the truth.
If I had no sense of humor, I would long ago have committed suicide.
Justice that love gives is a surrender, justice that law gives is a punishment.
-Mahatma Gandhi

Gandhi was freakin' awesome

BC AdBot (Login to Remove)

 


#2 jake gardner

jake gardner

  • Members
  • 22 posts
  • OFFLINE
  •  
  • Local time:06:25 AM

Posted 11 September 2012 - 08:27 PM

Where it says "hello world" change it
eg.
echo hello world
@echo off
sleep 5
echo goodbye world
@echo off
sleep 5



that will display hello world then wait and then say good by world

#3 Purplegill10

Purplegill10
  • Topic Starter

  • Members
  • 90 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Somewhere in the 4th wall
  • Local time:04:25 PM

Posted 11 September 2012 - 08:34 PM

Awesome, thx for the reply
Even if you are a minority of one, the truth is the truth.
If I had no sense of humor, I would long ago have committed suicide.
Justice that love gives is a surrender, justice that law gives is a punishment.
-Mahatma Gandhi

Gandhi was freakin' awesome

#4 myrti

myrti

    Sillyberry


  • Malware Study Hall Admin
  • 33,768 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:At home
  • Local time:10:25 PM

Posted 12 September 2012 - 09:42 AM

Hi,

you can alter the size of your window with the command mode con cols=number lines=number, where number needs to be replaced with a number to define the size. You can use the command color to change the color of your command line. COLOR c0 will create black writings on a red background. The command title, will alter the title-bar of your batch.

title my first batch
echo hello world
@echo off
sleep 5
color c0
echo goodbye world
@echo off
sleep 5

this batch will change the title to say "my first batch" and change the color between saying hello world and goodbye world.

regards myrti

is that a bird?  a plane? nooo it's the flying blueberry!

If I have been helping you and haven't replied in 2 days, feel free to shoot me a PM! Please don't send help request via PM, unless I am already helping you. Use the forums!

 

Follow BleepingComputer on: Facebook | Twitter | Google+


#5 Purplegill10

Purplegill10
  • Topic Starter

  • Members
  • 90 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Somewhere in the 4th wall
  • Local time:04:25 PM

Posted 12 September 2012 - 09:13 PM

thanks again, never knew you could do that :lol:
Even if you are a minority of one, the truth is the truth.
If I had no sense of humor, I would long ago have committed suicide.
Justice that love gives is a surrender, justice that law gives is a punishment.
-Mahatma Gandhi

Gandhi was freakin' awesome

#6 DarkSnake-Kobra

DarkSnake-Kobra

  • Members
  • 633 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Iowa, USA
  • Local time:03:25 PM

Posted 12 September 2012 - 10:08 PM

I didn't know ether that you could do colors. B)

#7 luke127

luke127

  • Members
  • 40 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:NSW Australia
  • Local time:06:25 AM

Posted 13 September 2012 - 01:18 AM

Generally @ echo off is at the top of page. So it affects ALL commands under it. It won't ruin your code because I wrote a similar script myself :)

#8 AceInfinity

AceInfinity

  • Members
  • 30 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Canada
  • Local time:01:25 PM

Posted 23 September 2012 - 11:42 PM

Where it says "hello world" change it
eg.
echo hello world
@echo off
sleep 5
echo goodbye world
@echo off
sleep 5



that will display hello world then wait and then say good by world



Hi,

you can alter the size of your window with the command mode con cols=number lines=number, where number needs to be replaced with a number to define the size. You can use the command color to change the color of your command line. COLOR c0 will create black writings on a red background. The command title, will alter the title-bar of your batch.

title my first batch
echo hello world
@echo off
sleep 5
color c0
echo goodbye world
@echo off
sleep 5

this batch will change the title to say "my first batch" and change the color between saying hello world and goodbye world.

regards myrti


@Above - I don't understand though, why you're using @echo off more than once within the same script when it was always off even at the point in time of calling it a second time?? You only need it once, and as this guy stated:

Generally @ echo off is at the top of page. So it affects ALL commands under it. It won't ruin your code because I wrote a similar script myself :)


That is correct, it's typically at the top of your code, and you don't have to set it again. You should also be using PING instead of SLEEP because it consumes less processor time.

@OP - Fool around with some loops, and variable modifiers. Start out with making a basic addition calculator with user input for the first and second numbers, output the total. Be sure to use the /a switch for mathematical operations with variables involved.

Edited by AceInfinity, 23 September 2012 - 11:46 PM.

mvp.png
Microsoft MVP .NET Programming - (2012 - Present)
®Crestron DMC-T Certified Automation Programmer


#9 KingDavidlll

KingDavidlll

  • Members
  • 297 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:06:25 AM

Posted 25 September 2012 - 05:02 PM

I haven't really done much with batch, but you can assign different keys (although you will have to press enter after) to do different things by using a variable and if statements.

Example:
@echo off
:top
set /p var=Type 'a', 'b' or 'c': 
if "%var%"=="a" (
    echo Hello World
)
if "%var%"=="b" (
    echo Too good for Hello World?
)
if "%var%"=="c" (
    echo Oh well Good Bye!
    goto :end
)
pause
goto :top
:end


#10 AceInfinity

AceInfinity

  • Members
  • 30 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Canada
  • Local time:01:25 PM

Posted 25 September 2012 - 11:25 PM

Actually, in XP or later I believe, there's the CHOICE command (executable in an environment location as choice.exe) that you can use. It allows you to input without having to press ENTER.

mvp.png
Microsoft MVP .NET Programming - (2012 - Present)
®Crestron DMC-T Certified Automation Programmer





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users