Solved i need help with some code in batch

December 30, 2015 at 16:32:15
Specs: Windows 7
this is my first try at coding so be nice,
i wanted to make a csgo key to gbp converter with tax and no tax. i have the calculations corect but i need help. it just doesnt work so i think i am missing something vital. please can someone help. il put the file and the contents here.its done in notepad++ batch language so yeah...


@echo off
@title: Key to GBP converter
echo say notax if you want no tax
echo say tax if you want me to apply an 85% tax
set /p tax=
if %tax%=notax goto taxless
if %tax%=tax goto taxed
pause>nul
:taxless
echo how many keys do you have
set /p notaxkeys=
set /a notaxgbp=%notaxkeys%*1.65
echo %notaxkeys% directly converts into %notaxgbp%
pause>nul

:taxed
echo how many keys do you have
set /p taxedkeys=
set /a taxedgbp=%taxedkeys%*1.65
set /a taxedgbp2=%taxedgdp%/0.85%
echo %taxedkeys% converts to %taxedgbp2% if you buy quicksells

note: new build, still doesnt work but its better organised and seems to get further. still need some help though:@echo off
@title: Key to GBP converter
echo Would you like tax to be added: Y / N
echo Note: Tax is a 85% addition
set /p tax=
if %tax%==N goto taxless
if %tax%==Y goto taxed
pause>nul
:taxless
echo how many keys do you have
set /p notaxkeys=
if /p==Nul goto taxless
set /a notaxgbp=%notaxkeys%*1.65
echo %notaxkeys% directly converts into %notaxgbp%
pause>nul

:taxed
echo how many keys do you have
set /p taxedkeys=
if /p==Nul goto taxed
set /a taxedgbp=%taxedkeys%*1.65
set /a taxedgbp2=%taxedgdp%/0.85%
echo %taxedkeys% converts to %taxedgbp2% if you buy quicksells

why doesnt this work?

message edited by RegretCoding


See More: i need help with some code in batch

Report •


#1
December 30, 2015 at 19:36:35
To test equality you need:

if %tax%==notax goto taxless

NOT this:

if %tax%=notax goto taxless

=====================

M2 Get custom script or take private lessons


Report •

#2
December 30, 2015 at 20:05:10
✔ Best Answer
Numerous.
set /p tax=
if %tax%==N goto taxless
if %tax%==Y goto taxed
pause>nul

you had it right here, but you messed up on your second rendition:


:taxless
echo how many keys do you have
set /p notaxkeys=
if /p==Nul goto taxless

this should have been same arrangement as your first instance:
if %notaxkeys%==Nul ...

And a warning: batch doesn't handle fractions/decimals. Advise to use some other medium to handle the math. It can be fudged in batch, but requires way too much fu(dg)ing around. batch only handles integers.

message edited by nbrane


Report •

#3
December 31, 2015 at 04:27:27
thanks for the help guys, you are correct about the decimals, it goes all wierd but i thinnk for my first project i made a lot of progress understanding the language . evenm if i didnt actually create a working program xD <3 thanks for helping out guys :)

Report •

Related Solutions


Ask Question