1.

Solve : Capturing first input only?

Answer»

hey all,

I'm working a game (inspired by Jacob's good work!) and I'm after a little help...

I have menu's that I require the user to enter 1 or 2 or 3 and so on, but [emailprotected] like to only capture the first inputted value.

example,

if the user enters 20 I'd like only the 2 to be assigned to my variable.

any ideas how??

Cheers in advanceHave a look at this:

Code: [Select]@echo off
echo.
echo Type two digit number:
SET /p a= :
cls
echo.
echo. %a:~0,1%
pause
perfect thanks.

So the :~0,1 is saying keep the 0 and ignore the 1

could this be applied to other strings.

example;

if "1234" was entered, would :~0,1,0,1 capture the 1 and 3???

Cheers again.The best description I can give it is it is like moving decimal points when multiplying or dividing by 10.

a = 25
%a:~0,1%

Go forward 0 times and then select 1 away.

= 2



Just experiment arh, I get it.

:~"number of places to move to the right","how many CHARACTERS to keep"

Nice one.


Cheers mateYeah, there we go.

Glad to help.

Don't FORGET to show us your game when you're done.Quote from: Carbon Dudeoxide on June 16, 2008, 09:09:52 AM

Don't forget to show us your game when you're done.

Gladly, but it might take a while. Ideas just keep coming to me........

so far I've got the basic story line planned out, with a start menu including new game, load and game options. (all work) I've also got my base setup, for buying health, weapons and ammo.

it looks good, but I'm still a long way off.

Cheers the help.


Discussion

No Comment Found