Introduction: Editing Variables
Hello to all. (This is my first instructable so be nice.) In most informational web sites (ex, Webipidea) you can search for certain topics and facts. In this Instructable, I will show you how to edit out parts of user input and use them as search keywords.
Step 1: How to Do It
Here's how to do it:
First, set a variable (I used %a% for this example, but you can use any thing.)
Shows all but the first 2 letters %a:~2%
Shows all but the last two letters %a:~0,-2%
Shows all but the first 2 and Last 2 letters %a:~2,-2%
Only shows the first 2 letters %a:~0,2%
Only shows the last 2 letters %a:~-2%
Only shows the first 2 letters and last 2 letters %a:~0,2%%a:~-2%
I used 2 for every example, be you can use any number you want.
I've included a program that asks for a word, then cut it up into bits using only the methods used above. You can download it from the bottom or copy and paste it into Notepad if you don't trust me. ;(
title time editer
echo Write a word 6 letters or more long.
set /p a=
echo Full word: %a%
echo First 2 letters gone:
echo Last two letters gone:
echo First 2 letters:
echo Last 2 letters:
echo First 2 and Last 2 letters
echo First 2 letters and last 2
echo letters: %a:~0,2%%a:~-2%
This won't edit the variable's value, it's just some of the variables value from being seen or used. If you wanted to see if someone typed in something starting with your name, you would write:
set /p imput=
if %imput:~0,4%==NAME echo Quit talking about me.
The value itself would noth change, only what's seen or used.
The screen woud show:
Press any key to continue . . .
That would show the first 2 letters of the value of the variable "a," but the value itself doesn't change. If you wanted to change the value of a variable with this method, you would do this:
The screen would show:
Step 2: Another Example
Another thing people sometimes don't know is that their are certain things that you can add to your commands to adjust how they appear on the screen. Here's an example.
-would turn echo off, clear the screen, execute some commands, pause showing "Press any key to continue . . .", execute some commands, then exit.
Adding ">nul" at the end of any of the commands would stops the command from showing it's results.
Long time - no see.
It works be saving the results as nul. (I'm not quit sure what nul is. If any one knows, Please tell me!) This is useful if you hid a copy command in a friends guessing game.
We have a be nice policy.
Please be positive and constructive.