Original problem with the batch file fixed now can I do this

September 19, 2012 at 21:37:22
Specs: N/A
Ok so I got a response to the last question which helped a lot. So can I do this now?
Coding:
Set $=50000
Set food=10
Set water=5
Set pistol=100
Set tent=35
Set matches=1
Set hatchet=20
~~~~~~~~~~~~~~
Insert item list here
~~~~~~~~~~~~~~
Set buy=
Set/p buy=
Set/a $ - =%buy%
if %$%=48500 goto:sorry

Now I'm wondering how to make it display how many of each you got. Basically how many times you typed a certain item. Is this possible?


See More: Original problem with the batch file fixed now can I do this

Report •


#1
September 20, 2012 at 06:11:55
Ick, why would you make a game in batch of all languages. To quote a guy who works on Windows for a living, "[N]obody actually enjoys batch programming. It's just something you have to put up with in order to get something done."

Mysticalchickenwing: Now I'm wondering how to make it display how many of each you got.
I'm not sure what you're asking here.

How To Ask Questions The Smart Way


Report •

#2
September 20, 2012 at 06:45:19
I do Enjoy batch programming. It gives me something to do when I have nothing else to do which is most of the time. I'm asking how to display the amount of times the word was typed. Could you just type if /a %buy%==hatchet set hatchet + =1 and in the beginning have set hatchet=0?

This is basically what I'm asking but I included that section of code seeing if it is possible after that


Report •

#3
September 20, 2012 at 07:53:50
It gives me something to do when I have nothing else to do which is most of the time.
You should try learning a real scripting/programming language. Something with a written rule set. If you have Vista or 7, you can use PowerShell. If you have any version after Win95 pre-IE, you can use VBScript. There are real programming languages, like C# or any of the .NET languages. You could go with something not focused exclusively on Windows, like Python.

Could you just type if /a %buy%==hatchet set hatchet + =1 and in the beginning have set hatchet=0?
You have the "/a" on the wrong command, but yes, you can make a counter.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
September 20, 2012 at 08:00:19
Well the thing is I'm doing this on a computer with windows xp that has no internet. The computer that has Internet lags to the point I want to explode. This computer (having hardly anything on it) is pretty fast and what should I put the /a on if this is te wrong command for it. The /a is working on it but nothing else is for some reason =/ what should I replace the /a with?

Report •

#5
September 20, 2012 at 08:37:37
Suggested reading:
IF /?
SET /?

/A should go with SET. IF has an /I option for case insensitive compare, which you probably want.

How To Ask Questions The Smart Way


Report •

#6
September 20, 2012 at 08:44:45
But /a is with set...and I don't need anything on if but I do need a little help on how to make it to where $ if less than 47000 it goes to :sorry.
I posted this yesterday and edited the 48500 to where it is 4700
if %$%==less 47000 goto:sorry but it just keeps going past that all the time

Report •

#7
September 20, 2012 at 08:58:18
Suggested reading:
IF /?
Seriously, your questions are answered in the help documentation. Read it.
if %$% lss 47000 goto :sorry

How To Ask Questions The Smart Way


Report •

#8
September 21, 2012 at 11:13:06
::from my spare time
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
Set $=50000
::this is only one example
echo
Set water=5 && set /a waterc=0 
::sets water to 5 money units and the number of water the charactor has to 0
::to make things more interesting you could draw data from a txt file, so that you could save charactors

Set buy=
::possibly unnecissary

:infinateloop
cls
echo You have %$% money units (TYPE x and hit ENTER to LEAVE)
Set/p buy="What would you like to buy: "
::more user friendly prompt

if %buy% equ x goto :eof  

if %buy% equ water Set/a $=($-%buy%) && Set/a %buy%c=(%buy%c+1) && goto eclo
::upon selection of water(the example chosen) this sets buy to "5" and adds "1" to waterc(this is the counter for water.)

goto infinateloop
::to cover against mistakes and misentries
:eclo
::only echos if there is a legitimate entry
echo Money Remaining: %$%
set reply=!%buy%c!
echo Item purchased: %buy% QTY on hand: %reply%
PAUSE
goto infinateloop

:: mike


Report •

Ask Question