Inane Coding Go on, slap that wayward code

8Jun/117

Simple user input in batch files

I was recently playing around with batch scripts (*.bat files) - but what I wanted to do with the script snowballed and I found I needed more functionality, the main one being to be able to execute commands based on user input.

Below is an example of the code I used to do this. This is for Windows NT based batch execution (i.e. any recent computer).


SET /P _inputname= Please enter an input:
IF "%_inputname%"=="OMG" GOTO :they_said_omg

ECHO No 'OMG'... frowny face :(
GOTO :end

:they_said_omg
ECHO You said OMG!

:end

Share
3Jun/110

Go on, slap that wayward code

Huzzah, it's alive!

Welcome to this here blog, courtesy of me. I will be bringing you regular articles with examples, snippets of code, and other programming related oddities which I come across during my day-to-day coding.

The articles will be covering a whole range of topics; off the top of my head here are a few areas that I've dealt with very recently which I may cover:

  • C programming
  • PHP, python
  • javascript
  • .htaccess files
  • SQL and interfacing with databases
  • batch scripting
  • VBA and excel
  • CSS and HTML
  • Programming AVR microcontrollers
  • and a whole host of others thrown in for bad measure - essentially whatever I come across.

I aim to make the articles informative and unique, to help you find that useful code example to do that thing you've always wanted to do. You know that thing? Yes that one.

Hopefully a few of the tricks I come across while searching for ways to accomplish things myself will be useful to others, and save you that little bit of time. And... if they do you can always donate!

Take it sleazy,

~Kevin

Share